PHOBOSLAB

Blog Home

UVC Camera Control for Mac OS X

For a recent computer vision project I needed to pull images out of a Logitech QuickCam 9000 and track some markers with the help of the ARToolKitPlus library. I connected the camera to my Mac and was quite surprised to see that it just works. There was no need to install any drivers. As I learned later, that's because the QuickCam 9000 is a UVC webcam for which Mac OS X 10.4.9 already provides a driver. I was able to get to the raw camera images through the QTKit Framework in no time.

However, the QuickCam 9000 has its auto exposure enabled by default, which is absolutely deadly for stable tracking results. I thought I could just turn the auto exposure off and set it to a fixed value through some QTKit API – but no, there's no way to change the exposure of a UVC camera with QTKit. In fact, there's no way to change any parameters of your camera. No exposure values, no white balance, no gain, nothing. Apple just implemented the bare minimum in its UVC driver and the QTkit Framework.

Well, maybe I could get to these parameters through the older Sequence Grabber Framework then? After all, there's a VDIIDCSetFeatures function and a vdIIDCFeatureExposure key! But nope, as the name implies, this stuff only works for IIDC cameras. What's an IIDC camera? Wil Shipley asked the same questions almost 3 years ago - even back then, IIDC cameras were pretty much deprecated. Still, these cameras are the only devices that Apple provides an API for, if you want to change some esoteric parameters no one would ever need to change, like oh, the exposure time or white balance temperature for instance.

Apple is aware of the problem but hasn't done anything to solve it. And Logitech apparently doesn't see the need to provide a Mac driver for their cameras, since Mac OS X already ships with one. Great.

But wait, UVC is a standard, right? USB.org provides a documentation for all device classes, and the Video Class is no exception. So, I poked around in the documentation for a while, read some Linux UVC driver sourcecode and used Apple's USB Prober to see what's going on. After some more hours of playing around with the Kernel Framework's USB API, I was finally able to control some of the QuickCam's settings!

UVCCameraControl class

I've now cleaned up the source a bit and organized everything in a UVCCameraControl class. You can use it like this:

UVCCameraControl * cameraControl = [[UVCCameraControl alloc] 
    initWithVendorID:0x046d productID:0x0990];

[cameraControl setAutoExposure:NO];
[cameraControl setExposure:0.9];

[cameraControl release];

All the input values are normalized. Before setting a value the UVCCameraControl class asks the device for the min and max value for that setting and maps the input value accordingly. So exposure, gain, brightness, contrast, saturation, sharpness and white balance all accept values from 0.0 to 1.0.

In this example, VendorID and ProductID are the ones of the Logitech QuickCam 9000. You can use the USB Prober to find the values of your camera. In theory, the UVCCameraControl class should work with all UVC compatible cameras. However, I wasn't able to control the built-in iSight of my MacBook Air at all and I don't have any other cameras to test this with. So all I know at this moment, is that it works with the QuickCam. I've also only implemented those controls that are supported by the QuickCam – other cameras might not support all of these, or might support additional ones.

Note that you only have access to the camera if it is not in use by another process. This means you can't change the camera's settings while using it in iChat or other applications. My understanding is that if you'd want to do that, you'd have to write a Kernel Extension. The UVCCameraControl class is only useful for you, if you use the camera in your own application. So if you're doing blob tracking or marker detection or any other computer vision stuff, this probably is what you're looking for.

UVC Camera Control I also built a simple demo application that makes use of the UVCCameraControl class. This demo uses QTKit to open a connection to the first (default) video device and simply displays the images in a QTCaptureView. There's no system setting to select the default video device, however the device you selected to use in iChat will be the default (you have to quit iChat after selecting your camera, otherwise it will be locked for all other applications).

The controls currently supported by the UVCCameraControl class are:

- (BOOL)setAutoExposure:(BOOL)enabled;
- (BOOL)getAutoExposure;
- (BOOL)setExposure:(float)value;
- (float)getExposure;
- (BOOL)setGain:(float)value;
- (float)getGain;
- (BOOL)setBrightness:(float)value;
- (float)getBrightness;
- (BOOL)setContrast:(float)value;
- (float)getContrast;
- (BOOL)setSaturation:(float)value;
- (float)getSaturation;
- (BOOL)setSharpness:(float)value;
- (float)getSharpness;
- (BOOL)setAutoWhiteBalance:(BOOL)enabled;
- (BOOL)getAutoWhiteBalance;
- (BOOL)setWhiteBalance:(float)value;
- (float)getWhiteBalance;

Download

Consider this as public domain. Do whatever you want with it. I'm not responsible if your camera explodes or for any other damages this software might cause!

Wednesday, July 15th 2009
— Dominic Szablewski, @phoboslab

127 Comments:

#1 – Colby Gutierrez-Kraybill – Wednesday, September 9th 2009, 05:51

Brilliant! I'm very happy you've gone about doing this. Now I shall make time to add in pan-tilt-zoom.

#2Nick Forge – Monday, October 12th 2009, 05:30

Thanks for making this code public! I worked on a Computer Vision project last year where we spent a long time trying to do exactly what you've described.

Just out of interest: have you tested this on Snow Leopard (10.6)?

#3Nick Forge – Monday, October 12th 2009, 05:39

Also, just a quick note on Objective-C/Cocoa conventions - 'getters' in Objective-C are written without the 'get'. In other words, 'getAutoExposure' should probably be 'autoExposure'. If you adhere to the standard naming conventions you can make use of other higher-level Cocoa features like KVC, KVO and Bindings.

#4 – Grant – Monday, October 12th 2009, 22:00

So iChat will recognize my logitech pro 9000, but even after following your instructions the app goes straight to my built in iSight. Any ideas on how to get around this? Thanks!

#5Dominic – Thursday, October 15th 2009, 08:13

@Nick: I did only test this on 10.5. Haven't installed 10.6 on my machine yet.

Thanks for the info about the getter methods; I'm still quite new to Objective-C. I also just noticed that my setter methods should be of type void (they currently return a boolean). Will fix that sometime :)

@Grant: Have you tried using the alternative constructor, like it's described in the source (CameraControlAppDelegate.m)?
- (id)initWithVendorID:(long) productID:(long)

The sad thing is, I couldn't find a reliable way to get the USB location id of the camera from the QTCaptureDevice object, or vice versa. So you not only have to make sure, that my CameraControl class finds the right USB device, but also that QTCaptureDevice does so too.

For testing, you could just try to init the QTCaptureDevice with "objectAtIndex:1" (line 7 in CameraControlAppDelegate.m). I made the assumption that the default device will always be returned first by the inputDevicesWithMediaType method. This might have been just a lucky coincidence on my Mac.

#6 – Chris – Thursday, October 15th 2009, 14:43

Dominic, thanks a lot for this! I'm writing an app for astrophotography, it's pretty essential to have control over exposure time, white balance and the like. Couple of questions though:

1. Is there a good way to programmatically get a list of controls that are supported on a camera?

2. Is there some equivalent to this for non-UVC cameras? (I.e. firewire cameras, and USB cameras with their own drivers).

Btw, you can pretty easily get a list of QTCapture devices (with [QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeMuxed] and [QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeVideo]). I do that and just populate an NSPopup with the device descriptions.

Your method of getting the USB vendor/model seems to work (hopefully it'll stay working - the unique ID being the vendor + model makes a lot of sense so hopefully it won't!) so it should be possible to switch cameras pretty easily.

#7Dominic – Thursday, October 15th 2009, 20:24

1. I guess you'd have to send a request to every UVC control. All supported controls should respond to UVC_GET_INFO (0x86).

2. Well, for Firewire Cameras there's the IIDC standard, which is directly supported by the Sequence Grabber Framework, but for every other camera type you'd probably have to start from scratch.

#8 – Chris – Monday, October 19th 2009, 17:42

