need to check orientation of below part

Discussion related to "under the hood" OpenMV topics.
dhunjoshi
Posts: 9
Joined: Tue Apr 10, 2018 2:46 am

need to check orientation of below part

Postby dhunjoshi » Sat May 05, 2018 12:42 pm

IMG_20180505_213941.jpg
IMG_20180505_213941.jpg (4.19 MiB) Viewed 292 times
IMG_20180505_213931.jpg
IMG_20180505_213931.jpg (4.26 MiB) Viewed 292 times
User avatar
kwagyeman
Posts: 2275
Joined: Sun May 24, 2015 2:10 pm

Re: need to check orientation of below part

Postby kwagyeman » Sat May 05, 2018 2:31 pm

Hi, this is not easy to do with any elementary methods, you'll have to build up a complex image processing setup to do this. First, do you have a jig to mount the OpenMV Cam in to look at the part? If so, then can you take pictures using the jig?
Nyamekye,
dhunjoshi
Posts: 9
Joined: Tue Apr 10, 2018 2:46 am

Re: need to check orientation of below part

Postby dhunjoshi » Sun May 06, 2018 8:30 am

kwagyeman wrote:
Sat May 05, 2018 2:31 pm
Hi, this is not easy to do with any elementary methods, you'll have to build up a complex image processing setup to do this. First, do you have a jig to mount the OpenMV Cam in to look at the part? If so, then can you take pictures using the jig?
OK.jpg
OK.jpg (13.2 KiB) Viewed 282 times
NG.jpg
NG.jpg (13.23 KiB) Viewed 282 times
yes i have mada jig for mount OpenMV Cam and above two image taken from that.
User avatar
kwagyeman
Posts: 2275
Joined: Sun May 24, 2015 2:10 pm

Re: need to check orientation of below part

Postby kwagyeman » Sun May 06, 2018 1:59 pm

Our CNN for finding numbers isn't that great. Needs a better model:

Code: Select all

import sensor, image, time, pyb

# Replace this image loading with a loop with snapshot...
img = image.Image("OK.bmp", copy_to_fb=True) # load image

img.binary([(90, 100)], zero=True)
img.mean(7, threshold=True, offset=-40, invert=False)
img.erode(1, threshold=5)

blobs = img.find_blobs([(90, 100)], x_stride=1, y_stride=1)
blobs = list(filter(lambda x: x.w() < 10, blobs)) # Find blobs less than 10 pix wide
blobs = sorted(blobs, key=lambda x: (x.y() * x.w()) + x.x()) # index from pixel offset

gs_img = img.to_grayscale(copy=True)

correct = [1, 3, 5, 2, 4, -1]
score = 0

for i in range(len(blobs)):
    b = blobs[i]
    new_roi = (b.x()-10, b.y()-10, 28, 28)
    num, conf = gs_img.find_number(roi=new_roi)
    img.draw_rectangle(new_roi, color=(255, 0, 0), thickness=2)
    img.draw_string(b.x()-10, b.y()-10, "%d" % num)
    score += num == correct[i]
print(score)

img.compress(90) # Force higher quality jpeg
sensor.flush() # Send image to PC
pyb.delay(1000) # Wait for the image to be displayed
Anyway, if you try out the OK.bmp versus the NG.bmp file you'll see the score is 2 versus 0. For the CNN to work better the numbers need to be more zoomed in on.
Attachments
OK.zip
(59.43 KiB) Downloaded 12 times
Nyamekye,
dhunjoshi
Posts: 9
Joined: Tue Apr 10, 2018 2:46 am

Re: need to check orientation of below part

Postby dhunjoshi » Mon May 07, 2018 1:27 am

error.jpg
error.jpg (283.36 KiB) Viewed 274 times
kwagyeman wrote:
Sun May 06, 2018 1:59 pm
Our CNN for finding numbers isn't that great. Needs a better model:

Code: Select all

import sensor, image, time, pyb

# Replace this image loading with a loop with snapshot...
img = image.Image("OK.bmp", copy_to_fb=True) # load image

img.binary([(90, 100)], zero=True)
img.mean(7, threshold=True, offset=-40, invert=False)
img.erode(1, threshold=5)

blobs = img.find_blobs([(90, 100)], x_stride=1, y_stride=1)
blobs = list(filter(lambda x: x.w() < 10, blobs)) # Find blobs less than 10 pix wide
blobs = sorted(blobs, key=lambda x: (x.y() * x.w()) + x.x()) # index from pixel offset

gs_img = img.to_grayscale(copy=True)

correct = [1, 3, 5, 2, 4, -1]
score = 0

for i in range(len(blobs)):
    b = blobs[i]
    new_roi = (b.x()-10, b.y()-10, 28, 28)
    num, conf = gs_img.find_number(roi=new_roi)
    img.draw_rectangle(new_roi, color=(255, 0, 0), thickness=2)
    img.draw_string(b.x()-10, b.y()-10, "%d" % num)
    score += num == correct[i]
print(score)

img.compress(90) # Force higher quality jpeg
sensor.flush() # Send image to PC
pyb.delay(1000) # Wait for the image to be displayed
Anyway, if you try out the OK.bmp versus the NG.bmp file you'll see the score is 2 versus 0. For the CNN to work better the numbers need to be more zoomed in on.
thank you very much for your kind support. i tried but below error is coming.
Image
User avatar
kwagyeman
Posts: 2275
Joined: Sun May 24, 2015 2:10 pm

Re: need to check orientation of below part

Postby kwagyeman » Mon May 07, 2018 1:51 am

Please use the lower resolution images I provided in the attached zip file in the previous post for getting started.

Also, you need to update your firmware. We just released the latest OpenMV IDE for all this stuff. The binary method was improved and was previously not able to handle the arguments passed like in the test script.
Nyamekye,
dhunjoshi
Posts: 9
Joined: Tue Apr 10, 2018 2:46 am

Re: need to check orientation of below part

Postby dhunjoshi » Mon May 07, 2018 2:08 am

kwagyeman wrote:
Mon May 07, 2018 1:51 am
Please use the lower resolution images I provided in the attached zip file in the previous post for getting started.

Also, you need to update your firmware. We just released the latest OpenMV IDE for all this stuff. The binary method was improved and was previously not able to handle the arguments passed like in the test script.
openMV ide download link not working..
User avatar
kwagyeman
Posts: 2275
Joined: Sun May 24, 2015 2:10 pm

Re: need to check orientation of below part

Postby kwagyeman » Mon May 07, 2018 2:37 am

Fixed
Nyamekye,

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 8 guests