I have a Pi 3 running motioneye with a camera module 3. (The motioneye package is installed over the latest Pi OS -- I'm not using the motioneyeOS image.) I'm using this to stream video of my front door.
Everything works, except that in my excitement to get the camera installed in the right spot, and pointed in the right direction, I may have dislodged the camera's little black plastic lens thing, which now wobbles a little if I touch it. (It didn't wobble when I first got it).
The consequence of this is that the focus isn't as sharp. With the camera in my hand, I can manually move the lens slightly, and I see the image (or video) become more or less sharp. However, this doesn't seem to last.
And with the camera installed up over my door, it's too awkward to try and move the lens manually while also looking at the video.
So, the question is, is there a way to adjust the focus from the command line, or through motioneye?
Thanks so much.
Adjust focus with raspberry pi camera module 3
Moderators: adafruit_support_bill, adafruit
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
- sromanos
- Posts: 10
- Joined: Sun Dec 18, 2022 3:54 pm
- adafruit_support_mike
- Posts: 67485
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Adjust focus with raspberry pi camera module 3
I'm afraid not. The only way to adjust the camera's focus is to twist the physical lens.
It sounds like the plastic lens that holds the barrel may be cracked if it holds generally but still moves easily. Try removing it and seeing if you can see the crack and repair it with cyanoacrylate glue.
It sounds like the plastic lens that holds the barrel may be cracked if it holds generally but still moves easily. Try removing it and seeing if you can see the crack and repair it with cyanoacrylate glue.
- sromanos
- Posts: 10
- Joined: Sun Dec 18, 2022 3:54 pm
Re: Adjust focus with raspberry pi camera module 3
Well, I may have partially solved things. The focus mechanism isn't totally broken, but the black lens thing is still a little jiggly. However, if run "libcamera-vid -t 20000 --autofocus-mode continuous" (or auto) I can get it to focus from a few inches to several feet (I didn't quite try longer distances. The trouble seems to be that motioneye doesn't engage the autofocus (or at least doesn't engage it enough) to get a crystal clear picture at about 8 feet away.
However, what I can do is:
- stop motioneye
- run libcamera-vid --autofocus-mode continuous, which does its best to get a clear picture
- then start motioneye again
And so this seems to invoke motioneye using the focus position last used by libcamera. Again, it's not perfect, but better than before.
Also, in case this helps anyone, getting motioneye working on a current and fresh install of Pi OS, with python 3, and a camera module 3, was not fun. The worst of it was getting motioneye to recognize the camera. After many hours searching for help, I came across a post (https://github.com/motioneye-project/mo ... ssues/2683) with the simple answer:
Add camerify to /etc/systemd/system/motioneye.service. i.e.:
...
ExecStart=/usr/bin/libcamerify /usr/local/bin/meyectl startserver -c /etc/motioneye/motioneye.conf
...
Boom. Works now.
However, what I can do is:
- stop motioneye
- run libcamera-vid --autofocus-mode continuous, which does its best to get a clear picture
- then start motioneye again
And so this seems to invoke motioneye using the focus position last used by libcamera. Again, it's not perfect, but better than before.
Also, in case this helps anyone, getting motioneye working on a current and fresh install of Pi OS, with python 3, and a camera module 3, was not fun. The worst of it was getting motioneye to recognize the camera. After many hours searching for help, I came across a post (https://github.com/motioneye-project/mo ... ssues/2683) with the simple answer:
Add camerify to /etc/systemd/system/motioneye.service. i.e.:
...
ExecStart=/usr/bin/libcamerify /usr/local/bin/meyectl startserver -c /etc/motioneye/motioneye.conf
...
Boom. Works now.
- adafruit_support_mike
- Posts: 67485
- Joined: Thu Feb 11, 2010 2:51 pm
Re: Adjust focus with raspberry pi camera module 3
Good info.. thanks for posting the follow-up!
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/