Thanks. Looks like a ton of extra work in store for me :(

#9Mike – Tuesday, October 20th 2009, 22:17

Thanks! this is exactly what I need, Happy to report it also works for QuickCam Communicate Deluxe (0x09a2)

#10 – stephan schulz – Wednesday, October 21st 2009, 20:30

Very nice.

Did you have any luck yet with using your class in openframeworks?
If so, do you have a sample project?

thanks.

#11 – John – Thursday, November 26th 2009, 08:45

Nice work.

But I have a problem. When I want to use it with SGChannel object, the USB has been locked by SGChannel. Only if I switch the channel to another webcam, I can open the USB device and set the configuration. Any Ideas??

#12Jeremy – Sunday, December 13th 2009, 20:25

This is rather brilliant. Is there any way that the camera can retain these settings after I quit your demo app? I have a Logitech camera that is always underexposed, except with your app. I can get a rather decent picture on it by simply engaging the auto exposure, which seems to be disables by default.

Any hints as to how to retain these settings?

Thanks!

#13Francis – Saturday, December 19th 2009, 07:39

Awesome!

Works on 0x080a Logitech C905

Thanks!

#14 – chris – Friday, December 25th 2009, 03:22

this looks brilliant. been googling around for ages trying to figure out how to use this with my logitech cam (quickcam e3500 vid:046d pid:09a4) but can't seem to find any way to implement what's provided. i went through the various files in texteditor, trying to get a better understanding of what they do and maybe find a way to enter the vid and pid, but so far i can't make heads or tails of what i'm looking at. the camera control sample demo does recognise the camera (insofar as the image shows up) but the controls don't change anything.
i'd love to figure out how to get this working. any help, as technical as possible or required, would be greatly appreciated.
moc.liamg/at/rettonkmaerd

#15 – chris – Friday, December 25th 2009, 03:35

if i right-click CameraControl and choose Show Package Contents, then navigate to Contents>>MacOS>>CameraControl then run it in Terminal, any action i take in the sample program results in Terminal throwing "no interface to send request".

#16zerm – Monday, December 28th 2009, 14:22

Awesome, I've been searching exactly for something like this!

However, my UVC cam does not work (no logitech but 0x0ac8/0x3420). I've tried to use initWithVendorID:productID: from your sample application but I get "Unable to open interface (e00002c5)". Trying to investigate that, hopefully I can get this working for my cam aswell...

#17zerm – Monday, December 28th 2009, 16:34

Mh, e00002c5 means that the device cannot be opened exclusively. Possibly the QTCaptureDevice blocks it on my mac?

I started to write my own c++ lib, and it appears to me that my UVC camera returns everything in little endian byte order, therefore I need to swap all bytes on my PPC which sounds quite weird - but now i get reasonable values for auto exposure and the exposure min/max values.

#18 – chris – Tuesday, December 29th 2009, 23:45

ok, not sure why, exactly, but your sample app is working now (where it wasn't a couple nights ago). (!!!)

i'm using the logitech quickcam e3500 and have a ustream streaming from it through safari. i use CamTwist to add certain effects to the video being streamed then select CamTwist as video source in the ustream broadcast window.

the exposure setting of the camera since trying it on my mac 10.5.7 has always been fickle, usually being set at maximum exposure which gives a nice picture, but terrible frame rate.

i noticed today while fiddling with the CamTwist effects/controls that my framerate had suddenly jumped up and the motions were being picked up in nearly real time! i'd basically been testing out each effect offered in camtwist, including what i assumed was merely software-based exposure/contrast/brightness/white balance "effects." i've been so excited to see a great picture with really decent framerate that i haven't stopped the stream or done anything differently to try to recreate the results.

however, i decided then to open up the sample CameraControlApp and found, to my delight, that not only does the image show up in the CCApp window while CamTwist is already busy capturing the source, but also the three sample controls all effect the image that CamTwist is capturing.

so, as i said, i have recreated the current result, so i'm not sure if it's a matter of CamTwist capturing the image source in concert with the sample CCApp, but i have the CCApp settings directly affecting the live simultaneous stream that CamTwist "sees." .... which is great!

as for chatting etc, i haven't found a way to manually select a video source for iChat, and chatting in Gmail with GoogleTalk plugin does allow you to select a video source, but doesn't seem to like CamTwist (at least in firefox).

more tests + results to come. for now i'm pleased as punch!
dziękuję bardzo! thanks a billion for this champion effort!

#19 – chris kaprys – Wednesday, December 30th 2009, 00:05

confirm that the quickcam e3500 works with skype (and ustream, simultaneously).

webcam set as video source in CamTwist.
(also possible to set desktop as source, plus PIP and a hundred other wonderous options, from eyecandy to sensible functionality)

skype video source set as CamTwist

opened sample CCApp (*1000 Thanks to this site!)

set desired exposure levels etc.
closed CCApp.

settings remain!

(as mentioned, the CamTwist source is also being shared through Ustream at the same time.. so you can use that information to your own creative ends..)

#20 – chris kaprys – Wednesday, December 30th 2009, 00:14

also confirm with photobooth, sans CamTwist.

quite CamTwist and exited out of browsers etc.

opened photobooth, which still retained (good) settings previously achieved through CamTwist+CCApp.

opened CCApp, and... nothing. just a menu difference. photobooth image froze, so i thought something had crashed. but i quit out of CCApp and then clicked photobooth, discovering that the photobooth image simply freezes when focus is taken away from the app.
opened CCApp again, and the settings were again defaulted to Auto everything, so the picture was bright and clear with bad framerate. unchecked auto settings, made adjustments, clicked on photobooth window and the settings instantly transfered.

closed CCApp and the exposure/white balance/gain settings all remained.

!!

(sorry to keep posting, but this is great news and i wanted to share it for anyone else who's trying to develop on this idea)

#21 – chris – Thursday, December 31st 2009, 14:56

compared to other posters up there, i'm sure i'm the baby of the group, but i'm wondering if anyone would be willing to give me a few pointers. i've done some programming in the past, but not in this particular realm. i'm just trying to get a base-level understanding of how to implement this control class. i've looked at each file in the control class download as well as the sample program, reading the information in textedit. i can see how functions are being called, variables manipulated, etc. i get the general picture of what's going on, but i can't figure out how to change it.
for instance, in the file CameraControlAppDelegate.m
i've found the lines
[cameraControl setAutoExposure:YES];
[cameraControl setAutoWhiteBalance:YES];
which, if i'm not mistaken, initiate the sample program with the check boxes checked on. if i wanted to change these values to NO, what would i have to do with the .m (and/or .h) file(s) in order to make the program reflect those changes?

i'm pretty sure the answer would be to re-compile the program, but that's where my knowledge comes up short. do i somehow use X11 to do that?

as i said, i've done programming in the past, and i am comfortable with terminal and command line operations. just trying to get my foot in the door to begin learning about this type of programming, and play around with this particular (wonderful) find.

thanks much.

chriskaprys
#a.t#
gmail

#22zerm – Monday, January 4th 2010, 17:55

Dominic, as I have already mentioned, I started to re-implement all that stuff and I am slowly beginning to understand UVC as well as this weird IOKit.

From your code, the reason why I have trouble with it is that your setData/getData methods always pass a pointer to long to the controlRequest struct, which is wrong as data of variable length is expected. This results in the fact that e.g. for requests of one byte length, the result is written just into the first of the four bytes of the long (or, read from) and this breaks on big endian machines like the PPC (and is somehow "wrong"). Also, values going to or from the USB are little endian, therefore a conversion might be necessary. IOKit has USBToHostWord and USBToHostLong for your convenience.

For now, I've been able to read the supported settings from the device as well, so if you are interested, we could possibly share some code. I am still trying to eventually read the actual frames from the camera, as I've got the impression that QuickTime is not doing a good job there (and, I'd prefer to just link against IOKit and not also against QuickTime...)

#23Dominic – Sunday, January 10th 2010, 01:40

@zerm: Yes, you're right. I just used the pointer to long out of convenience. The endianness problems never crossed my mind. Sorry about that.

Another interesting thing I found is that for some cameras you don't need to actually open the USBInterface before sending a control request. Maybe that's because it is already "opened" by QTKit?! I don't know. But anyway, if you're having trouble with locked devices, you could try to just skip the USBInterfaceOpen and USBInterfaceClose calls in the sendControlRequest method.

A lot of this stuff was just trial and error. Most of IOKit still eludes me.

#24 – chris kaprys – Monday, January 11th 2010, 19:22

@dominic or anyone else reading this, could someone please direct me to some resources that will help me play around with these functions? i've been looking online for weeks for clues and some kind of direction and fiddling with the files in the sample program and control class, but i'm just lacking that bit of knowledge/vocabulary to be able to research let alone know exactly what it is i'm looking for. so please forgive the n00bness of this question, but is this written in c++? X11? if i have the camera control class and the sample program is recognising and affecting my camera but i want to be able to play around with the programing, where should i be looking? i've altered some of the files to try to do some trial and error, but i'm sure there's some kind of re-compiling step that i'm missing... i don't even know what i'm missing. i'm flying blind.
is there a kind and generous pair of hands out there who could simply tell me what i'm looking at so i knew how to go about experimenting more with it?

thanks so much.
chris

#25zerm – Thursday, January 14th 2010, 11:26

@chris: Everything here is for Apple MacOS X. Cocoa is used and not X11, Objective-C is used and not C++.
You might want to install "Xcode", the IDE for MacOS X. It is freely available somewhere at Apple's website. Probably developer.apple.com There you'll find lots of additional information. However, getting started with Objective-C and coding on MacOS X might be tricky, so you might want to get yourself a good book about that first.

#26 – Alex, Greece – Monday, January 18th 2010, 19:20

Ok, the work you've done is a lot already, so this might be heard a little bit greedy:

Can you upload an update of this extraordinary app with a very helpfull (for Snow Leopard users) adittion of fps (frames per second) control?

Thank you anyway.

#27 – chris kaprys – Wednesday, January 20th 2010, 17:56

@zerm, thank you so much for the info! that's exactly what i was looking for. i was already looking into programming books, but/so that gives me a better idea of where i should be looking.


@alex, as far as i've read and been able to tell (whether used with appropriate drivers on windows or uvc support in mac), the fps is directly affected by / proportionate to the exposure. the higher the value of Exposure, the lower the FPS. on my logitech E3500, which does work with this handy little app, even if i use it with the 'native' drivers in windows, when i turn up the exposure all the way, the frame rate drops. this could depend on the camera itself, but to the best of my knowledge this is basically universally true of usb webcams. of course, the lower the value of exposure, the darker the image capture gets, so if i want a high FPS value, i turn down my Exposure and turn on my (many many lights).
using this particular app, with my camera, my FPS improves dramatically when i set the Exposure Time slider to just a couple ticks below maximum.

try it yourself!
open dominic's sample app.
un-tick Auto Exposure.
slide the Exposure Time marker all the way to the right.
wave your hand in front of the camera.
see the blur.
carefully take the Exposure Time down by one step.
now wave your hand again.
should be a darker image but less blurry movement (higher FPS).
take the Exposure Time down by one more step
(you may need to turn on an extra light now)
wave your hand in the camera again. you should notice great improvement in the FPS.

again, this is just / at least with my logitech usb camera here.

what i mean to point out is that, at least with this (type of) camera, the FPS and Exposure values are not separate settings, they are correlated.

(and, again, that's just based on experiments + lots of reading, but i could be missing some vital information)

#28 – chris kaprys – Thursday, January 21st 2010, 06:19

after the pointers from zerm i was able to fiddle around with more interfaces for the other setting. i applied these to my specific camera, the quickcam e3500. i've added sliders for contrast and brightness and adjusted the gain slider (which was set to adjust brightness before). i also added label fields so you can see the float number that the slider is currently valued at. i changed some of the slider value ranges from the full 0.0 - 1.0 to more "useful" ranges. value changes 3 and 4 decimal places deep (in the thousandths and ten-thousandths) still have an effect on the image, and many of the values in the tenths place were pretty "useless," in my opinion (e.g. exposure settings below 0.7 being almost completely dark).
i also turned off Auto-Exposure being automatically checked when the program starts, and set the defaults to settings that work for me in low-light conditions, so now all i have to do is open this app, then open camtwist, and i'm off to the races.

only thing is, i could not for the life of me figure out how to properly compile the project into a stand-alone executable, so i went as far as i could figure out then just copied out the .app from the Debug folder.
i've linked that below as e3500.app, but in case it doesn't work or you want to see the changes i made to the original sample app, i've also included a zip of the project files.

thanks again to dominic and zerm for the huge first steps they made. after applying a few tweaks to the hard work evident here, i'm now able to control my quickcam e3500's internal video settings for use with any program that will accept my camtwist as a valid video source. this includes skype and ustream, but still not gmail/googletalkplugin nor iChat. but hey, baby steps.

dl.dropbox.com/u/1078859/e3500.app.zip
dl.dropbox.com/u/1078859/e3500project%20files.zip

#29zerm – Wednesday, January 27th 2010, 15:06

Just to keep you updated, since i guess this interests you, esp. also alex:

The FPS is set-up in the negotiation for what video size the camera should stream to mac, which can not be configured using Dominic's approach alone. It obviously depends on exposure times as well, but this can only lower the frame-rate.
For my set-up, it appears to me that QuickTime only grabs the largest possible video frame size, which sadly my camera can provides at only 7fps (which sucks).

My own (QuickTime-independent) driver makes quite some progress. Recently I was able to capture my first frames but as I am still losing quite some packets I need more optimization (and tweaking) in the transfer code.

I hope to get it working in some time soon so you can start to test and help with it. Would be great to get something easy and QuickTime-independent for everything in one little library.

#30 – chris kaprys – Thursday, January 28th 2010, 03:41

@zerm. great work! glad to hear you're making progress. i wish i was at your programming level so i could help out.

now that i'm starting to get more familiar with xcode, if you need any kind of testing or feedback with a logitech e3500 on 10.5.7 let me know.

good luck!

#31 – kureta – Thursday, January 28th 2010, 17:53

this is great news. thank you very very much.

#32 – scott – Monday, February 1st 2010, 04:21

i have a quickcam pro 5000 and C905 (which sadly behaves exactly as described - 5 FPS in reactivision). an application called VideoGlide Capture will have all the features to tweak but alas is not a library but a standalone app.

dominic's app works perfectly as described to quell auto-exposure and auto white balance (i believe the feature is called RightLight-earlier cams had it in software, later ones in hardware) but all changes are lost once the app is shut down.

would love to get my framerates up but i'd be happy enough w/ a quicktime component specifically for logitech cams instead of macam which only works for a few models anyway.

#33zerm – Tuesday, February 2nd 2010, 14:13

You've got a serious spam problem there ;)

i've posted something on my progress here:
ioctl.eu/blog/2010/02/02/mac_uvc_camera_driver
(manual trackback, somehow)

#34 – Immo Colonius – Tuesday, February 2nd 2010, 15:47

works on snow leopard out of the box. Nice piece, thanks for the code

#35Dominic – Tuesday, February 2nd 2010, 19:46

Sorry about all the spam lately. Should be fixed for now.

@zerm: sounds really promising. Can't wait to test it :)

#36 – Andreas – Thursday, February 4th 2010, 21:01

With a few tweaks to the code, I was able to control my builtin iSight with this class (at least autoexposure and autowhitebalance, not sure about the rest). More details at www.paranoid-media.de/blog/.

Thanks a lot for your great work!

#37zerm – Saturday, March 6th 2010, 21:07

I've released first version of my driver. Don't expect too much for now, though.
ioctl.eu/blog/2010/03/06/uvc_mac_release

#38stephan schulz – Friday, March 12th 2010, 17:48

great work.
do you think it might be possible to get access to auto focus?
i am using the logitech vision pro for mac.

thx.

#39zerm – Monday, March 15th 2010, 16:55

@stephan:
please consult the UVC Specifications, you can find them under [1]. Find the corresponding control for auto-focus, there should be a boolean toggle (on/off) as well as set-focus control. then you can add that one to either dominic's or my code.
[1] www.usb.org/developers/devclass_docs/USB_Video_Class_1_1.zip

#40stephan schulz – Sunday, March 21st 2010, 14:39

@ i/o
thanks. i will give it a try.

#41James Snyder – Friday, April 2nd 2010, 01:52

It looks like it's not just a boolean, though it has been done on linux. The autofocus has to be done in software where one controls the motors in response to the sharpness of the image being captured. It's been done on linux:
alex.seewald.at/projects.html
(look for software autofocus)

Presumably by following what's in those projects it should be at least possible to have manual focus. I'm not sure how difficult it would be to autofocus when the camera is in use by some application.

#42jsnyder – Wednesday, April 7th 2010, 01:54

Adding to uvc_controls:
.absoluteFocus = {
.unit = 0x09,
.selector = 0x03,
.size = 8,
},

and then adding the requisite methods will allow absolute focus control on the QuickCam Pro 9000 that I tried. This is not an ideal way to do this, one should look for the UUID of the control instead of having the unit set to 0x09, but it does work for manual focus control. This device doesn't appear to have autofocus, so software control would be required.

#43Alex Beim – Friday, April 9th 2010, 19:34

Hey Dominic

This is great!

I was following this thread on Open Frameworks www.openframeworks.cc/forum/viewtopic.php?f=25&t=2319&p=14721&hilit=uvc#p14721
and found out about this.
We are i need of exactly what you have developed, do you know if somebody got it to work in Open frameworks?

#44Torley – Wednesday, May 5th 2010, 20:10

Wow! I came here searching for a way to disable auto-exposure on my aGent V5. The Windows software can but I couldn't find any Mac software that could... until now.

Thanks so much for filling this knowledge gap, Dominic.

Is there a way to make the settings persist? When I close your UVC Camera Control sample app and open Photo Booth, the settings are as they were before. I'd like to have auto-exposure disabled ALWAYS. I'm not a developer so I appreciate your technical expertise.

#45 – Dave – Saturday, May 22nd 2010, 16:12

Funny thing is I opened your demo app while iChat was already running and using the camera. Exclusively I would have thought - but no. I can control the settings of an active iChat from a concurrent instance of your demo app.

Cool.

#46 – stephan schulz – Wednesday, June 16th 2010, 14:52

hey jsnyder

do you think you can post you project folder that includes the absoluteFocus control. i am still struggling to implement it.
thx, stephan.

#47stephan schulz – Monday, July 12th 2010, 19:34

ok i am now able to turn the auto focus on and off
add this code

.absoluteFocus = {
		.unit = 0x09,
		.selector = 0x03,
		.size = 8,
	},	
	.autoFocus = {
		.unit = UVC_INPUT_TERMINAL_ID,
		.selector = 0x08, //CT_FOCUS_AUTO_CONTROL
		.size = 1,
	},

and further down this
//-----focus
- (BOOL)setAutoFocus:(BOOL)enabled {
	//int intval = (enabled ? 0x08 : 0x01); //that's how eposure does it
	int intval = (enabled ? 0x01 : 0x00); //that's how white balance does it
	printf("setAutoFocus = %i \n",enabled);
	return [self setData:intval 
			  withLength:uvc_controls.autoFocus.size 
			 forSelector:uvc_controls.autoFocus.selector 
					  at:uvc_controls.autoFocus.unit];
	
}
- (BOOL)getAutoFocus {
	int intval = [self getDataFor:UVC_GET_CUR 
					   withLength:uvc_controls.autoFocus.size 
					 fromSelector:uvc_controls.autoFocus.selector 
							   at:uvc_controls.autoFocus.unit];
	
	//return ( intval == 0x08 ? YES : NO );
	//return ( intval ? YES : NO );
	return ( intval == 0x01 ? YES : NO );
}
- (BOOL)setAbsoluteFocus:(float)value {
	printf("focus value %f \n",value);
	//value = 1 - value;
	return [self setValue:value forControl:&uvc_controls.focus];
	
}
- (float)getAbsoluteFocus {
	//float value = [self getValueForControl:&uvc_controls.absoluteFocus];
	//return 1 - value;
	return [self getValueForControl:&uvc_controls.focus];
}


but the setAbsoluteFocus does not seem to work.

any ideas?

#48 – timell – Monday, August 2nd 2010, 19:51

Using the above methods for AbsoluteFocus I was able to get the focus
to work in my Quickcam Pro 9000. At the extreme macro setting, I could focus sharply up to about one inch. I didn't use the AutoFocus code since I believe that would rely on software to implement the autofocus algorithms.

In the XIB file, I added a Focus slider and used the values between 0 and 1 since I think everything is normalized.

Once the camera was focused at the macro level, If I quit the app and tried running iChat or Photo Booth, the camera would remain at the macro focus level and my face two feet away from the camera would be out of focus. So I believe there is absolutely no focus support in OSX. You need to set it once and it will hold that value.

#49 – timell – Monday, August 2nd 2010, 19:57

I guess that I should add, that in the process of playing with the quickcam for focus, I broke the ability to use the camera with the built in Photo Booth application. It works with iChat and iStopmotion fine but when I fire up Photo Booth and get this, with only "some" of the accounts on my laptop all I see is a black screen, but the camera light is on. Hmmph! So most apps work fine with the camera but Photo Booth does not; but only with three of the five user accounts on the same machine. If I remember correctly, I think I've deleted the PhotoBooth.plist but it didn't have any effect. My next action is to look at the VDCAssistant.plist

#50kris27 – Saturday, August 7th 2010, 15:57

Excellent Dominic - thanks for sharing.
I was struggling with UVC CMOS sensors based cameras. I want to use them for astronomy. Got few "different" models and found that AgentV5 and Digible are same thing and guess as well as Logitech 9000 Pro. Difference is packaging and price. Digible was $AU20- compare to the other brands. Anyway they identified as Z-Star and/or/ Vmicro. Problem is autoexposure - it to long and stars were overexposed. Thanks for Dominics code this problem can be overcome. (I never have had Microsoft on my machines) notebook for my portable computing is iBook G4.
The sensors ( can't remember brand/type right nowI, think is Aptina (Micron)) used in this cams also have ability to select area of interest - so you can tell what image size in pixels like to have. Say 1234x432 or what ever. Also pending of size can have high frame rates 320x240 can be as high as 60 fps. Well changing clock speed - (it may involve changing crystal oscillator or clock timing capacitor) Maximum frame size is just a bit over 2k (2048x1536) for sensor used, for digital film camera or you can change to your liking - at this format can do nicely 25/24 frames/sec. Watch out you lights thou. Also you can have raw RGB video out.
Referring to cams above. So - did any one find out how to change frame size yet?
Does any one knows how to calculate sensitivity Volt/Lux/Second to ISO film speed? I did not Google for this yet :-(. It seems that for these cams is very high well over ISO400.)
All together these web cams are quite good - I wish that people that make them have had a bit more sense and would be nice to have ieee1394a/b interface - simply even 1924a is faster than hard disk drive and USB2 and can have up to 64 gizmos on one cable, lots of USB2 puts heaps of load on cpu. Pity, FireWire is available only only on high end prosumer video cams and professional video/film or machine vision devices and just a few notebooks.

Thanks, Kris

#51 – arin – Monday, August 16th 2010, 17:52

Can anyone please let us know the structures for pan and tilt to be used in this sample code.

#52 – fsk – Wednesday, September 8th 2010, 17:34

when i found this code i got so excited. i went and bought a logitech camera to try it. i wish i got the Quickcam Pro 9000. i went for the c910 and this code doesnt seem to work with it.

i get this error:
8/9/10 5:29:16 PM CameraControl[5295] CameraControl Error: Control request failed: e000404f

i moved the error reporting line above the close interface line to see the error number. it is some kind of pipe stall error. any idas why this would happen?

#53 – stephan schulz – Friday, September 17th 2010, 00:40

hey timell

can you please post some code. the one that allowed you to set a fixed focus.

thanks so much.

stephan.

#54stephan schulz – Friday, September 17th 2010, 02:50

true works. but i noticed that for me i first need to activate auto focus, than turn auto focus off and only then i can use a slider to change the the absolute focus value.
otherwise i get an error message : CameraControl Error: Control request failed: 00000000

any how. it works now. yeah.

#55 – Brent – Wednesday, September 22nd 2010, 02:05

Logitech has a list of cameras on their website that are UVC-compliant. I am interested, like Kris, to use a hacked webcam for astrophotography, and two that work well seem to be Logitech's Pro 9000, and Fusion. I located a fusion (part #861304-0000) and it works fine on OS X. Dominic's code also works well with it. What is frustrating is while Logitech provides a part number (p/n) such as 861304-0000, it is hard to find that same number elsewhere, like Amazon. Amazon will list it as 961304-1234; a lot of sites have 9 as the first digit, compared to Logitech's 8. It's odd and confusing.

So what's the difference between a higher-end logitech camera, and a $20 special? I picked up the 1.3MP Dynex UVC webcam at a local BestBuy ($25-30, depending) to see. In the same environment, it gave just as good image quality as the Logitech Fusion, but ONLY in VERY well lit situations. The Dynex image goes dark well before the Logitech camera, as the lighting level drops. As for UVC compliance, the Fusion provides sane values for the nine parameters in Dominic's code (exposure, whitebalance, gain, etc). The Dynex camera ONLY supports exposure. The Dynex cost $25; a used Fusion also cost $25. But the Fusion is about 10x the camera. And the Pro 9000 is even better I hear.

It's surprising (well, not really, it's Apple) that the builtin iSight camera is entirely uncontrollable via UVC. Pitiful, Apple, it really is.

Thanks for the great code base, Dominic!

I just found this excellent page while looking for the list of Logitech UVC-compatible cams:
www.quickcamteam.net/devices
Check out the PDF of UVC cams -- it lists both the 8- and 9- part numbers I mentioned.

#56 – mikej – Saturday, October 16th 2010, 20:22

Hi:
I'm trying to turn off autofocus on an HP Premium autofocus Webcam. Your app works beautifully to control the exposure, but the tweaks above don't have quite enough detail for an Xcode newbie. I've tried hacking them around, with no success. I can attach more output from usbprober if that would help. This is a subset.

            VDC (Control) Input Terminal   
                Length (and contents):   18
                    Raw Descriptor (hex)    0000: 12 24 02 01 01 02 00 00  00 00 00 00 00 00 03 2E  
                    Raw Descriptor (hex)    0010: 00 02 
                bDescriptorType:   0x24
                bDescriptorSubType:   0x2
                Terminal ID   1
                Input Terminal Type:   0x201 (Camera Sensor)
                Input Terminal ID:   0 [NONE]
                Input Terminal String Index:   0 [NONE]
                Minimum Focal Length   0
                Maximum Focal Length   0
                Ocular Focal Length   0
                Controls Supported   Description
                       Auto Exposure Mode
                       Auto Exposure Priority
                       Exposure Time (Absolute)
                       Focus (Absolute)
                       Focus, Auto

Thanks for any help.

#57Alexander Grau – Thursday, February 3rd 2011, 15:28

Brilliant! It works with my 'Logitech QC 3000 for Business' (UVC webcam) and now I can set exposure for this camera so I can move around the camera quickly on an outdoor robot (I'm using two of them for a stereo vision project with OpenCV - btw, using two USB cams seem to work only using QuickTime API, not the newer QTKit API ... and you have to first open any MacBook iSight cam, then the two external webcams, then closing again the iSight cam ... happy hacking! ;-) ).

#58 – stephan schulz – Friday, February 25th 2011, 21:34

i just got the logitech c910 true HD cam but the code that worked for the Logitech QuickCam® Vision Pro for Mac® does not work for the c910.

i guess i have to hunt for the right uvc references.
or did anyone find them already?

thanks,
stephan.

#59 – stephan schulz – Tuesday, March 1st 2011, 21:58

i found out i need to change the productID to 0x0821

cameraControl = [[UVCCameraControl alloc] initWithVendorID:0x046d productID:0x0821];

but it still does not connect.

//error message: CameraControl Error: Control request failed: 00000000

#60Michael SILVESTRE – Tuesday, March 29th 2011, 10:13

Hi Stephan, i have exactly the same webcam : Logitech C910, but i have the same problem too...
If you find any solution, please share it with us please...

#61Elliot Woods – Wednesday, March 30th 2011, 18:26

oh dear.
i wish i read to the end of this comment thread before going out and buying a c910 today!!

@stephan (/Michael)
to get a meaningful error message out (instead of 8 0's) i suggest changing the end of sendControlRequest function in uvc_camera.cpp to

if( kr != kIOReturnSuccess ) {
NSLog( @"CameraControl Error: Control request failed: %08x, system(%04x), subsystem(%04x), code(%04x)", kr , err_get_system(kr), err_get_sub(kr), err_get_code(kr));
kr = (*interface)->USBInterfaceClose(interface);
return NO;
}

this means that it'll output the error from the previous function, not the error from the USBInterfaceClose command (which always gives a 0)

my error is
CameraControl Error: Control request failed: e000404f, system(0038), subsystem(0001), code(004f)

where subsystem refers to USB and code refers to kIOUSBPipeStalled (which is what @fsk above appears to have also experienced)
I'm not entirely sure what a kIOUSBPipeStalled issue is, but some people on the internet suggest that it may be a response to an unsupported function.
(*interface)->ClearPipeStall might be useful for clearing up the stall, but chances are we simply need to figure out what's causing it in the first place.

I've also tried @zerm's own approach which is pretty nice (if it worked with the c910, which for me it doesn't).



According to
forums.quickcamteam.net/showthread.php?tid=1345
the c910 supports either YUYV (aka YUV2) or MJPG compression

YUYV gives 4:2:2 colour data
i.e. for every 2 pixels horizontally, 32bits are sent
8bits of luminance per pixel + 16bits of colour shared across the 2 pixels (UV represent the distance of the colour along blue<->yellow, red<->cyan respectively)

This means that it's possible to receive lossless luminance values for the whole image, if we can access the YUYV data (which i presume will be more simple with zerm's approach). MJPG seems to be the default, and also offers higher framerates as it takes much less bandwidth.

I hope we can make some progress with this! :)

Elliot

#62Elliot Woods – Wednesday, March 30th 2011, 19:06

btw, which OSX/cpu/build architecture are you using with c910?

I'm on 10.6, with Core2Duo, tested i386 and 64bit

I've started a thread on forums.quickcamteam.net/showthread.php?tid=1583
to spread the problem a little further :)

#63Elliot Woods – Friday, April 1st 2011, 04:51

My findings when evaluating the Logitech C910 camera for computer vision tasks
bit.ly/logitechc910

#64 – stephan schulz – Thursday, April 28th 2011, 01:45

i noticed today that the logitech QuickCam Vision Pro for Mac is not available anymore in many online stores.

i tried to control the Webcam Pro 9000 but had no success. i get an image but no controls.

stephan.

#65 – cnegle – Friday, April 29th 2011, 09:14

Guangzhou cnegle silver is a professional production of songs and wholesale 925 silver jewelry manufacturer. Products are 925 silver rings, pendants, necklaces, bracelets, chains, etc. Has a group of professional technicians and a number of creative professional design talents, their own production workshops and advanced production equipment and website members exchange platform integral policy, pay attention to product quality,! Preferential prices, breed diversity, the factory product design updates faster, favored by the vast number of dealers and consumers silver high praise. Long-term with quantities. Welcome old and new customers to choose custom, dazzle gives your charm, countless wealth jewelry is here click start: www.jewelryinchina.com

#66 – Zeitkind – Monday, May 2nd 2011, 10:34

Thx for that code, I use it to control a x-box USB-Cam from Microsoft. It somehow now works, at least, I get a picture and not only a white page..

#67 – ILS – Wednesday, May 4th 2011, 06:16

Has anyone made any progress with controlling the C910? Specifically I need to turn off auto-focus, auto-white balance, and zoom control for use with CamTwist. Anything else is a bonus. Logitech seriously dropped the ball with C910 on Mac. Try using it when sitting in front of a non-white wall...

#68 – lightningad – Monday, May 16th 2011, 10:50

hmmm - i tried to get the demo app to work on my MacbookPro (10.6.7, intel 2.8ghz Core i7) but all i can get the app to show is the built-in iSight.

As instructed i set my iChat to use the webcam (Agent V5), quit iChat then start demo but it always defaults back to iSight.

I could really use this software as i'm trying to use the Agent V5 for doing some stop frame animations, but autoexposure is really spoiling them.

Any suggestions? bearing in mind i'm not a programmer and i haven't a clue about any of that code stuff mentioned on here!

#69 – USFLUX – Saturday, May 28th 2011, 07:30

Not working for the C910. The app runs and the camera shows up in the window, but the controls have no effect.

Using USB prober I noticed a few numbers (ID's, etc.) are different. Changed a couple to see, but nada. Also, the list of supported controls under Input Terminal and Processing Unit are different (for example, there's no "Auto Exposure", but there is "Auto Exposure Mode" and "Auto Exposure Priority"). I'm not a programmer so I am throwing darts into the fog. I'd love for this to work!

I'd also love it if someone turned this code into a Quartz Composer plugin.

#70 – USFLUX – Saturday, May 28th 2011, 07:33

Ps. In fact, I'd pay a semi-nominal fee if someone wanted to take up the cause for Quartz Composer.

#71 – max – Tuesday, June 7th 2011, 13:03

yes, it's not working for the C910.... :-(

#72 – hiren Shah – Saturday, July 16th 2011, 13:34

How can i add Zoom,Crop features in this application.
Can any one help?

#73 – Vinesh – Tuesday, August 30th 2011, 13:20

You are genius, thanks alot for sharing this!

#74 – Diode – Monday, September 12th 2011, 19:36

Hi,
Many thanks first of all!
Been trying to get this to work with a Microsoft Lifecam, which runs, but the problem is that the exposure slider works inverted - i.e. if I drag the exposure slider to the left, the exposure actually becomes larger (up to a full white overexposed image) and when I drag the slider to the right, it becomes shorter / darker.
That in theory doesn't have to be an issue, but the problem is that I cannot get the exposure dark enough - 0.9 or 1.0 (darkest) are still brighter than when I re active Autoexposure.
Does anyone recognise this, and perhaps have (a hint towards) a solution?
Defining the vendorID/productID gives no difference, works just the same.
Thanks!

#75sam – Tuesday, October 4th 2011, 10:20

i think i got it working for the C910, i.e. the pipe stalls went away. in the UVC spec it says that for the wIndex one should pass in the interface number, which is 2 for the C910. so do a

controlRequest.wIndex = (unitId << 8) | 0x2;

when forming the requests.

#76 – mcv – Thursday, October 6th 2011, 18:02

How did a UVC camera on a Mac "just work" for you? I can't find mine anywhere, and I can't find any documentation on how to access it. Preferably, I'd like to access it unix-style as /dev/something.

#77johnboiles – Friday, October 7th 2011, 19:28

@sam I can confirm your fix makes it work with the C910. Good sleuthing. Thank you!!

#78johnboiles – Saturday, October 8th 2011, 08:26

ok I got manual focus working for the C910. I used the following

.absoluteFocus = {
.unit = UVC_INPUT_TERMINAL_ID,
.selector = 0x06, // CT_FOCUS_ABSOLUTE_CONTROL
.size = 2,
},
.autoFocus = {
.unit = UVC_INPUT_TERMINAL_ID,
.selector = 0x08, //CT_FOCUS_AUTO_CONTROL
.size = 1,
},

#79 – Nikopraxis – Tuesday, October 11th 2011, 14:46

While searching the net i found this page. I'm looking for manual controls for the C910 on Macosx Lion.

I'm a complete noob in programming. But desperately looking for the software working with the C910. Could anybody please post the controls with fixes for the C910. It would really help me!

thnkx

#80 – Nikopraxis – Tuesday, October 11th 2011, 14:47

by the way, i already tried to tweak the software with the answers above. So i'm not lazy, just a noob...

#81 – chris kaprys – Tuesday, October 11th 2011, 23:03

so glad to see this is still alive!

have a quick uvc/quicktime question that should be well suited to those who are still reading/finding this log.

i installed iLife '09 on my 10.6.8 snow leopard today, with the hopes of using my usb webcam as a source for film clips in iMovie. after loading up iMovie and getting the "no camera connected" message i did some quick research (too late) to discover that this feature of iMovie is intended for DV cameras connected through Firewire.

however!

at some point in all my camera fiddling i went and installed iGlasses 3, which is basically a software-based camera controls and effects maker that integrates itself with the other apps on the mac. when using iGlasses in, say, Skype, or iChat, or even in Photobooth, you simply select the camera as though it were another connected to your system (much in the same way that 'macam' behaves, if i remember correctly).
now, the juicy bit: with nothing else open, i fired up iMovie. no camera. no surprise. then, while i had photobooth running and detecting my Logitech webcam, i opened iMovie again and, voila! it detected "iGlasses" as my [only] camera, and i made a quick recording, which performed beautifully, and even used the audio from the Logitech camera (i have no other mic connected to the computer).

note: when i quit out of both programs and tried just iMovie on its own, 'no camera connected.' then i repeated the step of leaving photobooth running with the signal from the Logitech, and opened iMovie: 'no camera connected'. hmm... so i opened up Activity Monitor and found iGlasses running in there. after 'quitting' or 'force quitting' (both worked equally) iGlasses, i could successfully recreate the solution.
1) make sure no iGlasses process is running
2) open Photobooth and feed it the signal from the Logitech webcam
3) open iMovie and use Command-I to Import from Camera.

now, filtering the source through iGlasses wasn't an ideal solution, and **this is where the question for this log's readers comes into play**

i remember when i was fidgeting around with my old Logitech E3500 on my mac with Xcode (see several posts (years?) ago), i came across some information regarding the way Dominic's sample code finds the usb camera, and the probing of usb source in general. so i figured: iMovie recognizes the iGlasses "camera" as long as the actual camera is currently busy. i tried tricking the OS and iMovie and switching the order of things. no luck. iMovie only liked the iGlasses 'camera'. so i dug around in a drawer and got out my old Logitech E3500, and plugged it in, again, trying to play around with and trick the OS and/or iMovie into recognizing a 'first' and 'second' and 'third' camera. but, again, no dice. iMovie only made friends with iGlasses. so then i figured there must be some function, some framework (pardon if i don't know the right terms yet) that iGlasses is using that passes its signal on as a software-based 'camera' that iMovie recognizes.

if any poor soul out there actually read through all of that, could you tell me: what is this relationship that i've stumbled upon? if i could get my hands on iMovie and/or iGlasses documentation, or even start rummaging through various 'packages' within the apps, what would i be looking for?

at the end of the day, i'm still trying to understand the relationship of the UVC-compatible camera to the Mac OS X. i wouldn't call this information a 'breakthrough,' but i certainly would consider it to be a happy accident that might further me down the path of what i hope to understand.

tia for any further light that someone might shed on the subject.
and for anyone who is interested in the usb video import capabilites with iMovie, i'm using iMovie 8.0 (717) and iGlasses Demo v3.0.2 with a Logitech Quickcam Vision Pro (but the E3500 does a decent job as well, especially after 'tricking' it with Dominic's sample code/app.)

