0

I am trying to use object detection to recognise a post-it note within a video feed. I am using emguCV for detection. I tried using the Shape Detection approach but it couldn't recognise the post-it... maybe because I was holding it up in the air so my fingers were obstructing the vertices.

I've also tried using SURF detection but that did not work either I guess because it is a square so does not have any stand-out features.

I attempted to use HAAR/LBP classification but it was taking over 10 hours to train just for one stage for 48 positives and 80 negatives so I gave up.

Can anyway suggest a suitable method for detecting/recognising a post-it note within a video feed? Would be much appreciated.

deez22
  • 17
  • 5

1 Answers1

2

I have had a similar problem recently, this is how I have solved it. I have just used the post note color in the HSV spectrum to locate it. You just have to choose a color that is both easily recognizable and doesn't change much under angle.

I've used this code to control an AR drone with 2 post-it notes taped to it, so it had to be reliable and fast. Here it is in action. Hope it helps.

def centerFromImage(image, hue_min, hue_max):
    image = cv2.cvtColor(image, cv2.cv.CV_RGB2HSV)
    hue = image[:, :, 0]

    # Filter out green postit note color
    # yellow is 90-100
    # pink is 137-150
    # green is 80-90
    hue[hue < hue_min] = 0
    hue[hue > hue_max] = 0
    hue[hue > 0] = 255

    hue = cv2.erode(hue, None, iterations=2)
    hue = cv2.dilate(hue, None, iterations=2)

    contours, hierarchy = cv2.findContours(
        hue,
        cv2.RETR_LIST,
        cv2.CHAIN_APPROX_SIMPLE
    )

    center = [0, 0]

    if len(contours) > 0:
        contour = contours[0]
        area = cv2.contourArea(contour)

        for c in contours:
            if cv2.contourArea(c) > area:
                area = cv2.contourArea(c)
                contour = c

        m = cv2.moments(contour)
        center = [0, 0]
        if m['m00'] != 0:
            center = [m['m10'] / m['m00'], m['m01'] / m['m00']]

        center = [int(center[0]), int(center[1])]

    return center
mirosval
  • 6,671
  • 3
  • 32
  • 46
  • ahh thank you very much. What hsv min and max values did you use to locate the blue post-it note? – deez22 Feb 22 '14 at 12:00
  • Don't know exactly, I had a script that allowed me to read the hue value using the mouse pointer directly from the cam, I can probably find it if you want – mirosval Feb 22 '14 at 12:57
  • Yes please that would be very helpful. – deez22 Feb 22 '14 at 15:12
  • I put it in a [gist](https://gist.github.com/mirosval/9169921). It uses freenect and Kinect as a camera, but you could modify it easily to load it from an image or what.. Btw, turns out that the blue postit color is 165-180 – mirosval Feb 23 '14 at 10:59