1

I have an app that I want to just show a preview of the iSight camera. I am trying to use QTCaptureView to accomplish this. I have the QTCaptureView window linked in interface builder to the correct variables in my class. I can see the green light on my iSight camera turn on, but I get just a black screen in the app. I have a friend who knows AppleScript that can use the same lines of code converted to AppleScript Objective-C, and it will display the iSight preview within the app.

Here is the code:

self.iSightSession = [[QTCaptureSession alloc]init];
QTCaptureDevice *iSight = [QTCaptureDevice defaultInputDeviceWithMediaType:QTMediaTypeVideo];
[iSight open:nil];
QTCaptureDeviceInput *iSightInput = [QTCaptureDeviceInput deviceInputWithDevice:iSight];
[self.iSightSession addInput:iSightInput error:nil];
QTCaptureDecompressedVideoOutput *iSightOutput = [[QTCaptureDecompressedVideoOutput alloc]init];
[self.iSightSession addOutput:iSightOutput error:nil];
[self.iSightCaptureView setCaptureSession:self.iSightSession];
[self.iSightSession startRunning];
OGHaza
  • 4,795
  • 7
  • 23
  • 29
  • Explore sample projects offered Apple, Inc. – El Tomato Feb 24 '14 at 22:28
  • So.... after completely giving up on trying to accomplish this using QTKit, I tried from scratch again using the same formula as above to display the iSight camera in a basic window, and it now works correctly. I no longer get the camera turning on and displaying just a black screen. I had upgraded my machine to 10.10, where when I originally wrote this, it was on 10.9. I have since sent the code to someone running 10.9 and it works correctly as well. I am assuming I had some weird glitch with my particular computer when it was running 10.9. – petey_wheatstraw Jul 11 '14 at 17:37
  • I'm having a similar problem; I'm using MyRecorder. The video is displayed for a low-cost eBay WebCam, but for another camera (microscope cam), it's completely black. can I encourage you to post your solution as an answer to your own question ? - It might help me in finding out what my problem is. :) –  Sep 22 '15 at 03:15

0 Answers0