thanks again!

#82 – chris kaprys – Wednesday, October 12th 2011, 04:36

thank you john!!!

dominic, if you would rather i not post links to files in here please let me know, or i suppose just delete this. but i was so excited by this simple 'furthering' that i couldn't resist providing a couple sample files.

while testing i had the PID and VID set to my specific camera, the Logitech Quickcam Vision Pro for Mac. after i got the various sliders functioning the way i wanted for the camera, i reverted that section of Dominic's code to the the 'catch-all' generic UVC usb camera finder (in so many words).

the resulting app, as a logical extension to Dominic's hard work, can be found here: db.tt/XYsFGUJO

after reverting the 'camera-finding' section of the code back to the way it was originally, i unplugged the Quickcam Vision Pro and plugged in my old Logitech E3500 (which still, STILL has the hardware fault of muting the audio feed from the mic if you turn it up all the way, even on a system as foreign as a Mac OS. incredible..). anyway, i fired up the Quicktime which came with my Snow Leopard and made two quick sample recordings, one with each camera, both on Medium quality in Quicktime (Maximum quality video recording with the Quickcam Visio Pro pumps the resolution up to a ridiculous 1600x1200, with an framerate of ~5 fps -- i spent 4 hours this afternoon playing with quicktime .plist files and researching QTCompressionOptions[etc]H.264vido classes trying to force the Maximum to a lower resolution, but with no luck yet). this is by way of saying that the actual video feed on the screen was noticeably of much better quality than the subsequent coding that Quicktime's H.264 coding automatically compressed it into. it gives decent results, but not great. that said, it's better than what Photobooth's native video compressor has to offer.

