find template

Hi.
I using a find_template function.
but if moving snapshot images
camera connections are fail

how can i stay clearly connection state

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)

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

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

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())

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

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

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.
pgm_file.zip (43.1 KB)
test.mp4 (1 MB)
target_point.PNG
template_image.PNG
target_image.PNG

Hi, I can reproduce this bug, will look into it and get back to you.