find template

Discussion related to "under the hood" OpenMV topics.
jade
Posts: 5
Joined: Wed Jan 10, 2018 3:50 am

find template

Postby jade » Wed Jan 10, 2018 4:03 am

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

how can i stay clearly connection state
User avatar
kwagyeman
Posts: 1325
Joined: Sun May 24, 2015 2:10 pm

Re: find template

Postby kwagyeman » Wed Jan 10, 2018 10:42 am

Hi, what's the hardware you are using M4/M7, ide version, operating system, and firmware version?
Nyamekye,
jade
Posts: 5
Joined: Wed Jan 10, 2018 3:50 am

Re: find template

Postby jade » Wed Jan 10, 2018 7:45 pm

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)
User avatar
kwagyeman
Posts: 1325
Joined: Sun May 24, 2015 2:10 pm

Re: find template

Postby kwagyeman » 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.
Nyamekye,
jade
Posts: 5
Joined: Wed Jan 10, 2018 3:50 am

Re: find template

Postby jade » Wed Jan 10, 2018 10:20 pm

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
User avatar
kwagyeman
Posts: 1325
Joined: Sun May 24, 2015 2:10 pm

Re: find template

Postby kwagyeman » 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.
Nyamekye,
jade
Posts: 5
Joined: Wed Jan 10, 2018 3:50 am

Re: find template

Postby jade » Thu Jan 11, 2018 5:14 am

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



User avatar
kwagyeman
Posts: 1325
Joined: Sun May 24, 2015 2:10 pm

Re: find template

Postby kwagyeman » 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.
Nyamekye,
jade
Posts: 5
Joined: Wed Jan 10, 2018 3:50 am

Re: find template

Postby jade » Thu Jan 11, 2018 8:00 pm

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.
Attachments
pgm_file.zip
(43.15 KiB) Downloaded 6 times
test.mp4
(1 MiB) Downloaded 3 times
template_image.PNG
template_image.PNG (1.69 KiB) Viewed 152 times
target_point.PNG
target_point.PNG (61.39 KiB) Viewed 152 times
target_image.PNG
target_image.PNG (59.93 KiB) Viewed 152 times
User avatar
iabdalkader
Posts: 392
Joined: Sun May 24, 2015 3:53 pm

Re: find template

Postby iabdalkader » Fri Jan 12, 2018 1:23 pm

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

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest