Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I access the webcam on a MacBook?

What is the proper way in Mac OS X Lion to access the FaceTime/iSight camera built into the MacBook/MacBook Pro and iMac? I have to imagine there is a way to access this outside of using Xcode. What libraries do I need to feed to g++ and how would I compile it? I know people have done this, I am just not sure how I would go about doing it.

like image 756
Red Avatar asked Jul 15 '12 18:07

Red


1 Answers

On Mac OS X Lion you will want to use the AV Foundation framework for video capture. The AV Foundation Programming Guide has clear instructions for how to capture audio and video data. You don't have to use Xcode but you do have to use some Objective-C. If you are primarily programming in C++ you typically will have an Objective-C object compiled with the Objective-C++ compiler to configure the various AV Foundation objects and to serve as the video capture delegate that video frames are vended to. Once you have received the video frames you can pass these back to your C++ code to use as you wish. The whole process is not particularly difficult if you have moderate experience with Objective-C.

Note, if you need to target versions of Mac OS X before Lion (10.7) then you will have to use the QTKit instead. This also requires Objective-C and the techniques for using it are similar but the capabilities of this framework are more limited.

like image 122
torrey.lyons Avatar answered Oct 02 '22 00:10

torrey.lyons