OV5640 FREX mode

Discussion related to "under the hood" OpenMV topics.
User avatar
CameraMan
Posts: 21
Joined: Thu Apr 09, 2020 3:41 pm

OV5640 FREX mode

Postby CameraMan » Thu Apr 09, 2020 4:43 pm

Hello All,

Im eagerly awaiting my OpenMV Cam H7 +. One exciting feature I am looking forward to exploring FREX mode. I see it has been mentioned several times in the forum but not explored in great detail.

A little background about FREX mode also called Global Reset Mode:

The OV5640 is a rolling shutter. Rolling shutter are not well suited for capturing objects that are moving. For example try taking a photo of a fan while it is turned on. The resulting image will be distorted. This is do to the way the shutter is exposed.

The OV5640 is a unique camera sensor as it support FREX mode. This is a feature not really found in affordable camera sensors. Here is a description from the docs:
Compared with normal(rolling) exposure mode, frame exposure allows all rows integrated simultaneously rather than row by row. It is mainly used in image capture and can work accompany with flash strobe function to increase image brightness under dark situation.
Generally, the function works as follows:
(1) Initially, the sensor is in normal exposure mode. The electrical shutter is open.
(2) User sends a frex request.
(3) Photo-diode of all pixels in all rows start precharge and the precharge will last for a given time.
(4) Until a given precharge time, the precharge phase stops and all pixels start integration.
(5) During integration, flash strobe may turn on to increase exposure.
(6) Until a given exposure time, the electrical shutter closes to stop further integration, and whole image is then start to readout.
(7) After the readout is finished, the electrical shutter opens again and the sensor resume to normal mode.

How is FREX a benefit?

Essentially the camera can mimic a global shutter sensor. In global reset mode, all of the pixels on the sensor begin collecting charge simultaneously, rather than row by row. The end of integration, however, is still delayed on the sensor row by row from top to bottom as readout takes place. One result of this behavior is a partial reduction in motion blur and other effects typical of rolling shutters.


Technial Questions:

Will the OpenMV Cam H7 + have direct access to the Frex and Strobe pins?
If the pins are not exposed will we be able to write registers to the sensor to activate FREX and Strobe?
Attachments
FSM12MGE_glovalreset.png
Rolling-Shutter.gif
Rolling-Shutter.gif (10.33 KiB) Viewed 1222 times
rolling-global2-20171121154055.jpg
-Chief Tinkering Officer
User avatar
kwagyeman
Posts: 4111
Joined: Sun May 24, 2015 2:10 pm

Re: OV5640 FREX mode

Postby kwagyeman » Thu Apr 09, 2020 4:46 pm

Hi, yes, this pin is hooked up on the OpenMV Cam H7.

Note the schematic is here: https://github.com/openmv/openmv-boards ... OV5640.pdf
Nyamekye,
User avatar
kwagyeman
Posts: 4111
Joined: Sun May 24, 2015 2:10 pm

Re: OV5640 FREX mode

Postby kwagyeman » Thu Apr 09, 2020 4:50 pm

STORE is not hooked up. I read the data sheet on that pin and it's useful for flash control. Anyway, the FSIN pin is on one of the OpenMV Cam H7 Plus headers. You can wire it to any I/O pin to control it. It's on an external I/O pin so multiple units can be connected to each other.
Nyamekye,
User avatar
kwagyeman
Posts: 4111
Joined: Sun May 24, 2015 2:10 pm

Re: OV5640 FREX mode

Postby kwagyeman » Thu Apr 09, 2020 4:52 pm

Yes, you have direct register access with sensor.__read_reg() and sensor.__write_reg(). You can directly copy register addresses from the data sheet to peek and poke at things. I will include a sensor.ioctl() however to make this feature operational for you also.
Nyamekye,
User avatar
CameraMan
Posts: 21
Joined: Thu Apr 09, 2020 3:41 pm

Re: OV5640 FREX mode

Postby CameraMan » Thu Apr 09, 2020 5:08 pm

