opencv-camera


Nameopencv-camera JSON
Version 2023.1.7 PyPI version JSON
download
home_pagehttps://pypi.org/project/opencv_camera/
SummaryAn OpenCV camera library
upload_time2023-01-07 19:42:40
maintainer
docs_urlNone
authorwalchko
requires_python>=3.8
licenseMIT
keywords computer vision camera calibration opencv jupyter stereo camera cv cv2
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # OpenCV Camera

![CheckPackage](https://github.com/MomsFriendlyRobotCompany/opencv_camera/workflows/CheckPackage/badge.svg)
![GitHub](https://img.shields.io/github/license/MomsFriendlyRobotCompany/opencv_camera)
[![Latest Version](https://img.shields.io/pypi/v/opencv_camera.svg)](https://pypi.python.org/pypi/opencv_camera/)
[![image](https://img.shields.io/pypi/pyversions/opencv_camera.svg)](https://pypi.python.org/pypi/opencv_camera)
[![image](https://img.shields.io/pypi/format/opencv_camera.svg)](https://pypi.python.org/pypi/opencv_camera)
![PyPI - Downloads](https://img.shields.io/pypi/dm/opencv_camera?color=aqua)

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](https://nbviewer.org/github/MomsFriendlyRobotCompany/opencv_camera/tree/master/docs/jupyter/)

### 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)`

![](https://github.com/MomsFriendlyRobotCompany/opencv_camera/blob/master/pics/mosaic.png?raw=true)

Calibrate a camera with:

```python
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)`

![](https://github.com/MomsFriendlyRobotCompany/opencv_camera/blob/master/pics/target-points.png?raw=true)

### Distortion

Use the found calibration parameters to undistort an image:

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

Visualize the lens distortion with:

```python
visualizeDistortion(cameraMatrix, distortCoeff, height, width)
```

![](https://github.com/MomsFriendlyRobotCompany/opencv_camera/blob/master/pics/py-dist.png?raw=true)

### Stereo

Calibrate a stereo camera with:

```python
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)`

![](https://github.com/MomsFriendlyRobotCompany/opencv_camera/blob/master/pics/epipolar.png?raw=true)

## 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

- [x] Remoded `apriltag` calibration, moved to `moms_apriltag` library
- [ ] Add pointcloud from stereo
- [x] Add parameters for known cameras
- [x] Add Jupyter notebook documentation and examples
- [x] Simplify stereo camera
- [x] Add `computeReprojectionErrors` and `visualizeReprojErrors`
- [x] Add `visualizeDistortion`
- [ ] Add `visualizeExtrinsics`
- [x] Remove `attrs`, replaced with python's `dataclass`
- [x] Add save/load from `yaml`
- [x] 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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://pypi.org/project/opencv_camera/",
    "name": "opencv-camera",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "computer vision,camera,calibration,opencv,jupyter,stereo camera,cv,cv2",
    "author": "walchko",
    "author_email": "walchko@users.noreply.github.com",
    "download_url": "https://files.pythonhosted.org/packages/d8/4d/5f4ab565c6baca4efb0703ebe34d32f223cc629e9d3fa9d584e0b9fc8223/opencv_camera-2023.1.7.tar.gz",
    "platform": null,
    "description": "# OpenCV Camera\n\n![CheckPackage](https://github.com/MomsFriendlyRobotCompany/opencv_camera/workflows/CheckPackage/badge.svg)\n![GitHub](https://img.shields.io/github/license/MomsFriendlyRobotCompany/opencv_camera)\n[![Latest Version](https://img.shields.io/pypi/v/opencv_camera.svg)](https://pypi.python.org/pypi/opencv_camera/)\n[![image](https://img.shields.io/pypi/pyversions/opencv_camera.svg)](https://pypi.python.org/pypi/opencv_camera)\n[![image](https://img.shields.io/pypi/format/opencv_camera.svg)](https://pypi.python.org/pypi/opencv_camera)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/opencv_camera?color=aqua)\n\nSimple threaded camera and calibration code using OpenCV. This tries to simplify some things\n\n## Install\n\nThe preferred way to install is using `pip`:\n\n```\npip install opencv_camera\n```\n\n## Usage\n\nSee the jupyter notebooks under the `docs` in the repository for some examples.\n\nOnline [nbviewer](https://nbviewer.org/github/MomsFriendlyRobotCompany/opencv_camera/tree/master/docs/jupyter/)\n\n### Colorspace\n\nChange between common colorspaces with:\n\n- `bgr2gray(image)`\n- `gray2bgr(image)`\n- `bgr2rgb(image)`\n- `rgb2bgr(image)`\n- `bgr2hsv(image)`\n- `hsv2bgr(image)`\n\n### Calibration\n\nCreate a mosaic of input calibration images with `mosaic(images, width)`\n\n![](https://github.com/MomsFriendlyRobotCompany/opencv_camera/blob/master/pics/mosaic.png?raw=true)\n\nCalibrate a camera with:\n\n```python\ncalibrator = CameraCalibration()\nboard = ChessboardFinder((9,6), 1)\ncam, cal = calibrator.calibrate(images, board)\n```\n\nDisplay all of the found image points with `coverage((width, height), imagePoints)`\n\n![](https://github.com/MomsFriendlyRobotCompany/opencv_camera/blob/master/pics/target-points.png?raw=true)\n\n### Distortion\n\nUse the found calibration parameters to undistort an image:\n\n```python\nun = UnDistort(cameraMatrix, distortionCoeff, w, h)\ncorr_img = un.undistort(image)\n```\n\nVisualize the lens distortion with:\n\n```python\nvisualizeDistortion(cameraMatrix, distortCoeff, height, width)\n```\n\n![](https://github.com/MomsFriendlyRobotCompany/opencv_camera/blob/master/pics/py-dist.png?raw=true)\n\n### Stereo\n\nCalibrate a stereo camera with:\n\n```python\nstereoCal = StereoCalibration()\nboard = ChessboardFinder((9,6), 1)\nok, cm, sc = stereoCal.calibrate(imgL, imgR, board)\n```\n\nDraw epipolar lines in stereo images with `drawEpipolarLines(imgpointsL,imgpointsR,imgL,imgR)`\n\n![](https://github.com/MomsFriendlyRobotCompany/opencv_camera/blob/master/pics/epipolar.png?raw=true)\n\n## Apps\n\nUse `program --help` to display switches for each of the following:\n\n- `opencv_calibrate`: calibrate a camera\n- `opencv_capture`: simple tool to capture and save images\n- `opencv_mjpeg`: sets up a simple jmpeg server so you can view images in a web browser\n- `udp_server x.x.x.x`: sends camera images via UDP\n- `udp_client x.x.x.x`: displays UDP camera images from server\n\n# ToDo\n\n- [x] Remoded `apriltag` calibration, moved to `moms_apriltag` library\n- [ ] Add pointcloud from stereo\n- [x] Add parameters for known cameras\n- [x] Add Jupyter notebook documentation and examples\n- [x] Simplify stereo camera\n- [x] Add `computeReprojectionErrors` and `visualizeReprojErrors`\n- [x] Add `visualizeDistortion`\n- [ ] Add `visualizeExtrinsics`\n- [x] Remove `attrs`, replaced with python's `dataclass`\n- [x] Add save/load from `yaml`\n- [x] Add stereo calibration `pytest`\n\n# Change Log\n\n| Date       | Version    | Notes                                     |\n|------------|------------|-------------------------------------------|\n|            | 2022.12.23 | changed version number to match date, changed to `opencv-contrib-python` |\n| 2020-12-27 | 0.10.10 | added distortion and reprojection display |\n| 2020-09-15 | 0.10.8 | added known camera params and general cleanup |\n| 2020-08-24 | 0.10.6 | added UDP image server and client |\n| 2020-07-03 | 0.10.2 | renamed and focused on camera |\n| 2018-07-19 |  0.9.4 | simple clean-up and updating some things |\n| 2017-10-29 |  0.9.3 | bug fixes |\n| 2017-04-09 |  0.9.0 | initial python 3 support |\n| 2017-03-31 |  0.7.0 | refactored and got rid of things I do not need |\n| 2017-01-29 |  0.6.0 | added video capture (video and images) program |\n| 2016-12-30 |  0.5.3 | typo fix |\n| 2016-12-30 |  0.5.1 | refactored |\n| 2016-12-11 |  0.5.0 | published to PyPi |\n| 2014-3-11  |  0.2.0 | started |\n\n# MIT License\n\n**Copyright (c) 2014 Kevin J. Walchko**\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "An OpenCV camera library",
    "version": "2023.1.7",
    "split_keywords": [
        "computer vision",
        "camera",
        "calibration",
        "opencv",
        "jupyter",
        "stereo camera",
        "cv",
        "cv2"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b2626fd3aaaf37684c7de828d4426d99e8c096df51c949c1c3ffe534b20f863b",
                "md5": "f68ff72a9ef654e72c78a4da212eafdd",
                "sha256": "31c0be953eaa0ff20b12058e791e8fdbf3387279a9f2597e8504626ef65f6876"
            },
            "downloads": -1,
            "filename": "opencv_camera-2023.1.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f68ff72a9ef654e72c78a4da212eafdd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 40800,
            "upload_time": "2023-01-07T19:42:38",
            "upload_time_iso_8601": "2023-01-07T19:42:38.925854Z",
            "url": "https://files.pythonhosted.org/packages/b2/62/6fd3aaaf37684c7de828d4426d99e8c096df51c949c1c3ffe534b20f863b/opencv_camera-2023.1.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d84d5f4ab565c6baca4efb0703ebe34d32f223cc629e9d3fa9d584e0b9fc8223",
                "md5": "c1897eb528b2a45a8ff07b1b06efe48e",
                "sha256": "92b2aa6e8e12b85974dc0d5cd085aed850a2d1929bcce674a5d6c1f5a773eda5"
            },
            "downloads": -1,
            "filename": "opencv_camera-2023.1.7.tar.gz",
            "has_sig": false,
            "md5_digest": "c1897eb528b2a45a8ff07b1b06efe48e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 28342,
            "upload_time": "2023-01-07T19:42:40",
            "upload_time_iso_8601": "2023-01-07T19:42:40.386092Z",
            "url": "https://files.pythonhosted.org/packages/d8/4d/5f4ab565c6baca4efb0703ebe34d32f223cc629e9d3fa9d584e0b9fc8223/opencv_camera-2023.1.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-07 19:42:40",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "opencv-camera"
}
        
Elapsed time: 0.03426s