ayufan / camera-streamer

High-performance low-latency camera streamer for Raspberry PI's

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Full Frame capture with PiCam2

msroest opened this issue · comments

I'm attempting to move my octoprint to the new version using camera-streamer and I've come across a very strange issue. When trying to get full frame capture from my PiCam2. I've setup the my libcamera.conf as follows based on this issue #3

### Options for libcamera based cameras (PiCam, Arducam, ...)

# The port on which the webcam server for the camera should listen on. If you have only
# one camera, leave at 8080. If you have more, change to 8081, 8082, etc. The primary
# camera will be considered the one with 8080.
PORT=8080

# The resolution to request on the camera sensor. Defaults to 1280x720.
WIDTH=3280
HEIGHT=2464

# The height to use for the video stream. Defaults to 720.
VIDEO_HEIGHT=720

# The height to use for the snapshots. Defaults to 1080.
SNAPSHOT_HEIGHT=1080

# The framerate to set on the camera. Defaults to 15fps.
FRAMERATE=15

# Additional options. By default enables continuous auto focus (if possible).
#OPTIONS='--camera-options="AfMode=2" --camera-options="AfRange=2"'
OPTIONS='-camera-nbufs=2 --camera-high_res_factor=2 --camera-low_res_factor=4'

In this mode the camera-streamer returns a half a frame with the rest being green
Screenshot 2023-08-08 at 15 07 10

If I update the config to use 1920x1080 capture the streamer works fine but the view is garbage cause of the crop.

If I stop camera-streamer and use libcamera-jpeg -o image.jpg --nopreview it correctly pulls the whole frame:
rotatednopreview

I just updated from 0.2.5 to 0.2.6 and still have the same behaviour.

Firstly, many thanks to ayufan and anyone/everyone else who put time and effort into this streamer.

@msroest - My picam is in a screwed-shut case but identifies as IMX219 (= picam v2?).
I had a streamer problem that looks the same as yours i.e. ~ half green.
I don't use shapshots but SNAPSHOT_HEIGHT seems to matter, see below.
1232 and 2464 both seemed to work but 2464 required less CPU in my case.
There may be better solutions out there but this one worked for me. YMMV

My libcamera.conf for use with OctoPrint looks like this ...

### Options for libcamera based cameras (PiCam, Arducam, ...)

# The port on which the webcam server for the camera should listen on. If you have only
# one camera, leave at 8080. If you have more, change to 8081, 8082, etc. The primary
# camera will be considered the one with 8080.
PORT=8080

# The resolution to request on the camera sensor. Defaults to 1280x720.
# For (IMX219 + Pi3Bv1.2) & Octoprint v1.9.2 with new camera stack ...
#   1920x1080 works but crops field-of-view as described by ayufan
#   3280x2464 works if SNAPSHOT_HEIGHT is set as below.
WIDTH=3280
HEIGHT=2464

# The height to use for the video stream. Defaults to 720.
# Likely to be re-re-scaled by browser. 720 is a sensible 'standard'. Exact 2:1 or 4:1 not necessary.
VIDEO_HEIGHT=720

# The height to use for the snapshots. Defaults to 1080.
# With Octoprint connected, SNAPSHOT_HEIGHT = 1232 => 13-15% CPU, 2464 => 11-12% CPU
#SNAPSHOT_HEIGHT=1232
SNAPSHOT_HEIGHT=2464

# The framerate to set on the camera. Defaults to 15fps.
FRAMERATE=15

# Additional options. By default enables continuous auto focus (if possible).
# My camera is mounted upside down, so rotate by 180.
OPTIONS='--camera-hflip=1 --camera-vflip=1'

I hope this helps. Enjoy.

@paddymck you are my saviour. This fixed my issue, my full frame streaming now works

Where does the libcamera.conf file go?

My libcamera.conf is in '/boot/camera-streamer/ ' and seems to work OK there with v0.2.5.
If that location does not work for you, please say.
Enjoy.
🙂

Thanks. I wasn't using the Octopi distribution and wanted to see how the information got from /boot/camera-streamer/... into the camera-streamer systemd services.

Turns out the distribution installs camera-streamer, writes its own services, and then moves the config files to /boot and symlinks them:

https://community.octoprint.org/t/camera-streamer-configuration-on-the-new-camera-stack-for-octopi/49950/45?u=drf5n

If you aren't using the OctoPi distribution image, those systemd files are missing, and the ones you get from here (https://github.com/ayufan/camera-streamer/blob/main/service/camera-streamer-raspi-v2-8MP.service in this case) doesn't know to parse the /boot/camera_streamer/libcamera.conf environment variable file into the appropriate camara-streamer CLI options.

See https://github.com/OctoPrint/camera-streamer-stack/blob/main/systemd/camera-streamer-libcamera.service for the systemd service file that parses /boot/camera-streamer/libcamera.conf