Ask Your Question
0

Vision tracking using retroreflective tape

asked 2016-02-06 13:35:39 -0600

szewczukm219 gravatar image

updated 2016-02-07 00:54:55 -0600

berak gravatar image

Hello,

I am an FRC programmer, currently assigned with the task of vision processing. My team has not ever done vision processing in the past and it would be very helpful to have vision tracking done for this years challenge. Currently, I am able to take this image image description

and turn it into this, image description

using the code below. I've gotten to this point and am struggling getting the area highlighted (Made out of retroreflective tape) to the point where the processed image (second image) to be a more defined area of color. Currently I am using a usb webcam with a green LED ring around it. I am looking for a little bit of help defining the outlined area in the second image with the green colored bit in the first image.

import cv2
import numpy as np
vid = cv2.VideoCapture(0)
vid.set(10,.05)

while(True):
    ret, frame = vid.read()
    hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
    lower_green = np.array([40,20,20])
    upper_green = np.array([70,255,255])
    mask = cv2.inRange(hsv, lower_green, upper_green)
    res = cv2.bitwise_and(frame,frame,mask=mask)
    cv2.imshow('orig',frame)
    cv2.imshow('fff',res)

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
vid.release()
cv2.destroyAllWindows()
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-02-07 01:22:04 -0600

berak gravatar image

updated 2016-02-07 01:23:49 -0600

imho, your ranges are a bit off. it will definitely get better, if you add some pixel-testing code to your prog to test the actual hsv values, like:

def onmouse(k,x,y,s,p):
    global hsv
    if k==1:   # left mouse, print pixel at x,y
        print hsv[y,x]

cv2.namedWindow("hsv")
cv2.setMouseCallback("hsv",onmouse);
cv2.imshow('hsv',hsv)

using your image above i get something like:

[ 81 218 237]

then, you can adjust your ranges, maybe to:

lower_green = np.array([75,200,200])
upper_green = np.array([85,255,255])

and get a beautiful mask:

image description

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-02-06 13:35:39 -0600

Seen: 2,523 times

Last updated: Feb 07 '16