Raspberry Pi - Disable webcam autofocus: Difference between revisions

From munkjensen.net/wiki
(Created page with "See this guide https://community.octoprint.org/t/anyway-to-disable-the-autofocus-for-cameras/801/23 '''I made a copy of it here:''' # Install putty if you are in windows. Th...")
 
No edit summary
Line 10: Line 10:
# open a window with your octoprint camera and fine tune the focus..
# open a window with your octoprint camera and fine tune the focus..
# so enter sudo ''v4l2-ctl --set-ctrl=focus_absolute=70'' and change the number until the focus is ok
# so enter sudo ''v4l2-ctl --set-ctrl=focus_absolute=70'' and change the number until the focus is ok
# now, you have your two commands that fine tune your camera. In order to run them every time raspberry open, you have to add them to rc.local file:
# Now you have your two commands that fine tune your camera. In order to run them every time raspberry open, you have to add them to rc.local file. You can do that using the "vi" text editor like this:
 
# Enter ''sudo vi /etc/rc.local''
a) enter ''sudo vi /etc/rc.local'', then go to line last line "exit 0"
# then go to line last line "exit 0"
 
# Press shift+O and write your two commands (you can copy and paste with left click)..
b) press shift+O and write your two commands (you can copy and paste with left click)..


- If you mess up something press ''esc'' and '':q!'' to quit
- If you mess up something press ''esc'' and '':q!'' to quit

Revision as of 10:13, 9 June 2020

See this guide https://community.octoprint.org/t/anyway-to-disable-the-autofocus-for-cameras/801/23

I made a copy of it here:

  1. Install putty if you are in windows. This will let you enter the files inside raspberry pi.
  2. At tab session and Host Name field add octopi.local or your raspberry ip (you can find this in your router's page 192.168.1.1..and it will be something like 192.168.1.X), choose SSH, port 22, Open
  3. username is default "pi", and password "raspberry"
  4. you have to go to folder mjpg-streamer, so you enter the command cd mjpg-streamer/
  5. now enter sudo v4l2-ctl --set-ctrl=focus_auto=0 to disable auto focus
  6. open a window with your octoprint camera and fine tune the focus..
  7. so enter sudo v4l2-ctl --set-ctrl=focus_absolute=70 and change the number until the focus is ok
  8. Now you have your two commands that fine tune your camera. In order to run them every time raspberry open, you have to add them to rc.local file. You can do that using the "vi" text editor like this:
  9. Enter sudo vi /etc/rc.local
  10. then go to line last line "exit 0"
  11. Press shift+O and write your two commands (you can copy and paste with left click)..

- If you mess up something press esc and :q! to quit

- If you are fine press esc and :wq to save


some extra info:

if you set focus_auto to 1 and let the webcam focus an object in the center you can take the "perfect" focus value... and then focus_auto to 0... but which is this value?

Run the command sudo v4l2-ctl -l and you can find a line something like this :

"focus_absolute (int) : min=0 max=250 step=5 default=8189 value=50"

In this case the "perfect" value is 50 - you can play with the other listed settings too..(like contrast with sudo v4l2-ctl --set-ctrl=contrast=200)

if you want to check that your changes are permanent, do a restart and see the current values with sudo v4l2-ctl -l