anyway, in the name of research and development, a couple late night wine-soaked samples of further implementation of Dominic's work, with Focus/Auto-Focus put to use via johnboiles' discovery.

Logitech Quickcam Vision Pro for Mac: db.tt/3qpEYU1N
Logitech E3500: db.tt/ABWIS1gi

peace.

#83 – chris kaprys – Wednesday, October 12th 2011, 04:42

sorry! don't mean to spam! re: the last comment and app, i found that the best compromise for quality and framerate with the quickamVP4M was reached by changing the 640x480 pixel buffer values to 800x600. so:
[NSNumber numberWithInt:640], kCVPixelBufferWidthKey,
[NSNumber numberWithInt:480], kCVPixelBufferHeightKey, nil];

became:

[NSNumber numberWithInt:800], kCVPixelBufferWidthKey,
[NSNumber numberWithInt:600], kCVPixelBufferHeightKey, nil];

the retouched sample app includes this change, and both sample vids were recorder under those conditions.

chris

#84 – chris kaprys – Wednesday, October 12th 2011, 04:58

@diode: does your fps change during those manual exposure settings? i'm wondering if the exposure slider isn't actually controlling your gain/gamma. also, you can try experimenting with values of the exposure's slider, using Interface Builder (with Xcode). for the Logitech stuff i've been playing with, the values that offered a noticeable change were either between 0.9 and 1.0 (e.g. manual exposure) or 0.0 and 1.0. playing with your exposure's slider maximum and minimum values might shed some light.

