Skip to main content

OpenCV Camera

CheckPackage GitHub Latest Version image image PyPI - Downloads

Simple threaded camera and calibration code using OpenCV. This tries to simplify some things

Install

The preferred way to install is using pip:

pip install opencv_camera

Usage

See the jupyter notebooks under the docs in the repository for some examples.

Online nbviewer

Colorspace

Change between common colorspaces with:

  • bgr2gray(image)
  • gray2bgr(image)
  • bgr2rgb(image)
  • rgb2bgr(image)
  • bgr2hsv(image)
  • hsv2bgr(image)

Calibration

Create a mosaic of input calibration images with mosaic(images, width)

Calibrate a camera with:

calibrator = CameraCalibration()
board = ChessboardFinder((9,6), 1)
cam, cal = calibrator.calibrate(images, board)

Display all of the found image points with coverage((width, height), imagePoints)

Distortion

Use the found calibration parameters to undistort an image:

un = UnDistort(cameraMatrix, distortionCoeff, w, h)
corr_img = un.undistort(image)

Visualize the lens distortion with:

visualizeDistortion(cameraMatrix, distortCoeff, height, width)

Stereo

Calibrate a stereo camera with:

stereoCal = StereoCalibration()
board = ChessboardFinder((9,6), 1)
ok, cm, sc = stereoCal.calibrate(imgL, imgR, board)

Draw epipolar lines in stereo images with drawEpipolarLines(imgpointsL,imgpointsR,imgL,imgR)

Apps

Use program --help to display switches for each of the following:

  • opencv_calibrate: calibrate a camera
  • opencv_capture: simple tool to capture and save images
  • opencv_mjpeg: sets up a simple jmpeg server so you can view images in a web browser
  • udp_server x.x.x.x: sends camera images via UDP
  • udp_client x.x.x.x: displays UDP camera images from server

ToDo

  • Remoded apriltag calibration, moved to moms_apriltag library
  • Add pointcloud from stereo
  • Add parameters for known cameras
  • Add Jupyter notebook documentation and examples
  • Simplify stereo camera
  • Add computeReprojectionErrors and visualizeReprojErrors
  • Add visualizeDistortion
  • Add visualizeExtrinsics
  • Remove attrs, replaced with python's dataclass
  • Add save/load from yaml
  • Add stereo calibration pytest

Change Log

Date Version Notes
2022.12.23 changed version number to match date, changed to opencv-contrib-python
2020-12-27 0.10.10 added distortion and reprojection display
2020-09-15 0.10.8 added known camera params and general cleanup
2020-08-24 0.10.6 added UDP image server and client
2020-07-03 0.10.2 renamed and focused on camera
2018-07-19 0.9.4 simple clean-up and updating some things
2017-10-29 0.9.3 bug fixes
2017-04-09 0.9.0 initial python 3 support
2017-03-31 0.7.0 refactored and got rid of things I do not need
2017-01-29 0.6.0 added video capture (video and images) program
2016-12-30 0.5.3 typo fix
2016-12-30 0.5.1 refactored
2016-12-11 0.5.0 published to PyPi
2014-3-11 0.2.0 started

MIT License

Copyright (c) 2014 Kevin J. Walchko

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Metadata

Release files for opencv-camera 2023.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for opencv-camera 2023.1.7
File Size Uploaded
opencv_camera-2023.1.7.tar.gz 28.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for opencv-camera 2023.1.7
File Interpreter ABI Platform
opencv_camera-2023.1.7-py3-none-any.whl Python 3 none any Details

Total release size: 69.1 kB

Release files / opencv_camera-2023.1.7.tar.gz

Download URL opencv_camera-2023.1.7.tar.gz
Size 28.3 kB
Tags Source
SHA-256 checksum
How to use checksums
92b2aa6e8e12b85974dc0d5cd085aed850a2d1929bcce674a5d6c1f5a773eda5
BLAKE2b-256 checksum
How to use checksums
d84d5f4ab565c6baca4efb0703ebe34d32f223cc629e9d3fa9d584e0b9fc8223
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.1 CPython/3.10.9 Darwin/21.6.0

Release files / opencv_camera-2023.1.7-py3-none-any.whl

Download URL opencv_camera-2023.1.7-py3-none-any.whl
Size 40.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
31c0be953eaa0ff20b12058e791e8fdbf3387279a9f2597e8504626ef65f6876
BLAKE2b-256 checksum
How to use checksums
b2626fd3aaaf37684c7de828d4426d99e8c096df51c949c1c3ffe534b20f863b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.1 CPython/3.10.9 Darwin/21.6.0

Release history Release notifications | RSS feed

This release

2023.1.7 This release

2 release files

0.11.0

2 release files

0.10.6

2 release files

0.10.5

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page