Question

I'm trying to control auto focus/auto white balance settings for a webcam using OpenFrameworks(a c++ framework), but not having any luck.

The framework provides a QTKit video grabber, but I can't use the settings. There is a videoSettings() function when calling that I get an alert mentioning the project must be compiled with the 10.6 sdk and is not supported when the app is compiled with 10.7+

I'm using openFrameworks 0.8.0 on osx 10.9 and haven't found an easy way to download the 10.6 sdk( There is no direct download (older versions of xcode an sdk download option), I've downloaded Xcode 4.1 but it can't be installed because of osx 10.9).

I've also tried to set the GStreamer grabber, but I get linking errors:

Undefined symbols for architecture i386:
  "ofGstVideoGrabber::ofGstVideoGrabber()", referenced from:
      testApp::setup() in testApp.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

however, I thought the dylibs in the GStreamer framework are also usable for i386:

file /Library/Frameworks/GStreamer.framework/Headers /Library/Frameworks/GStreamer.framework/Versions/1.0/lib/libgstbase-1.0.0.dylib 
/Library/Frameworks/GStreamer.framework/Headers:                                 directory
/Library/Frameworks/GStreamer.framework/Versions/1.0/lib/libgstbase-1.0.0.dylib: Mach-O universal binary with 2 architectures
/Library/Frameworks/GStreamer.framework/Versions/1.0/lib/libgstbase-1.0.0.dylib (for architecture x86_64):  Mach-O 64-bit dynamically linked shared library x86_64
/Library/Frameworks/GStreamer.framework/Versions/1.0/lib/libgstbase-1.0.0.dylib (for architecture i386):    Mach-O dynamically linked shared library i386

I've tried dragging the framework into the 3rd party frameworks folder and adding the paths to Header Search Paths and Library Search Paths in Xcode but no joy.

I've tried using ofQuickTimeGrabber but got a parsing error:

Unknown type name 'ofQuickTimeGrabber'

After tried ofxUVC which uses ofxQTKitGrabber but ran into errors again:

Field type 'ofxQTKitVideoGrabber' is an abstract class

Ideally I would like to control resolution (16:9 formats seem a bit deformed/scaled) and autofocus for the c920 webcam. Is that possible with my setup on osx 10.9 ? If so, how ?

Was it helpful?

Solution

If you download an older version of XCode (the last version of 3 or 4 depending on if you want 10.6 or 10.7 SDKs) from the Apple developer site (https://developer.apple.com/downloads/), it will contain the 10.6 and/or 10.7 SDKs (inside the package).

You can extract the SDKs without installing the full package (which will be disallowed on 10.9). There are several ways to do this, but the easiest I've found is to use Pacifist http://www.charlessoft.com/.

Then place both of those sdks in your XCode 5 SDKs folder at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs folder and to use them with XCode 5.

Then restart XCode and choose the 10.6 or 10.7 SDK in the build settings. Remember to change the SDK for BOTH your project AND the openFrameworksLib project.

Also, to ensure the correct aspect ratio, make sure you are initializing your camera with a specific size (e.g. grabber.initGrabber(1280, 720); if you are trying to get a 16:9 aspect from the camera. By default you are not guaranteed to get the camera's "best" native resolution.

For documentation purposes, here are the steps currently needed to get ofxUVC control over the Logitech c920 camera:

  1. Add ofxUVC and ofxYAML to the openframeworks addons folder
  2. in UVCCameraControl.h set UVC_PROCESSING_UNIT to 3 (#define UVC_PROCESSING_UNIT_ID 0x03 )
  3. in UVCCameraControl.m's setData and getData modify the wIndex to use the selector instead of the unitID (controlRequest.wValue = (selector << 8) | interfaceNum;)
  4. Update the camera definition in the .yaml file

Logitech c920 definition:

- name: Logitech Camera
  vendorId : 0x046d
  productId: 0x82d
  interfaceNum: 0x03
  # 1280x720 (this is 1/2 res)
  width: 1280
  height: 720

Note that the Logitech Camera is the id listed by the ofQTKitVideoGrabber in this case and the cameraToUse at the top of the yaml file is set to 6(c920's yaml 0 based index).

This was succesfully tested on osx 10.7, 10.8 and 10.9

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top