Skip to main content

Image processing functions useful for FRC robotics teams (and other purposes)

Project description

Vision processing scripts useful for FIRST robotics teams and probably other purposes.

License: MIT

Author: Tim Poulsen, mentor for Team 1518 Raider Robotics

Version 0.1.4 (alpha)

Overview

The 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 camera

  • Lens distortion removal based on the camera calibrations created with the provided autocalibrate.py script

  • Retroreflective target identification, contour finding, and geometry finding functions

  • Image resizing, equalization, brightness and contrast adjustments, and more

  • A 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 images

The 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 / Usage

The best way to install this is with pip:

$ pip install robovision

You can also clone the repo and install locally:

$ git clone https://github.com/skypanther/robovision.git
$ cd robovision
$ pip install -e .

Target environment

Our 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.x

  • Jetson TX2 running Ubuntu 16.04 and JetPack 3.2.1

  • Axis 206 IP camera

  • Onboard Jetson gstreamer camera

  • Microsoft Lifecam USB camera

Python 2.x is not supported.

Example

import 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()
        break

Contributing

Contributions 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!).

License

MIT License

Copyright (c) 2019, Tim Poulsen, All rights reserved.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

robovision-0.1.4-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file robovision-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: robovision-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.5.0 setuptools/38.5.2 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.3

File hashes

Hashes for robovision-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 466d2b1d02c60c5cf3e29cf5737e03cf3ce4d0d34fd4997e391541405eb4814e
MD5 7dcfaed4c2f7d1fbe1297216f46275e5
BLAKE2b-256 168ecef5cb8134770e79a62fd764c81edea82ee6a3dcc8155a1fceb0fc07bb98

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page