17 April 2011
I've been playing around with the QTKit in Cocoa. I looked at the sample code and bar the usual Quicktime weirdness and some threading nuances it all seemed pretty simple. The sample code ran just fine and thanks to the macam drivers I could use my PSX3 Eye with my Mac.
The problem came when I made my own project and copy and pasted some code from the samples. It just never worked!
QTCaptureSession *session = [[QTCaptureSession alloc] init]; QTCaptureDevice *cameraSource = [QTCaptureDevice defaultInputDeviceWithMediaType:QTMediaTypeVideo]; [cameraSource open:nil]; QTCaptureDeviceInput *myInput = [QTCaptureDeviceInput deviceInputWithDevice:cameraSource]; [session addInput:myInput error:nil]; [outputView setCaptureSession:session]; [session startRunning];
cameraSource (line 2) was always nil! This can happen when:
Well I knew it wasn't the first two, the macam test app ran fine and I made sure it wasn't running while I was debugging. I tried creating the QTCaptureDevice from the main thread, from a child thread from an NSObject built from the NIB but nothing. Then I thought.... hang on this is XCode 4..... I flicked the project from 64bit to 32bit and hey presto I start getting a QTCaptureDevice.
There are some references in the docs to certain API calls not being available to 64bit clients but not for this particular call. I'm assuming that if I read all the docs this would all be clear to me but since I am mucking about prototyping something I really just want to build a mess to prove my idea and THEN do it properly. For now I'll just remove the 64bit target.
Coder beware :)comments powered by Disqus