calib3d


Namecalib3d JSON
Version 2.10.1 PyPI version JSON
download
home_pagehttps://github.com/ispgroupucl/calib3d
SummaryPython 3D calibration and homogenous coordinates computation library
upload_time2023-12-15 10:22:53
maintainer
docs_urlNone
authorGabriel Van Zandycke
requires_python>=3.6
licenseLGPL
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python camera calibration and projective geometry library

This library offers several tools for manipulation of calibrated cameras, projective geometry and computations using homogenous coordinates.

Camera calibration allows to determine the relation between the camera's pixels (2D coordinates) and points in the real world
(3D coordinates). It implies computation using homogenous coordinates. This python library aims at simplifying implementations
of projective geometry computations, building on top of `numpy` and `cv2`.


## Installation

Installation using the package manager pip

```shell
pip install calib3d
```

## Usage

Full API documentation is available in [here](https://ispgroupucl.github.io/calib3d).


### 2D and 3D points implementation

The `Point2D` (and `Point3D`) class represent 2D (and 3D) points extending `numpy.ndarray`. Access to y coordinate of `point` is `point.y`, and access to homogenous coordinates is made easy with `point.H`, while it is still possible to use `point` with any `numpy` operators.

```python
>>> Point2D(1,2) == Point2D(2,4,2)
True

>>> points = Point2D(np.array([[0, 0, 1, 2, 3],   # x coordinates
                               [1, 2, 3, 4, 5]])) # y coordinates
>>> points.x
array([0., 0., 1., 2., 3.])

>>> points.H
array([[0., 0., 1., 2., 3.],
       [1., 2., 3., 4., 5.],
       [1., 1., 1., 1., 1.]])
```


### Camera calibration

The `Calib` class represents a calibrated camera. It has a serie of methods to handle 3D to 2D projections, 2D to 3D liftings, image transformations, and more.

```python
>>> import numpy as np
>>> from calib3d import Calib, Point3D, compute_rotation_matrix
>>> f = 0.035                                      # lens focal length [m]      35 mm lens
>>> w, h = np.array([4000, 3000])                  # sensor size       [px.px]  12 Mpx sensor
>>> d = w/0.01                                     # pixel density     [px.m⁻¹] with a 1 cm sensor width
>>> K = np.array([[ d*f,  0 , w/2 ],               # Camera matrix (intrinsic parameters)
...               [  0 , d*f, h/2 ],
...               [  0 ,  0 ,  1  ]])
>>> C = Point3D(10,10,10)                          # Camera position in the 3D space
>>> R = compute_rotation_matrix(Point3D(0,0,0), C) # Camera pointing towards origin
>>> calib = Calib(K=K, T=-R@C, R=R, width=w, height=h)
>>> calib.project_3D_to_2D(Point3D(0,0,0))
Point2D([[2000.],
         [1500.]])
```

Cropping or scaling a calib is made easy with the following operations (for more operations, check the documentation)
```python
>>> new_calib = calib.crop(x_slice=slice(10, 110, None), y_slice=slice(500, 600, None))
>>> new_calib = calib.scale(output_width=2000, output_height=1500)
```

Other useful methods
```python
>>> calib.projects_in(Point3D(0, 20, 20))
False

>>> calib.compute_length2D(Point3D(0, 0, 0), .42)  # Number of pixels that represent a length of .42 in the 3D space
array([339.48195828])
```


## Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

## Authors

This library is developed and maintained by [Gabriel Van Zandycke](https://github.com/gabriel-vanzandycke). If you use this repository, please consider citing my work.
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ispgroupucl/calib3d",
    "name": "calib3d",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "Gabriel Van Zandycke",
    "author_email": "gabriel.vanzandycke@hotmail.com",
    "download_url": "https://files.pythonhosted.org/packages/91/c6/cdbc606f58470195588f84e261418a1686b9c447136664e0bdff33ebdee3/calib3d-2.10.1.tar.gz",
    "platform": null,
    "description": "# Python camera calibration and projective geometry library\n\nThis library offers several tools for manipulation of calibrated cameras, projective geometry and computations using homogenous coordinates.\n\nCamera calibration allows to determine the relation between the camera's pixels (2D coordinates) and points in the real world\n(3D coordinates). It implies computation using homogenous coordinates. This python library aims at simplifying implementations\nof projective geometry computations, building on top of `numpy` and `cv2`.\n\n\n## Installation\n\nInstallation using the package manager pip\n\n```shell\npip install calib3d\n```\n\n## Usage\n\nFull API documentation is available in [here](https://ispgroupucl.github.io/calib3d).\n\n\n### 2D and 3D points implementation\n\nThe `Point2D` (and `Point3D`) class represent 2D (and 3D) points extending `numpy.ndarray`. Access to y coordinate of `point` is `point.y`, and access to homogenous coordinates is made easy with `point.H`, while it is still possible to use `point` with any `numpy` operators.\n\n```python\n>>> Point2D(1,2) == Point2D(2,4,2)\nTrue\n\n>>> points = Point2D(np.array([[0, 0, 1, 2, 3],   # x coordinates\n                               [1, 2, 3, 4, 5]])) # y coordinates\n>>> points.x\narray([0., 0., 1., 2., 3.])\n\n>>> points.H\narray([[0., 0., 1., 2., 3.],\n       [1., 2., 3., 4., 5.],\n       [1., 1., 1., 1., 1.]])\n```\n\n\n### Camera calibration\n\nThe `Calib` class represents a calibrated camera. It has a serie of methods to handle 3D to 2D projections, 2D to 3D liftings, image transformations, and more.\n\n```python\n>>> import numpy as np\n>>> from calib3d import Calib, Point3D, compute_rotation_matrix\n>>> f = 0.035                                      # lens focal length [m]      35 mm lens\n>>> w, h = np.array([4000, 3000])                  # sensor size       [px.px]  12 Mpx sensor\n>>> d = w/0.01                                     # pixel density     [px.m\u207b\u00b9] with a 1 cm sensor width\n>>> K = np.array([[ d*f,  0 , w/2 ],               # Camera matrix (intrinsic parameters)\n...               [  0 , d*f, h/2 ],\n...               [  0 ,  0 ,  1  ]])\n>>> C = Point3D(10,10,10)                          # Camera position in the 3D space\n>>> R = compute_rotation_matrix(Point3D(0,0,0), C) # Camera pointing towards origin\n>>> calib = Calib(K=K, T=-R@C, R=R, width=w, height=h)\n>>> calib.project_3D_to_2D(Point3D(0,0,0))\nPoint2D([[2000.],\n         [1500.]])\n```\n\nCropping or scaling a calib is made easy with the following operations (for more operations, check the documentation)\n```python\n>>> new_calib = calib.crop(x_slice=slice(10, 110, None), y_slice=slice(500, 600, None))\n>>> new_calib = calib.scale(output_width=2000, output_height=1500)\n```\n\nOther useful methods\n```python\n>>> calib.projects_in(Point3D(0, 20, 20))\nFalse\n\n>>> calib.compute_length2D(Point3D(0, 0, 0), .42)  # Number of pixels that represent a length of .42 in the 3D space\narray([339.48195828])\n```\n\n\n## Contributing\n\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\n## Authors\n\nThis library is developed and maintained by [Gabriel Van Zandycke](https://github.com/gabriel-vanzandycke). If you use this repository, please consider citing my work.",
    "bugtrack_url": null,
    "license": "LGPL",
    "summary": "Python 3D calibration and homogenous coordinates computation library",
    "version": "2.10.1",
    "project_urls": {
        "Homepage": "https://github.com/ispgroupucl/calib3d"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "91c6cdbc606f58470195588f84e261418a1686b9c447136664e0bdff33ebdee3",
                "md5": "bda2cf876c58557bef243c9b38591a8d",
                "sha256": "c554765d71df06d2ccc52951fe8279f37ac0bd0a7488a36e217e0fde6baca455"
            },
            "downloads": -1,
            "filename": "calib3d-2.10.1.tar.gz",
            "has_sig": false,
            "md5_digest": "bda2cf876c58557bef243c9b38591a8d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 113304,
            "upload_time": "2023-12-15T10:22:53",
            "upload_time_iso_8601": "2023-12-15T10:22:53.975632Z",
            "url": "https://files.pythonhosted.org/packages/91/c6/cdbc606f58470195588f84e261418a1686b9c447136664e0bdff33ebdee3/calib3d-2.10.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-15 10:22:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ispgroupucl",
    "github_project": "calib3d",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "calib3d"
}
        
Elapsed time: 0.17998s