Awesome! Looking forward to it. I'll document all of my findings here.
-Chief Tinkering Officer
User avatar
CameraMan
Posts: 21
Joined: Thu Apr 09, 2020 3:41 pm

Re: OV5640 FREX mode

Postby CameraMan » Mon Apr 13, 2020 1:02 pm

Here is some interesting stuff about Frex and the OV5640 camera, from the raspberry pi forum:


https://github.com/Hermann-SW/Raspberry ... l_shutter

The main issues I have with his execution is requiring that raspivid_ges has to be run then the frex commands issued during the stream. So the stream is constantly writing to disk taking up space then you have to manually use something like ffmpeg to extract frames from the video file to grab only the frames where you issued the Frex commands. Then do the processing.

From my understanding of how frex works the camera needs to be in "free run" then the frex commands can be initialized.

Ideally I imagine it working like this:
Have the camera running in free run mode the at a reduced resolution checking for motion.
Motion Detected
Switch the camera into single frame acquisition mode with a exposure time of 2μs.
Begin Frame acquisition
send 4 frex signals
end frame acquisition
send frame to camera ram for processing with machine vision algorithm.


Should get my cameras soon so I will probably be more useful once I finally get my hands on some hardware. :D
-Chief Tinkering Officer
ewing
Posts: 1
Joined: Tue May 12, 2020 11:50 am

Re: OV5640 FREX mode

Postby ewing » Sat May 16, 2020 1:17 pm

CameraMan wrote:
Mon Apr 13, 2020 1:02 pm
Here is some interesting stuff about Frex and the OV5640 camera, from the raspberry pi forum:


https://github.com/Hermann-SW/Raspberry ... l_shutter

The main issues I have with his execution is requiring that raspivid_ges has to be run then the frex commands issued during the stream. So the stream is constantly writing to disk taking up space then you have to manually use something like ffmpeg to extract frames from the video file to grab only the frames where you issued the Frex commands. Then do the processing.

From my understanding of how frex works the camera needs to be in "free run" then the frex commands can be initialized.

Ideally I imagine it working like this:
Have the camera running in free run mode the at a reduced resolution checking for motion.
Motion Detected
Switch the camera into single frame acquisition mode with a exposure time of 2μs.
Begin Frame acquisition
send 4 frex signals
end frame acquisition
send frame to camera ram for processing with machine vision algorithm.


Should get my cameras soon so I will probably be more useful once I finally get my hands on some hardware. :D
Hi, I have exactly the same issue in using OV5640.
I read in a software application notes of OV5640, which is modified in May 25, 2011, mentioned that "...In both Mode 1 and Mode 2, we have the option(0x3817[3]) of turning off normal(rolling) mode timing. In that case, the sensor will not output image unless frex request comes. Every single request results in one single frame of image."
I tried changing that resgister 0x3817, but no difference occurred, the normal(rolling) mode still running.
Do you guys find anything new about it?
User avatar
kwagyeman
Posts: 4111
Joined: Sun May 24, 2015 2:10 pm

Re: OV5640 FREX mode

Postby kwagyeman » Sat May 16, 2020 2:46 pm

Haven't gotten t working on this. Will do soon.
Nyamekye,
BruceHoward
Posts: 1
Joined: Tue Jun 30, 2020 1:10 pm

Re: OV5640 FREX mode

Postby BruceHoward » Tue Jun 30, 2020 5:24 pm

Hi,

I am also interested in using the FREX mode available in the OV5640 for acquiring single frame images. Has any progress been made in making this work with the H7+?
User avatar
kwagyeman
Posts: 4111
Joined: Sun May 24, 2015 2:10 pm

Re: OV5640 FREX mode

Postby kwagyeman » Tue Jun 30, 2020 5:27 pm

None, it's a low priority for me. You should create a GitHub issue ticket about it so that it's tracked.

I have to fix an issue with the register settings for the OV5640 involving the greenish spot in the center of the field of view under certain lighting situations. So, I can look at adding an IOCTL to enable this then.
Nyamekye,

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 7 guests