Esempio n. 1
0
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
Esempio n. 2
0
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])
Esempio n. 3
0
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])