findContours

  1. caffe instead of caffe2?

  2. python2 instead of python3?


    Anyway, catching up…

We’re basically using what ARM provided us. The implement work was mostly done by them. We’re just taking it from demo quality to usable.

Hi all , I’ve pre-ordered the H7 coming camera , and I’m really newby with OpenMV cams… waiting for the cam I’m checking the examples in the IDE software I already installed some days ago .

So I ordered this cam to make a basic Background subtraction work , but on ‘no-color’ objects ( small black objects moving ) . I’ve checked on the forum and I 'm not sure that the find blob method works on black objects ? did I missunderstood and will this work ? (it looks like it seems to look for a color range threshold no ? )

currently I’m using a working Rpi+ picam V2 solution, using OpenCV ( using background subtraction MOG2 type then FindContours method then ‘minEnclosingCircle’ method which gives me something like in the attached image . ) this allows me to find the biggest moving object ( white ‘blob’ ) and gives me his coordinates x,y + the Circle radius (which allows me to find an approximate detph as I know the average blob real world size … so = ‘z’ coordinate).

Do you think we can get such workflow/result with OpenMV H7 cam ?

Thanks by advance for any input over this :slight_smile: .

and keep rocking guys , your product looks awesome , can’t wait to receive it .

Clem
BG_Contour_MinCircle.jpg

Hi, I added all the features find_countours provides in OpenCV to our API. We have a minimum circle method now. If you’d like to the un-released firmware let me know.

As for doing what you want. First use frame differencing to create a difference image and then just threshold that image for non-block things (i.e. differences). find_blobs() will then give you the objects and you can filter in python to find the largest ones.

Hi Nyamekye ,

I added all the features find_countours provides in OpenCV to our API

:slight_smile: thanks for those great additions ! Do you have examples scripts of those already maybe ?
So this new minimumCircle method will return a radius value too ? ( to use for guessing the ‘Z detph’ )

If you’d like to the un-released firmware let me know.

yes please if you can share with me/us this new version that’ll be great :slight_smile:

Ha ok for the frame differencing , I’ll check this more in details .
Thanks by advance

Clément

Example:

# Single Color RGB565 Blob Tracking Example
#
# This example shows off single color RGB565 tracking using the OpenMV Cam.

import sensor, image, time, math

threshold_index = 0 # 0 for red, 1 for green, 2 for blue

# Color Tracking Thresholds (L Min, L Max, A Min, A Max, B Min, B Max)
# The below thresholds track in general red/green/blue things. You may wish to tune them...
thresholds = [(30, 100, 15, 127, 15, 127), # generic_red_thresholds
              (30, 100, -64, -8, -32, 32), # generic_green_thresholds
              (0, 30, 0, 64, -128, 0)] # generic_blue_thresholds

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
sensor.set_auto_gain(False) # must be turned off for color tracking
sensor.set_auto_whitebal(False) # must be turned off for color tracking
clock = time.clock()

# Only blobs that with more pixels than "pixel_threshold" and more area than "area_threshold" are
# returned by "find_blobs" below. Change "pixels_threshold" and "area_threshold" if you change the
# camera resolution. "merge=True" merges all overlapping blobs in the image.

while(True):
    clock.tick()
    img = sensor.snapshot()
    for blob in img.find_blobs([thresholds[threshold_index]], pixels_threshold=200, area_threshold=200, merge=True):
        # These values depend on the blob not being circular - otherwise they will be shaky.
        if blob.elongation() > 0.5:
            img.draw_edges(blob.min_corners(), color=(255,0,0))
            img.draw_line(blob.major_axis_line(), color=(0,255,0))
            img.draw_line(blob.minor_axis_line(), color=(0,0,255))
        # These values are stable all the time.
        img.draw_rectangle(blob.rect())
        img.draw_cross(blob.cx(), blob.cy())
        # Note - the blob rotation is unique to 0-180 only.
        img.draw_keypoints([(blob.cx(), blob.cy(), int(math.degrees(blob.rotation())))], size=20)
    print(clock.fps())

Do img.draw_circle(blob.enclosing_circle()) to draw the circle that encloses the blob. Note that the enclosing circle depends on the blob having a unique’ish shape. Otherwise the min area rect won’t be stable.
firmware.zip (923 KB)

1 Like

oh I just see your reply Nyamekye , sorry !

thanks for the code ! :slight_smile: