Example #1
0
#camera.resolution = (160, 120)
#camera.framerate = 16
#rawCapture = PiRGBArray(camera, size=(160, 120))

#camera
rawCapture = VideoStream(0).start()
#rawCapture = vs.read()
#rawCapture = imutils.resize(rawCapture, width=500)
#rawCaoture = imutils.rotate(rawCapture, angle=180)

# allow the camera to warmup
time.sleep(0.001)

# capture frames from the camera
for image in rawCapture.capture_continuous(rawCapture,
                                           format="bgr",
                                           use_video_port=True):
    #grab the raw NumPy array representing the image, then initialize the timestamp and occupied/unoccupied text
    frame = image.array
    frame = imutils.resize(frame, width=160)
    frame = imutils.rotate(frame, angle=180)

    #frame=cv2.flip(frame,1)
    global centre_x
    global centre_y
    centre_x = 0.
    centre_y = 0.
    hsv1 = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
    mask_red = segment_colour(frame)  #masking red the frame
    loct, area = find_blob(mask_red)
    x, y, w, h = loct