i'm still shooting in the dark, so take my thoughts with a pinch of salt (.. and, don't look a gift horse in the mouth, or make him drink lead water, or, some bumbling cliche)

#85 – Nikopraxis – Friday, October 14th 2011, 23:16

Still nothing for C910?

Thanx

#86chris kaprys – Monday, October 17th 2011, 01:32

niko. looks like johnboiles (above your last comments) had some success with the C910. his comments helped me understand what i was previously failing to understand about the UVC documentation, and then the same input he shared got the focus working/in control on my logitech quickcam vision cam, as well as other features of my older E3500, once i better understood the code i was looking at and how to use it and adapt it. i feel i've already bombarded this thread enough, but if you want to get in touch with me for some help and explanations, i've provided a url in the link box (next to my name). i'm also on the noob end of the spectrum, but i'm so pleased with the advances that the comments in this page have helped me make that i'd love to share with someone else who's willing to learn. cheers. c

#87 – sgb – Wednesday, October 19th 2011, 14:52


Hi, anyone know how to copy the frame pixels from the capture session to an Array? Is just that I can´t figure out where are the pixels data. I need the RGB pixels for some processing. If anyone have a nice tutorial or advice, I will very thankful.

Cheers.

#88 – Dustin – Friday, October 28th 2011, 17:26

