Pi Camera V3/IMX Chipset Based Cameras Not Working

I can follow instructions well enough but installing a nightly build is concerning given the risk for other potential issues introduced. A plugin model is easy enough to enable/disable, but have some worry using anything other than the main stream image. I appreciate you doing this at all! I just don't want to risk having any downtime.

Well, the 1.0.0rc3 version seems stable enough, which is not nightly.

I will also note that regardless of what you do you'll need newer software than the 0.18 OctoPi image. Even if there is a plugin that sets up the streaming (mine is just an experiment) then it still needs the 1.0.0 image to start with.

I feel better about it being in a RC vs a nightly. Reading through the thread it wasn't 100% clear to me. Glad it is now.

I went through with and flashed the RC to an extra drive, added the scripts and I get

 $ libcamera-still --list-cameras
Available cameras
-----------------
0 : imx708_wide [4608x2592] (/base/soc/i2c0mux/i2c@1/imx708@1a)
    Modes: 'SRGGB10_CSI2P' : 1536x864 [30.00 fps - (0, 0)/0x0 crop]
                             2304x1296 [30.00 fps - (0, 0)/0x0 crop]
                             4608x2592 [30.00 fps - (0, 0)/0x0 crop]

back when querying libcamera, but in Octoprint I can't seem to get a preview image, is there another thing I need to config that I am missing other than the shell script and restarts?

I have a raspberry pi zero 2 w and I wasn't able to install the streamer on any 64bit os. The process always stop at Β±83% of Building CXX object.

It work when I increase swap file size.
Here the commands I use just after a fresh install :

stop the dphys swap

$ sudo /etc/init.d/dphys-swapfile stop

remove the old dphys version

$ sudo apt-get remove --purge dphys-swapfile

remove the old swap file

$ sudo rm /var/swap

make a new swap file (4 GB in this case)

$ sudo fallocate -l 4G /var/swapfile

change permission to root

$ sudo chmod 600 /var/swapfile

make Linux swap area

$ sudo mkswap /var/swapfile

start the swap service

$ sudo swapon /var/swapfile

make the service permantent

$ sudo nano /etc/fstab

add the following line

/var/swapfile swap swap defaults 0 0

while we're in fstab, reduce the shared memory to 100 MB

tmpfs /dev/shm tmpfs defaults,size=100M 0 0

close with +, ,

$ sudo reboot

you can test the swap with

$ swapon -s

I get these commands line from this website : Install 64 OS on Raspberry Pi zero 2 - Q-engineering

I've managed to get 1080p video and snapshots working. Still haven't had a chance to investigate the octolapse delay issues though. Here is a new version of the ExecStart command for the .service file that activates continuous auto focus and the higher resolution. (I still haven't got to updating the cam3install script, but I plan to later this weekend.

ExecStart=/usr/local/bin/camera-streamer \
  -camera-path=/base/soc/i2c0mux/i2c@1/imx708@1a \
  -camera-type=libcamera \
  ; YUYV offers best quality in camera-streamer
  -camera-format=YUYV \
  -camera-width=1920 -camera-height=1080 \
  ; 4608 (H) Γ— 2592 is full res - don't know how to enable it 
  ; frame rate 30 for North America.  25 may work better in 50Hz countries
  -camera-fps=30 \
  ; use two memory buffers to optimise usage
  -camera-nbufs=2 \
  ; high-res video is 1920x1080
  ; high-res snapshot is 1920x1056
  -camera-high_res_factor=1 \
  ; the low-res is 960x512
  -camera-low_res_factor=2 \
  ; Enable Continuous Autofocus
  -camera-options=AfMode=2 \
  -camera-options=AfRange=2 \

I also removed the -rtsp-port option as I don't use the rtsp stream.

@drkpxl, If you used my script and the process from Pi Camera V3/IMX Chipset Based Cameras Not Working - #34 by lgeitner, it should "just work" on reboot. Things I've posted since then need to be manually updated, but I don't recommend it until you have the basics working.

In Octoprint's Webcam settings, these have been working for me:

Stream URL:  /webcam/?action=stream
Snapshot URL: http://127.0.0.1:8080/?action=snapshot

I don't know why one has the streamer url and one has the webcam path. That seems odd, but I just copied it from my active installation. I think the stream url should be http://127.0.0.1:8080/?action=stream

If you want to check the stream without Octoprint, you can access it directly with http://octopi:8080/

[ Updated to strike out my mistaken comment about the streamer URL. - Thanks @jneillii ]

1 Like

definitely not. the stream url /webcam/?action=stream is through haproxy as relative path and gets redirected to http://127.0.0.1:8080/?action=stream on the server side. If you were to change your stream URL to that full path using 127.0.0.1 it will not work because that's a reference to the local machine and would try to load the webcam from the device connecting to the web interface. It works for snapshot because the server downloads the image from itself and is what is used for timelapse.

Right, and I should've known that. I was thinking that it was octoprint accessing the stream rather than the client directly.
I didn't know about the webcam redirect URL however. Thanks for that info.

1 Like

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

2 Likes

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.

2 Likes

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.zip

Flash 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 \
5 Likes

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.

  1. rm -rf /home/pi/camera-streamer and then follow the standard instructions.
    or
  2. 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.
2 Likes