Package: robovision
Vision processing scripts useful for FIRST robotics teams and probably other purposes.License: MITAuthor: Tim Poulsen, mentor for Team 1518 Raider RoboticsVersion 0.1.4 (alpha)OverviewThe robovision library includes functions useful for the types of vision tasks typically involved in a FIRST robotics competition. The goal of this library is to reduce (and hide) some of the complexity involved with target identification, measuring, field orienteering, etc.Some of the functions included:Image acquisition from a web cam, IP cam (i.e. Axis cam), Raspberry Pi camera, or Jetson onboard gstreamer cameraLens distortion removal based on the camera calibrations created with the provided autocalibrate.py scriptRetroreflective target identification, contour finding, and geometry finding functionsImage resizing, equalization, brightness and contrast adjustments, and moreA preprocessor class, which enables you to set up a pipeline of functions that will be applied in series to an image.Overlay arrows, text, borders, or crosshairs on imagesThe autocalibrate script is a camera calibration utility, which uses the OpenCV chessboard technique to determine lens parameters to be used for dewarping operations. If you prefer, there’s a manual_lens_calibration.py script that lets you adjust the various lens parameters until the image is visually correct.Installation / UsageThe best way to install this is withpip:$ pip install robovisionYou can also clone the repo and install locally:$ git clone https://github.com/skypanther/robovision.git
$ cd robovision
$ pip install -e .Target environmentOur primary vision system is a Jetson TX2 board. I’ve done most of the development on a Mac OS X system, with some testing on an Ubuntu laptop. The scripts should work on a Raspberry Pi, but we haven’t tested that yet. We don’t intend to use or test on Windows systems, so your guess is as good as ours whether it will work there. (But feel free to make a pull request to add Windows compatibility.)Our environment is:Python 3.5.x (newer versions, and Anaconda works too)OpenCV 3.4.xJetson TX2 running Ubuntu 16.04 and JetPack 3.2.1Axis 206 IP cameraOnboard Jetson gstreamer cameraMicrosoft Lifecam USB cameraPython 2.x isnotsupported.Exampleimport cv2
import robovision as rv

# create a video stream to our IP camera
source = "http://10.15.18.100/mjpg/video.mjpg"
vs = rv.VideoStream(source="ipcam", ipcam_url=source)

# instantiate the targeting class and set the color range of
# the retroreflective tape
target = rv.Target()
target.set_color_range(lower=(80, 100, 100), upper=(90, 255, 255))

# start the video stream
vs.start()

cv2.namedWindow('CapturedImage', cv2.WINDOW_NORMAL)

while True:
    frame = vs.read_frame()
    contours = target.find_contours(frame)
    if len(contours) > 0:
        cv2.drawContours(frame, contours, -1, (0, 0, 255), 3)
        print('angle {}'.format(target.get_skew_angle(contours[0])))
    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()
        breakContributingContributions are welcome! Feel free to open a pull request. Or, open an issue if you find something that doesn’t work (which is probably a lot!).LicenseMIT LicenseCopyright (c) 2019, Tim Poulsen, All rights reserved.