azby
Posts: 2
Joined: Sun May 16, 2021 2:02 pm

Read pixel value from preview address space

Sun May 16, 2021 2:28 pm

While having the camera (OV5647) displaying a preview on my monitor, I would like to read pixel values i.e. pixel = read(color,address).
The idea is to have quick access to data already there, and dynamically updated, when object moves in front of camera.
I can of course grab a frame and measure, and then grab another frame etc..... Hope I can do without that.

I have looked through all that I consider relevant, but I may of course have missed the right one, hi.

Hope one of you out there knows how to do this.

Thanks in advance.

User avatar
HermannSW
Posts: 4123
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Read pixel value from preview address space

Sun May 16, 2021 6:34 pm

Camera preview is an HDMI overlay.
This repo demonstrates with many examples how to deal with HDMI overlays:
https://github.com/AndrewFromMelbourne/raspidmx
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/raspiraw
https://stamm-wilbrandt.de/en/Raspberry_camera.html

azby
Posts: 2
Joined: Sun May 16, 2021 2:02 pm

Re: Read pixel value from preview address space

Thu May 20, 2021 6:49 am

Thank you very much for helping out HermannSW.

Seems like this whole camera/display area is huge, and with very sparse if any documentation.
I had hoped for a smart little solution to this, but I see now that getting into this realm is a huge task. Wonder why noone have done some simple examples to get one started. The code you pointed me to is ok, but not very much comments totell what's going on, hi.

Anyway, thanks a lot for your reply!

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 28624
Joined: Sat Jul 30, 2011 7:41 pm

Re: Read pixel value from preview address space

Tue Jun 15, 2021 9:39 am

The preview doesn't have a accessible framebuffer, so that why you cannot read a pixel from it. The data never touches ARM space, it's moved directly from the camera onto the HDMI output.

So you cannot actually read a pixel from the preview using the standard camera stack.

Things might be a little different in libcamera world, I'll ask around.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Working in the Application's Team.

User avatar
HermannSW
Posts: 4123
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Read pixel value from preview address space

Tue Jun 15, 2021 10:55 pm

jamesh wrote:
Tue Jun 15, 2021 9:39 am
So you cannot actually read a pixel from the preview using the standard camera stack.
As I said, accessing preview using AndrewFromMelbourne's code base should be possible.

If not that, then picamera should be able to save preview frames.
picamera code in this posting
viewtopic.php?f=43&t=232991&p=1582997&h ... w#p1582997
does duplicate preview and display it on two different displays at same time -- instead of displaying the split stream, picamera is likely to be able to save and/or access 2nd frame pixels.
Image
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/raspiraw
https://stamm-wilbrandt.de/en/Raspberry_camera.html

Return to “C/C++”