-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Tim Poulsen edited this page Feb 24, 2019
·
5 revisions
Robovision is a Python 3.x library that simplifies computer vision tasks typically implemented by FIRST robotics teams.
- Simplifies the basics and hides the complexity of common OpenCV robot vision tasks.
- Does not aim to do everything or provide every function you might need.
- Is meant to be run on a coprocessor, not the RoboRio.
Robovision has been developed on a mix of MacOS and Linux systems (Ubuntu, Raspbian). While it should work on Windows (particularly with the Anaconda Python environment), this hasn't been tested.
-
Core functions
- Basic image manipulation
- Edge detection, flattening, etc.
- Overlays
- Image stream preprocessing
- Target functions
- Multithreaded video streaming
An example of the basic use of Robovision is:
import argparse
import cv2
import numpy as np
import robovision as rv
# DEFAULT / STARTING VALUES
LOWER = 60 # HSV lower hue color
UPPER = 100 # HSV upper hue color
target = rv.Target()
target.set_color_range(lower=(LOWER, 100, 100), upper=(UPPER, 255, 255))
def main():
ap = argparse.ArgumentParser()
ap.add_argument("-s", "--source", required=True,
help="Video source, e.g. the webcam number")
args = vars(ap.parse_args())
# create a video stream source
vs = rv.get_video_stream(args["source"])
# start the source (i.e. turn on the camera)
vs.start()
cv2.namedWindow('CapturedImage', cv2.WINDOW_NORMAL)
while True:
# read a frame from the camera
frame = vs.read_frame()
# get a set of contours around the detected colors in the frame
contours = target.get_contours(frame)
# you'd do something here with those contours
cv2.imshow('CapturedImage', frame)
# wait for Esc or q key and then exit
key = cv2.waitKey(1) & 0xFF
if key == 27 or key == ord("q"):
cv2.destroyAllWindows()
vs.stop()
break
© 2019 Tim Poulsen, library: MIT, docs: CC BY-SA 4.0