MCPcopy Create free account
hub / github.com/cinder/Cinder / setupCapture

Method setupCapture

samples/CaptureBasic/src/CaptureBasicApp.cpp:270–311  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268}
269
270void 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
313void CaptureBasicApp::printDevices()
314{

Callers

nothing calls this directly

Calls 9

toStringFunction · 0.50
createFunction · 0.50
getNameMethod · 0.45
stopMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
getWidthMethod · 0.45
getHeightMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected