Getting the most out of your V2 camera with UV4L.
Personally I think it's an absolute quality little camera and the detail it can output is astonishing (for £25).
The main purpose of my project was to have a simple streaming webcam/camera looking out my front window, accessible whenever I want to view it.
I was previously using Motion with a webcam (c920 if you're interested), but as with all webcams they are not meant for focusing on distant objects and often give a blur on the peripheral of the outputted image due to the nature of their lenses curvatures.
Then I discovered the Pi Camera (the V2 to be more specific), although trying to use this camera with Motion proved to be an absolute nightmare. I'm not sure if the settings/commands Motion uses with the picamera are out of date but nothing seemed to be working. And don't even get me started on auto Exposure settings.
So I did a bit of research for alternatives and found ffmpeg, which seemed to be very complicated to set up, and UV4L/UV4l-raspicam, which seemed to be fairly simple, comparable with motion.
Editing the .conf file was a pretty easy and I was set up with my pi camera outputting h.264 1920x1080 video, AND, everything looked great. Auto exposure was finally working and the image was CRISP. One thing I did notice was that the image was really really cropped, almost like a 2x digital zoom. It wasn't using the full frame field of view.
After a LOT of research I've discovered that there are many "modes" that the camera can output, and quite a few of them are cropped, including 1920x1080. I think a lot of people are confused by these modes and aren't sure exactly what they do.
On the V2 camera the main important output modes are:
1. 1920x1080 16:9 30fps max- Cropped,
2. 3280x2464 4:3 8MP 15fps max - Full FOV,
3. 3280x2464 4:3 8MP 15fps max - Full FOV,
4. 1640x1232 4:3 2×2 binned 40fps max - Full FOV,
5. 1640x922 16:9 2×2 binned 40fps max - Full FOV,
6. 1280×720 16:9 40-90fps mode - Cropped,
7. 640×480 4:3 40-90fps mode - Cropped.
As you can see from the image above from the Pi Camera Documentation page 1080p mode is VERY cropped and as there's no pixel binning, so it's effectively using a 2MP section of an 8MP sensor to take photo/video..... not ideal (unless a narrow FOV is what you're after)
In UV4L-raspicam config (/etc/uv4l/uv4l-raspicam.conf) file there is an option to set resolution and the sensor output mode. Setting these options correctly is VITAL to obtaining the FOV you want. The settings I chose are mentioned below.
encoding = h264
width = 1640
height = 1232
framerate = 4
custom-sensor-config = 4
*for some reason I had to delete the "pound" (#) symbol from before the command text on each line that I changed. It was ignoring me otherwise.
This gave me full FOV and a crystal clear image. If you are thinking of streaming the video constantly then also change the bitrate down. Way down. I turned mine down to 2Mbps (bitrate = 2000000). This put a LOT less strain on the processor while making much less video data to upload constantly. Detail loss was negligible.
One last thing I did was make sure exposure = auto, ISO = 0 (zero ISO means auto) and drc = medium which reduces contrast in situations with a lot of light and dark areas, producing a more dynamic image.
Here are some screenshots taken from a browser streaming the video (not photos, video!) via interwebs, images have been halved in resolution as this forum doesnt take images larger than 1000px. Seeing as this is on-the-fly over-the-web streamed h.264 video I think it looks pretty decent.
Hope this helps some people out.