I am using a Logitech C905 camera on a Mac osX Snow Leopard. The ultimate problem I have is that the camera image will get dark over time ( if ran for a few days straight ). We use the camera in an app that takes a picture every 5 seconds. It seems to me that the auto-exposure gets disabled somehow. I hope that if I am able to install this modified driver found on this page that it will force the auto-exposure to always be on.

I am confused as to how to install the modified UVC driver so it can always run with out running CameraControl app. I am under the impression that the download file "uvc-camera-control-class" is a modified version of the existing uvc driver. In this regard, my thought is that I will need to replace the existing driver with this modified one.

If it is not a replacement, Then where can I find the existing UVC driver on a Mac osX Snow Leopard? Once I find it, will I just have to modify the existing UVC driver with some code from the downloaded driver?

I have looked at the documentation posted by I/O Zerm and found some hex commands that will do the trick if i just knew where I could implement the codes at.

#89 – Dustin – Friday, October 28th 2011, 17:29

*** EDIT ***

Thanks,

*** EDIT ***

#90 – Matt – Sunday, October 30th 2011, 16:19

I have the same questions, Dustin. I hope someone here can help. If someone were to come up with a simple system preference that allowed control of the UVC settings that, would be amazing. I would pay good money for that.

#91Beads – Sunday, November 6th 2011, 05:01

