| 268 | } |
| 269 | |
| 270 | void CaptureBasicApp::setupCapture( Capture::DeviceRef device ) |
| 271 | { |
| 272 | CI_LOG_I( "\n=== Setting up capture with device: " << device->getName() << " (auto mode) ===" ); |
| 273 | try { |
| 274 | // Stop and fully release old capture |
| 275 | if( mCapture ) { |
| 276 | CI_LOG_I( "Stopping previous capture" ); |
| 277 | mCapture->stop(); |
| 278 | } |
| 279 | |
| 280 | // Reset everything to ensure clean state |
| 281 | mCapture = nullptr; |
| 282 | mTexture = nullptr; |
| 283 | |
| 284 | // Use a working mode instead of the first one (which might be problematic) |
| 285 | if( ! mCurrentModes.empty() ) { |
| 286 | // Try to find 2560x720 mode that we know works, otherwise use first mode |
| 287 | int modeIndex = 0; |
| 288 | for( size_t i = 0; i < mCurrentModes.size(); i++ ) { |
| 289 | if( mCurrentModes[i].getWidth() == 2560 && mCurrentModes[i].getHeight() == 720 ) { |
| 290 | modeIndex = i; |
| 291 | break; |
| 292 | } |
| 293 | } |
| 294 | CI_LOG_I( "Creating capture with mode [" << modeIndex << "]: " << toString( mCurrentModes[modeIndex] ) ); |
| 295 | mCapture = Capture::create( device, mCurrentModes[modeIndex] ); |
| 296 | } |
| 297 | else { |
| 298 | CI_LOG_I( "No modes available, trying default 640x480" ); |
| 299 | mCapture = Capture::create( 640, 480, device ); |
| 300 | } |
| 301 | mCapture->start(); |
| 302 | CI_LOG_I( "Capture started successfully - actual size: " << mCapture->getWidth() << "x" << mCapture->getHeight() ); |
| 303 | } |
| 304 | catch( ci::Exception& exc ) { |
| 305 | CI_LOG_EXCEPTION( "Failed to setup capture with device: " << device->getName(), exc ); |
| 306 | CI_LOG_E( "ERROR: Failed to setup capture!" ); |
| 307 | // Leave mCapture as nullptr if setup fails |
| 308 | mCapture = nullptr; |
| 309 | mTexture = nullptr; |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | void CaptureBasicApp::printDevices() |
| 314 | { |