towolf wrote:This is getting a bit confusing.
The really simple summary: unless you exceed 1280x960 you will now get full field of view. That's all most people will care about.
The more complete explanation:
You as the user don't get to explicitly set which sensor mode is used.
The sensor lists the set of modes that it can support, with width, height, a min and max framerate, and a flags field for "video mode" or "stills capture mode" . That list for the OV5647 on RPi now consists of:
- - 2592x1944, 1-15fps, video or stills mode
- 1296x972, 1-42fps, video mode
- 1296x730, 1-49fps, video mode
- 640x480, 42.1-60fps, video mode
- 640x480, 60.1-90fps, video mode
- 1920x1080, 1-30fps, video mode
You as the user, via V4L2 or Raspi[still|vid], then give it a request of a resolution and frame rate. It then uses a algorithm that scores each mode against the request with the aim of fulfilling the request with the best image quality we can manage. The criteria considered are:
- - the flags field MUST match. (If we can't find a match, then default to the first mode specified and sulk a little)
- the closer the width/height to the sensor mode the better, but score heavily against upscaling.
- the frame requested should be within range - score against heavily the mode if out of range
- find the closest match for the aspect ratio requested to the sensor mode
So if you ask for
- 1) 4:3 video frames (note1) anything <= 1296x976 and <=42fps it will select the 1296x976 mode and scale in the ISP appropriately.
2) 16:9 video frames anything <= 1296x730 and <= 49fps, it will select the 1296x730 mode and scale in the ISP appropriately.
3) Exceed the resolution restriction of mode 2 and <=30fps and you will use the 1920x1080 mode, and that happens to have a reduced FOV.
4) Exceed the framerate restrictions on modes 1, 2 or 3 and you will get the VGA 42-60fps mode.
5) Exceed 60 fps and you will get the VGA 60-90fps mode.
6) Any stills request(note2) will use the 2592x1944 mode.
Aspect ratios other than 4:3 and 16:9 will choose the most appropriate mode to maximise field of view.
Whilst it seems a little bizarre, it has stood us in good stead on all projects so far.
towolf wrote:Also, any chance of having a mode that crops 2x2 1296x976 to 1280x720 directly? That is, a variant of the 16:9 1296x730?
Bluntly, no. The main thing that everyone was complaining about was the difference in FOV between preview and capture. Cropping on the sensor to 1280x720 would again give us a different FOV. Once I get cropping/zooming sorted, then you should be able to do effectively the same thing through the ISP. It is still a feature on the list, but time is very limited at the moment.
It doesn't help that, whilst Omnivision are helpful, getting these modes working with correct exposure and framerate control is still a right pain. Half the issue getting these modes working transpired to be an interaction between mirroring and binning on the sensor - if it was wrong the sensor simply didn't produce any frames. Not the easiest to debug.
(note1) for V4L2 "video frames" now means YUV or RGB modes at <= 921600 (equivalent to 1280x720) pixels total, or any H264 or MJPEG mode.
(note2) for V4L2 "stills frames" means YUV or RGB with > 921600 pixels, or any JPEG mode.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.