Ask Your Question
0

Can I turn off the autofocus of an autofocus-webcam?

asked 2017-07-10 09:11:26 -0600

tine-lore gravatar image

Hello all,

I'm using a Webcam (Logitech HD 720p Autofocus) with OpenCV and ROS. Is it possible to turn off the autofocus of the webcam? I already tried to change the camera parameters by setting the parameters:

rosparam set /autofocus false

rosparam set /focus 0

roslaunch [...]

But after this the camera is still autofocussing. Is there any other way?

Thanks a lot!

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2017-07-10 11:38:40 -0600

lucasw gravatar image

updated 2017-07-10 12:20:56 -0600

Can you disable the autofocus when running the camera outside of ros in a regular camera viewer? guvcview is a good test for this. Also try running v4l2ucp which can be done while the ros driver is running, it doesn't conflict (I made a ros node version of v4l2ucp https://github.com/lucasw/v4l2ucp and the parameters can be changed live via topics).

Or you run uvcdynctrl (not a ros node) separately on the command line to manipulate controls.

Are you using usb_cam?

Is the launch file setting focus or autofocus itself, overwriting your values?

It's possible the way the camera sets autofocus is not wired properly through V4L, or some startup sequence causes the param value to get overridden, so changing it after the launch is complete is the only way.

edit flag offensive delete link more
0

answered 2017-07-10 15:16:51 -0600

tine-lore gravatar image

Thanks for your answer! I'm using usb_cam.

I'm running Ubuntu on VMware and guvcview is running very unstable. But when turning off the autofocus, the webcam is not autofocussing anymore. When running the v4l2ucp Node (I guess "rosrun v4lucp v4lucp" is correct) I get errors for Exposure, Auto. And a similar result with uvcdynctrl. Why does this error occur? Is it possible to change the parameters dynamically with this node?

But, you are right, the launch file is overwriting the values I set with rosparam in advance. When I turn the autofocus off in the launch file, the camera is not autofocussing anymore. So this problem is solved here.

Thank you so much! Great answer!

edit flag offensive delete link more

Comments

I haven't tried running it in vmware. I frequently get errors when v4l2ucp starts up but they either don't seem to prevent anything from working or I sometimes have to restart the node- I'll look into that eventually.

lucasw gravatar imagelucasw ( 2017-07-11 07:59:54 -0600 )edit

You should be able to change the controls dynamically through topics, but the ros parameters are only loaded once when the node starts.

lucasw gravatar imagelucasw ( 2017-07-11 08:00:58 -0600 )edit

Thanks! The only Problem I have occurs when the camera node breaks down (like "process has died"). After relaunching the camera the focus point is wrong even though I set it in the launch file. Do you have any explanation for this?

tine-lore gravatar imagetine-lore ( 2017-07-11 15:45:46 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-07-10 09:11:26 -0600

Seen: 1,018 times

Last updated: Jul 10 '17