コード例 #1
0
ファイル: cal.py プロジェクト: ronhandler/recognition
def find_color():
    lower_color = np.array([38, 50, 50], np.uint8)
    upper_color = np.array([75, 255, 255], np.uint8)
    found_flag = False
    for i in range(0, CAM_QUANTITY):
        if temp_images[i] is None:
            continue
        for x in range(0, WIDTH, 5):
            for y in range(0, HEIGHT, 5):
                cropped_image = temp_images[i][y:y + 5, x:x + 5]

                img_hsv = cv2.cvtColor(cropped_image, cv2.COLOR_BGR2HSV)

                mask = cv2.inRange(img_hsv, lower_color, upper_color)
                amount_not_zero = cv2.countNonZero(mask)
                # If found:
                if amount_not_zero > (5 * 5) * COLOR_DETECT_THRESHOLD:
                    # print "Found the color on image " + str(i) + " at (" +str(x*5)+","+str(y*5)+")"
                    images[i] = np.copy(temp_images[i])
                    cv2.imshow(HEADER + CAMERA_LIST[i], images[i])
                    cv2.circle(images[i], (x, y), 25, (255, 0, 255), 3)
                    wp = WayPoint()
                    wp.cam_id = i
                    wp.cam_pos = (x, y)
                    wp.floor = coords[0]
                    wp.phys_pos = (coords[1], coords[2])
                    waypoints[current_wp][i] = wp

                    found_flag = True
                    break
            if found_flag is True:
                found_flag = False
                break
コード例 #2
0
ファイル: calibrate.py プロジェクト: ronhandler/recognition
def mouse_handler(event, x, y, flags, param):
    if event == cv2.EVENT_LBUTTONDOWN:
        images[param[0]] = np.copy(temp_images[param[0]])
        cv2.imshow("header"+str(param[0]),images[param[0]])
        cv2.circle(images[param[0]],(x,y),25,(255,0,0),3) 
        if param[1] is not None and param[2] is not None:
            wp = WayPoint(param[0], param[1], param[2])
            #print wp
            wp.set_cam_position(x,y)
            temp_WP[param[0]] = wp
    if event == cv2.EVENT_RBUTTONDOWN:
        images[param[0]] = np.copy(temp_images[param[0]])
コード例 #3
0
ファイル: cal.py プロジェクト: ronhandler/recognition
def mouse_handler(event, x, y, flags, cam_id):
    if event == cv2.EVENT_LBUTTONDOWN:
        images[cam_id] = np.copy(temp_images[cam_id])
        cv2.imshow(HEADER+str(cam_id),images[cam_id])
        cv2.circle(images[cam_id],(x,y),25,(255,0,0),3) 
        wp = WayPoint()
        wp.cam_id = cam_id
        wp.cam_pos = (x, y)
        wp.phys_pos = coords
        waypoints[current_wp][cam_id] = wp
    if event == cv2.EVENT_MBUTTONDOWN:
        images[cam_id] = np.copy(temp_images[cam_id])
        del(waypoints[current_wp][cam_id])
コード例 #4
0
ファイル: cal.py プロジェクト: ronhandler/recognition
def mouse_handler(event, x, y, flags, cam_id):   # removed flags,event, x, y, flags, cam_id
    if event == cv2.EVENT_LBUTTONDOWN:
        images[cam_id] = np.copy(temp_images[cam_id])
        cv2.imshow(HEADER + CAMERA_LIST[cam_id], images[cam_id])
        cv2.circle(images[cam_id], (x, y), 25, (255, 0, 0), 3)
        wp = WayPoint()
        wp.wp_id = current_wp
        wp.cam_id = cam_id
        wp.cam_pos = (x, y)
        wp.floor = coords[0]
        wp.phys_pos = (coords[1], coords[2])
        waypoints[current_wp][cam_id] = wp
    if event == cv2.EVENT_MBUTTONDOWN:
        images[cam_id] = np.copy(temp_images[cam_id])
        del (waypoints[current_wp][cam_id])