I need calculate the sum of pixel in a specific ROI of a gray scale image.
Reading some article on image processing , seems that one of most easy way is transit from an Integral image of the ROI.
My ROI is about 5 x 150 pixel and I could use the image.get_pixel(x,y) to calculate the values , I don’t think that is a big effort for OpenVM7.
Anyway ,Could I have benefict using the integral image method on a ROI of this size ?
Is there any function inside OpenVM sw that already calculate an integral image starting from a ROI ?
I’ve tryed this piece of code :
while(True): bar1=0 bar2=0 img = sensor.snapshot() for x in range (20,21): for y in range(10,121): print( type(img.get_pixel(22,14))) bar1 += img.get_pixel(x,y) img.draw_string(28, 10,str(bar1))
Why at this instruction :
bar1 += img.get_pixel(x,y)
I got this error TypeError: unsupported types for iadd: ‘int’, ‘NoneType’ ?!!
Both bar1 and img.get_pixel(x,y) are integer
In the micropython forum If found this post quite similar with nested for loop : weird behaviour breaking from a nested loop - MicroPython Forum.
May be that we are in the same situation with the version of firmare for OpenVM7 ?
My version is :MicroPython v1.8-4391-g3696110a on 2017-06-04; OPENMV3 with STM32F765.
Hi, if you index out of bounds get pixel returns none. Please handle the case is none is returned.
Ok I was 1 pixel over the y resolution …
Thanks . Roberto.