Average of 4 pictures

General discussion about topics related to OpenMV.
Ezzobeir
Posts: 4
Joined: Mon Mar 05, 2018 8:09 am

Average of 4 pictures

Postby Ezzobeir » Wed Apr 18, 2018 10:43 am

Hello ,
I have a Cam M7.

I'm trying to develop a program that can create a picture which is the average of 4 other pictures .
The Idea I had is to take 5 pictures, and modify the fifth one in order to get the average ( by adding pixels)

The program is as follows :

# Untitled - By: marc - mer. avr. 18 2018

import sensor, image, time, pyb

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(2000)

clock = time.clock()

L = 320
l = 240


img1 = sensor.snapshot()

img2 = sensor.snapshot()
img3 = sensor.snapshot()
img4 = sensor.snapshot()
img_average = sensor.snapshot()

for i in range(L*l):
img_average = ( ( img1 + img2 + img3 + img4 ) // 4 )

img1.save("/Image1")
img2.save("/Image2")
img3.save("/Image3")
img4.save("/Image4")

img_average.save("/Image_Average")

But I noticed that it is not possible to declare 5 Image objects by using sensor.snapshot : It's like I have one image object instead of 5.


Is there any other way to do that ?

Best regards
User avatar
kwagyeman
Posts: 1746
Joined: Sun May 24, 2015 2:10 pm

Re: Average of 4 pictures

Postby kwagyeman » Thu Apr 19, 2018 2:02 am

Hi, please use this:

http://docs.openmv.io/library/omv.senso ... c_extra_fb

Just alloc the frame buffer and then use the blend method to blend images into the frame buffer. For examples, see the in memory frame differencing scripts.

Note that the system only has one frame buffer normally... I.e. the next snapshot overwrites the first one.
Nyamekye,
Ezzobeir
Posts: 4
Joined: Mon Mar 05, 2018 8:09 am

Re: Average of 4 pictures

Postby Ezzobeir » Mon Apr 23, 2018 7:54 am

It works. Thank you very much !

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 1 guest