about

Project Development

for frame in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True):

        img = frame.array

        ## gray, threshold, keypoints

img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

ret, img_thresh = cv2.threshold(img_gray, thresh_thresh, 255, cv2.THRESH_BINARY_INV)

keypoints = detector.detect(img_thresh)

cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS

img_keypoints = cv2.drawKeypoints(img_thresh, keypoints, np.array([]), (255,255,255), cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)

if len(keypoints) == 2:

pi0.write(pinR, 0)

pi0.write(pinG, 1)

## right blob first

if (keypoints[0].pt[0] < keypoints[1].pt[0]):

    k0x =keypoints[0].pt[0]

    k0y =keypoints[0].pt[1]

    k1x =keypoints[1].pt[0]

    k1y =keypoints[1].pt[1]

 

else:

k0x =

    k0y =

    k1x =

    k1y =

keypoints[0].pt[0]

keypoints[0].pt[1]

keypoints[1].pt[0]

keypoints[1].pt[1]

keypoints[1].pt[0]

keypoints[1].pt[1]

keypoints[0].pt[0]

keypoints[0].pt[1]

            ## join with line and circle centroid

cv2.line (img, (int(k0x), int(k0y)), (int(k1x), int(k1y)),(0,255,100),2 )

cv2.line (img_thresh, (int(k0x), int(k0y)), (int(k1x), int(k1y)),(0,0,0) )

cv2.line (img_keypoints, (int(k0x), int(k0y)), (int(k1x), int(k1y)),(0,0,0) )

            len_y = (k1y - k0y)

            len_x = (k1x - k0x)

3)

dist = distance(k0x, k0y, k1x, k1y)

c_x = int(k0x + len_x/2)

c_y = int(k0y + len_y/2)

cv2.circle(img, (c_x, c_y), int(dist/2),

(0,255,100), 3) cv2.circle(img, (c_x, c_y), int(dist/6), (255,0,100), 1) cv2.circle(img_thresh, (c_x, c_y), int(dist/2), (0, 0, 0), 3) cv2.circle(img_keypoints, (c_x, c_y), int(dist/2), (0, 0, 0),

 

try:

    if len_x > 0:

        a = math.asin( len_y / len_x )

    else:

a=0 except:

a=0

## report info

cv2.putText(img, "[object A] ::

"+str(int(k0y)), (10, 15), cv2.FONT_HERSHEY_DUPLEX, 0.4, (255, 255, 255))

cv2.putText(img, "[object B] :: "+str(int(k1x))+" "+str(int(k1y)), (10, 30), cv2.FONT_HERSHEY_DUPLEX, 0.4, (255, 255, 255))

cv2.putText(img, "[-- 0 --] :: "+str(int(c_x))+" "+str(int(c_y)), (10, 45), cv2.FONT_HERSHEY_DUPLEX, 0.4, (255, 255, 255))

final project

god.