Sorrow is hushed into peace in my heart like the evening among the silent trees.
Achievement provides the only real pleasure in life

#92Gemstone Beads – Sunday, November 6th 2011, 05:02

If you wish to succeed , you should use persistence as your good friend , experience as your reference , prudence as your brother and hope as your sentry.

#93sluggo – Wednesday, December 14th 2011, 22:06

nice work!
found a little bug while writing my own implementation (for another project):
UVCCameraControl.m:232: controlRequest.wIndex = (unitId << 8) | 0x00;
wIndex high byte should indeed be the terminal id but the low byte is supposed to hold the interface number of the video-control interface. that's often interface 0 but on some multi-head (cam, mic, speaker, etc) devices, eg. logitech c910, the video-control interface has some other index.

// sluggo

#94paulobarcelos – Tuesday, January 3rd 2012, 00:07

Hey @sam & @sluggo, I was wondering if there is any way to find out dynamically the interface id of the video-control, interface... Where did you find exactly that, for example for the C910, the interface index is 2 and not 0? Was it empirically? Or is there a reference somewhere?

I am writing an openFrameworks addon to wrap the UVCCameraControl, and it would de immensely useful if it could workout by itself the interface id once it had successfully connected to the camera via vendor&productID/locationID

#95sluggo – Sunday, January 8th 2012, 00:51

@paulobarcelos
It's actually just a matter of finding the interface with base-class 0x0e, CC_VIDEO and subclass 0x01, SC_VIDEOCONTROL (for all subclass codes you can check out appendix A of the standard, www.usb.org/developers/devclass_docs/USB_Video_Class_1_1_090711.zip).
Sent you an email with some more info..

// sluggo

#96 – Alessandro Previti – Thursday, February 16th 2012, 11:59

Hi !
My name is Alessandro, I'm developing a a.r. app for my art studies.
As you i'm having terrible problems due to the poor cam support from apple os and I think this uvc drivers could save my artistic project!
The problem is that i'm not a programmer at all and my knowledges of flash scripting are more pragmatical than theoretical.

Could someone help me to make this uvc driver work with my c910?

Please!
Alessandro Previti.

#97 – urbeller – Tuesday, February 21st 2012, 19:55

Nice job ! Managed to have an image from my C910 but sliders have
no effect on the camera. Despite the suggestions aforementioned (right vendorId/productId , wIndex padded with interface id...) my
sliders have absolutely no effect. Any idea ? I run Mac Os Lion

Thank you,

#98football jerseys for sale – Wednesday, April 25th 2012, 11:15

I have the same questions, Dustin. I hope someone here can help. www.f-footballjerseys.com

#99hockey jerseys – Saturday, April 28th 2012, 05:59

we can try our best to do better www.h-hockeyjerseys.com

#100joohaeng – Monday, June 11th 2012, 11:54

I would like to share the working code to control C910. It can turn off autofocus and control the manual focus levels. Thank you all for helpful tips!

Source code: www.dropbox.com/s/qnjpl9diggx0s60/Control-Cam-C910.zip

Blog (in Korean): geolix.blogspot.kr/2012/06/uvc-control-of-logitech-c910-webcam-on.html

#101Greg Borenstein – Wednesday, July 11th 2012, 19:21

@Diode: I'm also working with a LifeCam (an HD-3000 in my case). I was able to make some small progress with exposure settings. I changed the getDataFor function to use the same bit-shifting as setDataFor in its calculation of the wIndex:

controlRequest.wIndex = (unitId << 8) | 0x00;

The result was that when I toggled auto-exposure off, the camera stayed at its current exposure setting rather than falling back to whatever default (wildly overexposed) setting it did previously.

I also think the exposure setting range may be working now (I stopped getting an error when setting it), but I can barely see the results (besides the black at the 1.0 setting like you say). I wonder if this has to do with the difference between absolute and relative control of exposure time as defined in the UVC spec. Absolute control sets the length of the exposure (in units of 1/10,000th of a second). The relative setting for the Exposure Time control sets the electronic shutter speed. That seems to work in some kind of relative manner with successive commands incrementing or decrementing the shutter speed. The comment in UVCCameraControl.m indicates that it's set to CT_EXPOSURE_TIME_ABSOLUTE_CONTROL. But the way it's acting (at least for me) seems to feel a lot more like the relative control (which is a three-way toggle where 0 jumps it to the default, 1 increments it by one step and 0xFF decrements it by one step). If I move the toggle to any position besides 1.0 it jumps to what feels like a default setting (pretty well exposed for normal lighting). If I send it a 1.0, it drops down to very under-exposed (like it would if you sent it 1 a couple of times). I'm going to try to poke around a little bit and see if I can get it to either actually get set to absolute control or if I can send it an 0xFF so as to have full control of the relative mode.

#102 – Paule Delaney – Thursday, July 26th 2012, 02:27

Folks,
I use a Microsoft Lifecam Cinema and I experienced the "overexposure and lack of white balance control" described above.
Q1.Can someone tell me -if by any chance- the new Mac OS Mountain Lion resolves those issues.
Q2. Has anyone tried it with the Microsoft Lifecam Cinema?
Q3.I need to find a user friendly way to use the Microsoft Lifecam Cinema on Mac to record 720p video @ 30fps. If possible, I would use Quicktime for recording or any Recording App as long as it user friendly. Ultimately, if you need to have some of the work above built in One Single App.

I am not a programmer. Can anyone help me?

#103 – glasspusher – Sunday, September 2nd 2012, 17:37

@sam

your fix for the c910 also works for my c525. Awesome! Thanks to everyone for this, fascinating.

also, if people are getting goose eggs for the error code in that getControlRequest method, be sure to get the NSLog moved up, so it executes before the USBInterfaceClose.

Good show!

#104 – glasspusher – Sunday, September 2nd 2012, 17:44

@Paule

reading this thread:

forums.macrumors.com/showthread.php?t=767649

seems that even iGlasses doesn't help. It appears that with webcams, caveat emptor. Better to do the research before getting one, to make sure that a webcam can do all you want, before you buy it. I know how you feel. I lucked out that my webcam could use the stuff on this page.

#105 – Andreas Mohr – Monday, September 3rd 2012, 08:52

Hi,

perhaps it's useful to do USB access via libusb instead, to have a cross-platform (and possibly simpler) USB abstraction.
For a related effort that is using libusb, see "[libusb/uvc] cross-platform autoadjustment killer.." www.dm9.se/?p=614 (and uvcc in its Downloads section).

Thanks for a very nice effort in getting camera support in (the yet again infrastructure-deficient) OS X improved!

#106 – Jacek – Wednesday, September 19th 2012, 15:35

Hi guys! thanks a lot.
Had an issue with c615. Same as before the 004f error. It seemed to appear when it cannot properly access property. Application tested on c910 worked perfectly fine. Video interface for c910 was addressed at 0x00 and audio 0x02. In c615 is the opposite so as sam said few posts before:

changing to:

controlRequest.wIndex = (unitId << 8) | 0x2;

If it still does not work use USB prober to check video interface address.

Good luck

#107Theo Watson – Monday, January 28th 2013, 01:47

First off thanks for the amazing code you put together!!

I spent quite a bit of time trying to get this working for the new C920
To be able to control white balance / gain etc

Change ( in UVCCameraControl.h )
#define UVC_PROCESSING_UNIT_ID 0x03

in the .m
the controlRequest.wIndex should be

controlRequest.wIndex = (unitId << 8) | 0x00;

for both getDataFor and setData

#108 – Gary Katch – Friday, February 8th 2013, 21:28

Thank you so much! You've solved a problem with a Rocketfish HD720 cam that has had many users befuddled over at the Rocketfish forum for months, until I stumbled across this blog.

