250 |
250 |
camNum = cameraNum;
|
251 |
251 |
|
252 |
252 |
if (!startCaptureDevice(camNum)) {
|
253 |
|
cout << "Warning, camera failed to properly initialize!" << endl;
|
|
253 |
cerr << "Warning, camera failed to properly initialize!" << endl;
|
254 |
254 |
started = 0;
|
255 |
255 |
} else {
|
256 |
256 |
started = 1;
|
... | ... | |
261 |
261 |
CvCaptureCAM::~CvCaptureCAM() {
|
262 |
262 |
stopCaptureDevice();
|
263 |
263 |
|
264 |
|
cout << "Cleaned up camera." << endl;
|
|
264 |
cerr << "Cleaned up camera." << endl;
|
265 |
265 |
}
|
266 |
266 |
|
267 |
267 |
int CvCaptureCAM::didStart() {
|
... | ... | |
296 |
296 |
|
297 |
297 |
IplImage* CvCaptureCAM::queryFrame() {
|
298 |
298 |
while (!grabFrame()) {
|
299 |
|
cout << "WARNING: Couldn't grab new frame from camera!!!" << endl;
|
|
299 |
cerr << "WARNING: Couldn't grab new frame from camera!!!" << endl;
|
300 |
300 |
/*
|
301 |
|
cout << "Attempting to restart camera; set capture property DISABLE_AUTO_RESTART to disable." << endl;
|
|
301 |
cerr << "Attempting to restart camera; set capture property DISABLE_AUTO_RESTART to disable." << endl;
|
302 |
302 |
stopCaptureDevice();
|
303 |
303 |
startCaptureDevice(camNum);
|
304 |
304 |
*/
|
... | ... | |
332 |
332 |
QTCaptureDevice *device;
|
333 |
333 |
NSArray* devices = [QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeVideo];
|
334 |
334 |
if ([devices count] == 0) {
|
335 |
|
cout << "QTKit didn't find any attached Video Input Devices!" << endl;
|
|
335 |
cerr << "QTKit didn't find any attached Video Input Devices!" << endl;
|
336 |
336 |
[localpool drain];
|
337 |
337 |
return 0;
|
338 |
338 |
}
|
... | ... | |
340 |
340 |
if (cameraNum >= 0) {
|
341 |
341 |
camNum = cameraNum % [devices count];
|
342 |
342 |
if (camNum != cameraNum) {
|
343 |
|
cout << "Warning: Max Camera Num is " << [devices count]-1 << "; Using camera " << camNum << endl;
|
|
343 |
cerr << "Warning: Max Camera Num is " << [devices count]-1 << "; Using camera " << camNum << endl;
|
344 |
344 |
}
|
345 |
345 |
device = [devices objectAtIndex:camNum] ;
|
346 |
346 |
} else {
|
... | ... | |
353 |
353 |
|
354 |
354 |
success = [device open:&error];
|
355 |
355 |
if (!success) {
|
356 |
|
cout << "QTKit failed to open a Video Capture Device" << endl;
|
|
356 |
cerr << "QTKit failed to open a Video Capture Device" << endl;
|
357 |
357 |
[localpool drain];
|
358 |
358 |
return 0;
|
359 |
359 |
}
|
... | ... | |
364 |
364 |
success = [mCaptureSession addInput:mCaptureDeviceInput error:&error];
|
365 |
365 |
|
366 |
366 |
if (!success) {
|
367 |
|
cout << "QTKit failed to start capture session with opened Capture Device" << endl;
|
|
367 |
cerr << "QTKit failed to start capture session with opened Capture Device" << endl;
|
368 |
368 |
[localpool drain];
|
369 |
369 |
return 0;
|
370 |
370 |
}
|
... | ... | |
396 |
396 |
|
397 |
397 |
success = [mCaptureSession addOutput:mCaptureDecompressedVideoOutput error:&error];
|
398 |
398 |
if (!success) {
|
399 |
|
cout << "QTKit failed to add Output to Capture Session" << endl;
|
|
399 |
cerr << "QTKit failed to add Output to Capture Session" << endl;
|
400 |
400 |
[localpool drain];
|
401 |
401 |
return 0;
|
402 |
402 |
}
|
... | ... | |
532 |
532 |
- (void)captureOutput:(QTCaptureOutput *)captureOutput
|
533 |
533 |
didDropVideoFrameWithSampleBuffer:(QTSampleBuffer *)sampleBuffer
|
534 |
534 |
fromConnection:(QTCaptureConnection *)connection {
|
535 |
|
cout << "Camera dropped frame!" << endl;
|
|
535 |
cerr << "Camera dropped frame!" << endl;
|
536 |
536 |
}
|
537 |
537 |
|
538 |
538 |
-(IplImage*) getOutput {
|
... | ... | |
641 |
641 |
forKey:QTMovieLoopsAttribute];
|
642 |
642 |
|
643 |
643 |
if (mCaptureSession == nil) {
|
644 |
|
cout << "WARNING: Couldn't read movie file " << filename << endl;
|
|
644 |
cerr << "WARNING: Couldn't read movie file " << filename << endl;
|
645 |
645 |
[localpool drain];
|
646 |
646 |
started = 0;
|
647 |
647 |
return;
|
... | ... | |
923 |
923 |
cc[4] = 0;
|
924 |
924 |
int cc2 = CV_FOURCC(cc[0], cc[1], cc[2], cc[3]);
|
925 |
925 |
if (cc2!=fourcc) {
|
926 |
|
cout << "WARNING: Didn't properly encode FourCC. Expected " << fourcc
|
|
926 |
cerr << "WARNING: Didn't properly encode FourCC. Expected " << fourcc
|
927 |
927 |
<< " but got " << cc2 << "." << endl;
|
928 |
928 |
}
|
929 |
929 |
|
... | ... | |
935 |
935 |
NSFileManager* files = [NSFileManager defaultManager];
|
936 |
936 |
if ([files fileExistsAtPath:path]) {
|
937 |
937 |
if (![files removeItemAtPath:path error:nil]) {
|
938 |
|
cout << "WARNING: Failed to remove existing file " << [path cStringUsingEncoding:NSASCIIStringEncoding] << endl;
|
|
938 |
cerr << "WARNING: Failed to remove existing file " << [path cStringUsingEncoding:NSASCIIStringEncoding] << endl;
|
939 |
939 |
}
|
940 |
940 |
}
|
941 |
941 |
|
942 |
942 |
mMovie = [[QTMovie alloc] initToWritableFile:path error:&error];
|
943 |
943 |
if (!mMovie) {
|
944 |
|
cout << "WARNING: Could not create empty movie file container." << endl;
|
|
944 |
cerr << "WARNING: Could not create empty movie file container." << endl;
|
945 |
945 |
[localpool drain];
|
946 |
946 |
return;
|
947 |
947 |
}
|
... | ... | |
1016 |
1016 |
[NSNumber numberWithInt:100*movieFPS], QTTrackTimeScaleAttribute,nil]];
|
1017 |
1017 |
|
1018 |
1018 |
if (![mMovie updateMovieFile]) {
|
1019 |
|
cout << "Didn't successfully update movie file." << endl;
|
|
1019 |
cerr << "Didn't successfully update movie file." << endl;
|
1020 |
1020 |
}
|
1021 |
1021 |
|
1022 |
1022 |
[imageRep release];
|