Tuesday, January 22, 2013

LifeCam HD-6000 autofocus fix, Raspberry Pi

LifeCam HD-6000 autofocus fix

The Microsoft Lifecam HD-6000 autofocus is notoriously annoying. It refocuses unnecessarily sometimes every few seconds making the camera nearly unusable. Here's the workaround on Raspbian (Debian) for the Raspberry Pi.

The best workaround is to disable autofocus. You'd think this would just make the camera blurry all the time, but it doesn't. The camera's depth of field keeps the image in focus over a wide range of distances without autofocus. I've tested ranges from 18" to infinity and everything is sharp and clear.

Since this camera is UVC-compliant (USB Video Class), on Raspbian disabling autofocus is done with a command that interacts with the UVC driver, uvcdynctrl.

My version of Wheezy didn't have this tool installed so I issued:

sudo apt-get install uvcdynctrl

With the software installed, I listed the configurable items on the camera:


$ uvcdynctrl -c
Listing available controls for device video0:
  Brightness
  Contrast
  Saturation
  White Balance Temperature, Auto
  Power Line Frequency
  White Balance Temperature
  Sharpness
  Backlight Compensation
  Exposure, Auto
  Exposure (Absolute)
  Pan (Absolute)
  Tilt (Absolute)
  Focus (absolute)
  Focus, Auto
  Zoom, Absolute


Then, I disabled autofocus.

$ uvcdynctrl --set='Focus, Auto' 0

And that's it, no more annoying autofocus. I'll be able to use this tiny, attractive little webcam for my RPi Telepresence robot.

7 comments:

  1. Is this really a fix when all you are doing is disabling autofocus? Have Jim, I have a problem with my car, the brake lights flicker on and off. No problem Bob, just disconnect them.

    ReplyDelete
    Replies
    1. After disabling autofocus, the image is clear and focused for a wide range of distances. So, it becomes usable versus going blurry every ten seconds making it unusable. I don't care if we call it a fix, hack or a rutabaga. :) The point is that when you disable autofocus the camera works nicely.

      Delete
  2. Does this camera work powered by the Pi only, or do you need USB hub?

    ReplyDelete
    Replies
    1. No powered hub needed, the Pi can power it fine (I have the original Pi with the fuses and limited current)

      This website lists various hardware and their compatibility and whether they need a powered hub or not.

      http://elinux.org/RPi_VerifiedPeripherals

      Delete
  3. i also had to turn on focus absolute to 1. turning focus auto to 0 didn't fix the focus.

    ReplyDelete
  4. I have to use FOCUS AUTO OFF with a Microsoft LifeCam HD-6000 ...Good job! Thanks.

    ReplyDelete
  5. Accessing and changing camera parameters (if your camera supports this), from the command line in Linux.

    Note- I have written this for disabling the autofocus and setting a desired focus value for Microsoft Lifecam HD-6000 webcam, in Ubuntu 12.10

    Step1:

    First list all the devices, in order to find your device.
    command:

    uvcdynctrl -l

    Result you would see:

    Listing available devices:
    video2 Microsoft® LifeCam HD-6000 for
    video1 Laptop_Integrated_Webcam_2HDM
    video0 Microsoft® LifeCam HD-6000 for

    I have connected 2 HD-6000 cams and hence I see 2 devices. In order to access/change a device's settings, you must use the following command:

    uvcdynctrl -d deviceName(in this case- video0 or video1 or video2)

    Step2:

    List all the controls available for the particular device

    Command is as follows:

    uvcdynctrl -d video0 -c

    Result you would see is as follows: (Don't worry more than what is below comes as result.. just hunt for the below mentioned part of the output)

    Listing available controls for device video0:
    Brightness
    Contrast
    Saturation
    White Balance Temperature, Auto
    Power Line Frequency
    White Balance Temperature
    Sharpness
    Backlight Compensation
    Exposure (Absolute)
    Pan (Absolute)
    Tilt (Absolute)
    Focus (absolute)
    Focus, Auto
    Zoom, Absolute

    Step3:

    Next, you can get the current value of a control by typing the following command:

    uvcdynctrl -d video0 --get='Focus, Auto'

    you will find the value at the end of the output as 1, as the auto focus will have been enabled by default.

    Step4:

    Now you need to first set the auto focus to 0 and then only, can you set the manual (absolute) focus to whatever value you desire.

    command:

    uvcdynctrl -d video0 --set='Focus, Auto' 0

    Take care about the spacing in the command..

    To cross verify whether the autofocus has been disabled, type the command in step3. Now you should get 0 as the value in your output

    Step5:
    Now that you have disabled autofocus, let us set a value- say 10 for the manual focus.

    command:

    uvcdynctrl -d video0 --set='Focus (absolute)' 10

    To cross verify the same, type:

    uvcdynctrl -d video --get='Focus (absolute)'

    In the end of the output, you should see 10 as the control value for manual (absolute) focus..

    Hope this helps :)

    Cheers!
    Sup..

    ReplyDelete