Hi Itlowe, newbie question, how to execute your last ExecStart command for 1080P and autofocus?
TY
After running the initial script, you need to edit the file
/home/pi/camera-streamer/service/camera-streamer-pi708-12MP.service
and replace the existing ExecStart section with the one from Pi Camera V3/IMX Chipset Based Cameras Not Working - #63 by ltlowe
I've run the script and got the camera to show, but it is extremely laggy and glitchy in octoprint. Anything I can do to fix this?
If you're using my updated higher res version, you could try setting the Stream URL to /webcam/?action=stream?res=low /webcam/?action=stream&res=low
but that would only affect the live stream.
camera-streamer provides an HLS and webrtc endpoint as well don't they? if so, the performance may be better with those, just have to test it out/experiment. I think I might have been thinking of go2rtc project instead.
I've updated the script to include all above tweaks (resolution and autofocus) and added prompt for reboot at the end. I have also moved the location, but am leaving the original in place for a while as well (I plan to update it to just wget the new location or echo a moved notice.) a copy in the original location with a moved notice and offer to download from the new location when executed.
Like the previous version, I initially tested with a 64bit nightly, but am now running the 32bit RC3 build and tested using @gambiting's instructions updated with the new cam3install url.
This method is confirmed to work on 3A+, 3B and 4 models.
Attempts to use this method on a Zero 2W have not been successful.
Download the Octoprint RC3 release image here:
https://unofficialpi.org/Distros/OctoPi/nightly/2022-10-27_2022-09-22-octopi-bullseye-armhf-lite-1.0.0.zipFlash it to a microsd card, boot up the raspberry pi as usual, don't do anything else on it yet.
Log in, either locally or via SSH, doesn't matter.
Then run the following:wget https://raw.githubusercontent.com/ltlowe/misc/main/picam3/cam3install.sh chmod +x cam3install.sh ./cam3install.sh
restart your system.
After the reboot the camera should be working with default Webcam & Timelapse
settings, although you may want to change the aspect ratio to 16:9 since the camera module 3 is a wide aspect ratio camera.
Resolution
I tried various settings for setting the camera resolution. The script sets them to the highest I was able to validate, although not the highest supported by the camera. This script sets the stream and snapshot resolutions to
- Stream (default): 1920x1080
- Snapshot (default): 1920x1056
- Stream (low): 960x512
- Snapshot (low): 960x512
Stream Lag
By default, Octoprint uses the high resolution stream and snapshot. If live view on the control tab is slow or lagging, try setting the Stream URL to /webcam/?action=stream&res=low
on the Webcam and Timelapse
page. The lowres stream is 960x512
and is the one I personally use.
Autofocus
This script automatically enables autofocus for the full range. If you prefer manual focus via the Camera Settings
plugin or other method, you can modify the camera-streamer service file.
Edit /home/pi/camera-streamer/service/camera-streamer-pi708-12MP.service
and remove the following lines, followed by another reboot (or restart the service.)
; Enable Continuous Autofocus
-camera-options=AfMode=2 \
-camera-options=AfRange=2 \
Man, You are amazing, Thank you, it is simple and working well
Do I have to start over from scratch (i.e. download and install a fresh OctoPi image) or can I just rerun the script to get the latest settings?
Also, you say change the aspect ratio to 16:9. Can you provide an example of how (and where) to do that?
You need to have a Bullseye-based OS - if you already have OctoPi 1.0.0, or a manual install there it should be fine.
16:9 ratio is an option in Settings > Webcam and Timelapse.
@b-morgan If you have previously run the script and want to update, there are two options.
-
rm -rf /home/pi/camera-streamer
and then follow the standard instructions.
or - replace
/home/pi/camera-streamer/service/camera-streamer-pi708-12MP.service
with https://raw.githubusercontent.com/ltlowe/misc/main/picam3/camera-streamer-pi708-12MP.service and reboot.
Hi Itlowe, I just try the first command and it unfortunatly not update the camera-streamer-pi708-12MP.service file correclty.
Hi then try the second option and it work perfeclty. Here the command line for those who don't know how to do it (like me 2 days ago ) :
sudo nano /home/pi/camera-streamer/service/camera-streamer-pi708-12MP.service
erase all content in the file that open and past (right click to paste in putty) all content written in this link:
https://raw.githubusercontent.com/ltlowe/misc/main/picam3/camera-streamer-pi708-12MP.service
Save the file by exiting with ctrl+x, answer y, confirm with enter
sudo reboot
Newbie here I got all the way until I need to run this
wget https://raw.githubusercontent.com/ltlowe/misc/main/picam3/cam3install.sh
chmod +x cam3install.sh
./cam3install.sh
How do I do this can I get a step by step?
Right now my stream just says Webcam loading with out ever connecting.
Start an SSH session with your OctoPi system (username: Pi and your password).
There are three lines above starting with "wget", "chmod", and "./". You can type each line into your SSH session and hit return or copy them with ctrl-C on a Windows machine and right-click in the SSH session window and hit return.
The first line fetches the script, the second line makes the script executable, and the third line executes the script. This third line will generate lots of output and will take a while to finish.
At the end of the script it should ask you to reboot.
Sorry about that, you are correct. I had a typo, thanks for catching it.
I've updated the previous post and added a note to post 72
Thank you! I removed my existing camera-streamer folder and installed using the new script. Quality is improved and autofocus is working!
Do you have any info or references for the AfMode and AfRange options?
I have my camera mounted to the Z axis and sometimes the print head moving back and forth causes the camera to be stuck overshooting its autofocus back and forth for a long time. Wondering if either of those two options could help solve this
According to the pi camera software manual, the options are
Auto Focus Modes:
- default (usually auto, but most people are not getting auto by default)
- manual
- auto (at start up only plus capture time for some software)
- continuous
Auto Focus Ranges:
- normal
- macro (close up only)
- full (close up and normal ranges)
The local url http://octopi.local:8080/option shows available camera-streamer options and value ranges. It only lists 0-2 as valid for AfMode
, so I chose 2 being the largest supported value. It worked and enabled continuous focus even though that doesn't seem to align with the manual.
For AfRange
there are 3 options and the values are 0-2, so I chose 2 for full range, guessing that they were listed in order, and it worked as well.
There are several other options in the manual that could map to keys shown on the camera-streamer option page, but I have not experimented with any of the other ones. If you want to, you should be able to add them to the .service file the same as AfMode and AfRange. Restarting the service or rebooting is needed to activate changes.
Much appreciated, I'll do some experimenting and post my results if I make any progress
Thanks a lot!!
It works just as you descibed :- )
EDIT
So I figured out the problem the case that I had printed out didn't have a large enough hole at the front so something was pushing on the elements and not allowing correct AF.
Leaving the Original post in case it can help someone else:
EDIT
Is anyone having issues with the focus area not being the center of the frame?
My pi cam 3 seems to be focusing on the RHS of the image
ie
RHS: Dropbox - Screenshot 2023-02-13 at 09.04.31.png - Simplify your life
Center: Dropbox - Screenshot 2023-02-13 at 09.04.42.png - Simplify your life
On in the manual there is
--autofocus-window Specify the autofocus window
I've tried adding it to the service with different values including up to -camera-options=AfWindow=0,0,1,1 \
which according to the documentation seems like it should cause the entire frame to be used for focus (and it is super slow to focus when I do that) It still seems to have the same only RHS of the image come into focus.
I've tried setting the lens position manually from the /option path as well and that seems to have the same issue I can never get the center of the frame in focus.
I know in the V2 camera using 1920x1080 it's only using part of the sensor (I had my v2 resolution set to 1640x1232 to get a full FOV window in the image. I'm wondering if that is causing the strange AF area.
Is anyone else seeing this? Maybe I got a bum camera module?
@msroest Glad you solved it.
It's also nice to know that the autofocus window control seems to work, and now we know not to use the whole frame