Exemplo n.º 1
0
import numpy as np
import cv2
from ospery_diver import Camera, Executor, tasks, Communicator
from ospery_diver.util import *
import time

cam = cv2.VideoCapture(0)
executor = Executor(cv2, np)
comm = Communicator('/dev/ttyAMA0', 9600)
# calibrated_color = long_range_orange()
# colorCalibrate(calibrated_color)
# display = Display(cv2)
ret, frame = cam.read()
height, width, _ = frame.shape
mid_x = width / 2
mid_y = height / 2
i = 0

turn = False
while (True):
    i += 1
    ret, frame = cam.read()
    cv2.imwrite('/home/pi/test' + str(i) + '.jpg', frame)
    pointTask = executor.run(tasks.gateDetector, frame, orange())
    pointResult = pointTask.result()
    pointResult.drawOnFrame(frame)

    # display.show(frame, 'frame')
    # display.show(threshold, 'threshold')
    command = "1 1 "
    if pointResult.value() is not None:
Exemplo n.º 2
0
# import function, variable, and classes from other modules
import numpy as np
import cv2
from ospery_diver import Camera, Display, Executor, tasks
from ospery_diver.util import *

cam = Camera(cv2)  # Camera Object
display = Display(cv2)  # Object used to display results or camera frames
executor = Executor(
    cv2, np
)  # The object that is responsible for executing different tasks (color detection, buoy detection, etc )

# Program we will be constantly looping
# press CTRL-C to abort (end program)
while (True):

    frame = cam.getFrame(
    )  # get a single frame or image from the camera and store it in a object

    # Try running the task with different colors
    # Comment the color = ORANGE and uncomment either color = BLUE or color GREEN
    color = ORANGE
    #color = BLUE
    #color = GREEN

    buoyTask = executor.run(
        tasks.buoyDetector, frame,
        color)  # Execute the task. The executed task can be stored in variable

    buoyResult = buoyTask.result()  # grab a result object from the task
    buoyResult.drawOnFrame(