Page 1 of 1

find template

Posted: Wed Jan 10, 2018 4:03 am
by jade
Hi.
I using a find_template function.
but if moving snapshot images
camera connections are fail

how can i stay clearly connection state

Re: find template

Posted: Wed Jan 10, 2018 10:42 am
by kwagyeman
Hi, what's the hardware you are using M4/M7, ide version, operating system, and firmware version?

Re: find template

Posted: Wed Jan 10, 2018 7:45 pm
by jade
kwagyeman wrote:
Wed Jan 10, 2018 10:42 am
Hi, what's the hardware you are using M4/M7, ide version, operating system, and firmware version?
I using M7 and firmware version is 2.6.0
camera is connected on PC
PC is operating Windows 7

python program is operating on my pc

i want to find some point of image
so template is part of image (snapshot -> save(roi))

usually disconnecting at image change
(image or camera is moving
and focus out or can not find template on image)

Re: find template

Posted: Wed Jan 10, 2018 9:19 pm
by kwagyeman
Hi, do you have an SD Card with the camera? You can save images to the internal flash. Otherwise, it seems like the camera should be fine with your PC.

Re: find template

Posted: Wed Jan 10, 2018 10:20 pm
by jade
kwagyeman wrote:
Wed Jan 10, 2018 9:19 pm
Hi, do you have an SD Card with the camera? You can save images to the internal flash. Otherwise, it seems like the camera should be fine with your PC.
Hi.
if i insert SD Card, how can i check Card was connected successfully

after insert SD Card, and try advanced_frame_differencing project
and occurs error
OSError : Failed to write requested bytes!

Do i something at SD Card?

SD Card is 8GB and FAT32 Format and also exFAT Format do not work too

Re: find template

Posted: Wed Jan 10, 2018 10:31 pm
by kwagyeman
Hi, the SD card should appear when you plug the camera into the PC and you should see it as a USB drive on the computer. You should be able to open files and save files using Windows explorer.

Re: find template

Posted: Thu Jan 11, 2018 5:14 am
by jade
kwagyeman wrote:
Wed Jan 10, 2018 10:31 pm
Hi, the SD card should appear when you plug the camera into the PC and you should see it as a USB drive on the computer. You should be able to open files and save files using Windows explorer.
Hi.
insert SD Card, but it have same symptoms.

always disconnected after print("1") and before print("2") at code
so i can see printed 1 but cannot see printed 2

if it have small size template image , it have much better connecting time
but it also disconnected few minutes ago.

I think it happens when the images are constantly moving and there is more tracking of the images.

i need connection for 24 hours.
so it must not disconnect

and if i set roi, but it isn't work .
the template match location was out of roi

Code: Select all

import time, sensor, image
from image import SEARCH_EX, SEARCH_DS

sensor.reset()
#sensor.set_auto_gain(True);
#sensor.set_auto_whitebal(True);
sensor.set_contrast(3)
#sensor.set_gainceiling(8)
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 1000)

clock = time.clock()

#img = sensor.snapshot()
#img.save("/desc.pgm",roi = (57,142,53,64))
template = image.Image("/desc.pgm") #,copy_to_fb = True
#img = sensor.snapshot()

while(True):
    clock.tick()
    img = sensor.snapshot()
    #print("1")
    r = img.find_template(template, 0.60, step=8, search=SEARCH_DS, roi=(1,1,118,238)) #, roi=(10, 0, 60, 60))
    #print("2")
    if r:
        print(r)
        img.draw_rectangle(r)
    print(clock.fps())




Re: find template

Posted: Thu Jan 11, 2018 11:20 am
by kwagyeman
Hi, please upload all assets for me to reproduce the behavior. I.e. the template image and target image. Please save them both as PPM files using the OpenMV Cam's save method.

Your running into a bug right now. The question is if I can work around it in the mean time.

Re: find template

Posted: Thu Jan 11, 2018 8:00 pm
by jade
kwagyeman wrote:
Thu Jan 11, 2018 11:20 am
Hi, please upload all assets for me to reproduce the behavior. I.e. the template image and target image. Please save them both as PPM files using the OpenMV Cam's save method.

Your running into a bug right now. The question is if I can work around it in the mean time.
maybe you can see how i tried through attached video
and this video have roi (1,1,118,238)
it was out of roi that template matched location

i can not save ppm file
if i try save to desc.ppm
Occurs ErrorMessage - OSError: Image is not PPM
so files are pgm file

and I attached the code below

image save code

Code: Select all

img = sensor.snapshot()
img.save("/desc.pgm",roi = (104,127,34,34))
template = image.Image("/desc.pgm",copy_to_fb = True) #
img = sensor.snapshot()
template_matching test code

Code: Select all

template = image.Image("/desc.pgm")
while(True):
    clock.tick()
    img = sensor.snapshot()
    #print("1")
    r = img.find_template(template, 0.60, step=8, search=SEARCH_DS, roi=(1,1,118,238)) #, roi=(10, 0, 60, 60))
    #print("2")
    if r:
        print(r)
        img.draw_rectangle(r)
    print(clock.fps())
I write down before
i need connection for 24 hours.

Re: find template

Posted: Fri Jan 12, 2018 1:23 pm
by iabdalkader
Hi, I can reproduce this bug, will look into it and get back to you.