After the Lion update, suddenly this camera was producing extremely dark/underexposed images. Running your demo camera control app did something to reset the auto-exposure function, I am guessing. I still have no control over the camera, but it least it works well for standard web cam apps.

#109 – Michael Bauer – Tuesday, April 2nd 2013, 18:41

Hi! I have a creative labs webcam and running Mountain Lion. I tried this control out and it didn't let me change any settings but it made my webcam too bright to see now. You can only see the outline of me. Any idea how to reset the cam settings? I have tried resetting the PRAM and also disconnecting the power from the mac to clear the settings. Nothing seems to work. Tried it on a Windows PC and it seems to be permanently damaged.

#110 – Matt Sav – Sunday, April 28th 2013, 16:52

Awesome work, thanks for sharing, works wonders with my Logitech c615 (as recommended above, had to modify controlRequest.wIndex = (unitId << 8) | 0x2; in both the setData and getDataFor methods).

#111 – raydawg – Monday, November 25th 2013, 18:12

Just tested this on 10.8.5 with a Microsoft Life Cam which by default shows up as very bright, immediately fixed all issues. w00t!

#112 – briancam – Friday, December 6th 2013, 11:43

So happy to find your app! Creative Live Socialize camera was way too dark - hadn't used it since Snow Leopard and I'm now on Mavericks - just opening your app made it remember to do its auto-exposure again, and everything is bright and clear!

#113Jamie McDonnell – Friday, January 17th 2014, 13:29

Hi guys, has anyone been able to add zoom and crop to this app? It's great, and will help me position and set up for business calls.

Am very disapointed with the lack of mac support for the c920 (despite it being a great camera) and would be please to hear if anyone on this list has made it happen?

Thanks, and great work!
Jamie

#114Tim G – Wednesday, March 19th 2014, 03:03

Thanks so much for your work, and making the code available.

I am just wondering where you are getting the definitions for UVC_INPUT_TERMINAL_ID & UVC_PROCESSING_UNIT_ID from?

The UVC 1.5 Class specification shows VC_INPUT_TERMINAL as being 0x02, but your source shows 0x01, additionally, VC_PROCESSING_UNIT is shown as 0x05, while your source shows the similarly named UVC_PROCESSING_UNIT_ID definition as 0x05. Am I looking at the wrong version of the UVC spec?

#115 – dee – Wednesday, June 4th 2014, 19:07

hi

erm this sounds wonderful but for a total non-computer person.. do you have software now to control this logitech 9000 on my mac (running 10.7) - I read a lot of the above but it is beyond me and cannot see a link to a piece ofclick and play software - sorry! probly not at all what this is about

just some contrast/colour control or change angle of view ie wider etc!??(I imagine thats a hard one!) and record!?

#116Irakli N. – Friday, August 29th 2014, 03:19

I also had a lot of problems with over-exposure and this utility saved the day for me: itunes.apple.com/us/app/webcam-settings/id533696630?mt=12

#117 – Chris – Thursday, September 4th 2014, 11:42

Now, thats what I call community spirited.

#118 – John Foster – Wednesday, September 10th 2014, 18:27

This worked perfectly. I was in the middle of a video call using Lync 2011 and my camera was very over exposed. During the call, I downloaded this app, started it and the video immediately adjusted perfectly.

My camera is a Microsoft LifeCam Cinema.

Thanks!

#119 – Steve Schilz – Tuesday, October 28th 2014, 19:28

These are the tweaks for built-in iSight, from paranoid-media.de, which is not working as i write this..

Controlling iSight Autoexposure programmatically

February 4th, 2010
One of the things that make computer vision with Apple’s builtin iSight quite cumbersome, are the extremely annoying auto-exposure and auto-whitebalance features. Also, Apple does not seem to care one bit about providing any kind of documentation on how to deactivate these features (and/or control other features) of your iSight. Anyways, after a long time of googling/research I found an Objective-C class at phoboslab.org, which allows to control UVC compliant USB webcams.

With the help of this class and a few tweaks to its code I was finally able to deactivate auto-exposure and auto-whitebalance of my builtin iSight.

Here are my steps:

1. Get the UVCCameraControl class and include it in your project.

2. Instantiate this class after you started your QTCapture session with something like this:
“cameraControl = [[UVCCameraControl alloc] initWithVendorID:0×05ac productID:0×8507];”
(You might have to adjust the parameters, USB Prober is your friend)

3. In the file “UVCCameraControl.h” change the line “#define UVC_PROCESSING_UNIT_ID 0×02″ to
“#define UVC_PROCESSING_UNIT_ID 0×03″

4. In the method “- (BOOL)sendControlRequest:(IOUSBDevRequest)controlRequest” remove the calls to USBInterfaceOpen() and USBInterfaceClose().

That’s it! At least this is how it worked out for me on my MacBook Pro (latest Generation). If you still have some problems, just drop a comment.

Note: This does not seem to work, if you access your iSight via the old sequence grabber component. Be sure to use the newer Quicktime API.

#120 – Lloyd in Vancouver – Thursday, November 20th 2014, 06:50

Thanks Phoboslab for this demo app! I finally got my webcam working properly again!

I'm so relieved!

#121Nickolay – Monday, January 12th 2015, 20:37

Hey Phoboslab!

I have a project where my task is to allow the user to control web camera's brightness, exposure, and other params when the camera itself is in use with other app (like Skype or Hangouts).

Does your driver provide capabilities to control camera's parameters while the camera is in use by the other app?

Thanks!

Nick

#122 – Martin Lubell – Friday, February 20th 2015, 03:46

Hello there, thanks a lot for your camera control App. Where is your PayPal button, I'll gladly transfer $5 over.
Ciao, m a r t i n

#123 – Raviteja Kammila – Tuesday, March 3rd 2015, 13:43

How can i get USB Camera default values for all Brightness, contrast, etc...

#124 – Jerry Zhang – Wednesday, July 8th 2015, 11:59

It works on my video device after I changed something about the video control interface number. The original code assumes that the video control interface number is always 0, but in some usb composite devices, the interface number would not be. So I added below code in function (BOOL)sendControlRequest:(IOUSBDevRequest)controlRequest. It will get the correct interface number and update the control request.

(BOOL)sendControlRequest:(IOUSBDevRequest)controlRequest {

if( !interface ){
NSLog( @"CameraControl Error: No interface to send request" );
return NO;
}

//Now open the interface. This will cause the pipes associated with
//the endpoints in the interface descriptor to be instantiated
kern_return_t kr = (*interface)->USBInterfaceOpen(interface);
if (kr != kIOReturnSuccess) {
NSLog( @"CameraControl Error: Unable to open interface (%08x)\n", kr );
return NO;
}

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
UInt8 intfNum = 0;
kr = (*interface)->GetInterfaceNumber(interface, &intfNum);
if( kr != kIOReturnSuccess ) {
kr = (*interface)->USBInterfaceClose(interface);
NSLog( @"CameraControl Error: Get interface number failed :%08x", kr);
return NO;
}

//Set the correct interface number
controlRequest.wIndex |= intfNum;
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
kr = (*interface)->ControlRequest( interface, 0, &controlRequest );
if( kr != kIOReturnSuccess ) {
kr = (*interface)->USBInterfaceClose(interface);
NSLog( @"CameraControl Error: Control request failed: %08x", kr );
return NO;
}

kr = (*interface)->USBInterfaceClose(interface);

return YES;
}

#125 – Chris Rimple – Tuesday, February 2nd 2016, 22:55

I'm using a Macbook Pro with OS X El Capitan 10.11.3 and a Microsoft Lifecam Studio.

Running the PhobosLab UVC Camera Control app at system start solves the brightness (over exposure) issues that I was experiencing, and there's no need to leave the PhobosLab app running. After auto adjustment, I'm having no problems with Skype, Google Hangouts, Quicktime video recording, or CamTwist. Since I use the web cam every day, I've set the PhobosLab app to Open At Login, so I don't even have to think about it.

Thanks!

#126 – Roy – Sunday, May 8th 2016, 23:32

I know this is a quite old string but you seem to be the sort of group who might have an answer... in short, I've got a Logitech HD c920 Pro Webcam that simply refuses to work on El Cap via my MacBook Air. It definitely recognises that it's there and the mic is fine but black screen for video... any thoughts?

Thanks!

Roy

#127 – Roy – Sunday, May 8th 2016, 23:33

Whoops... please e-mail me at royvella at gmail if you had any answers. Much appreciated!

Post a Comment:

Comment: (Required)

(use <code> tags for preformatted text; URLs are recognized automatically)

Name: (Required)

Please type phoboslab into the following input field or enable Javascript. This is an anti-spam measure. Sorry for the inconvenience.