Skip to main content

Fast defisheye algorithm

Project description

Defisheye

Fast Corrects for fisheye distortion in an image.

Defisheye is designed to transform a fisheye image into a normal perspective view looking towards the center of the fisheye image.

Install

python setup.py install

or:

pip install defisheye

Usage

CLI

For individual Image

defisheye --image example/images/example3.jpg

Process all image in a folder

defisheye --images_folder example/images --save_dir example/Defisheye

Python Code

from defisheye import Defisheye

dtype = 'linear'
format = 'fullframe'
fov = 180
pfov = 120

img = "./images/example3.jpg"
img_out = f"./images/out/example3_{dtype}_{format}_{pfov}_{fov}.jpg"

obj = Defisheye(img, dtype=dtype, format=format, fov=fov, pfov=pfov)

# To save image locally 
obj.convert(outfile=img_out)

# To use the converted image in memory

new_image = obj.convert()

Parameter/ Atributes:

For CLI command, use "--" and the parameter to pass for the command line: Exemple

defisheye --images_folder example/images --save_dir example/Defisheye --fov 140

The default fov is 180, but now was changed by 140 from command line. Same rule for the following parameters.

fov

fisheye field of view (aperture) in degrees.

IFOV is the input fisheye image field of view in degrees. A value of 180 will correspond to a hemispherical fisheye image within the circular area. Values are floats in the range 0<ifov<=180. The default is 180 degrees for a full hemisphere.

pfov

perspective field of view (aperture) in degrees.

OFOV is the output perspective image field of view in degrees. Values are floats in the range 0<ofov<180. The default is to use 120 degrees both vertically and horizontally for a circular fisheye and diagonally for a full frame fisheye. The value for ofov relative to the ifov determines the proportional amount of the fisheye area that will be transformed. Note that in comparison, a value of 48.8 degrees corresponds to a diagonal field of view from a 35 mm camera (film size 36mm x 24mm) with a 50mm focal length lens, i.e. a "normal" view. Similarly, when the image diagonal is equal to the focal length of the camera, the field of view is about 53.1 degrees. Although the default value is perhaps not appropriate to a normal perspective image, this will produce an image that maximizes the area covered, but without too much distortion. If the original fisheye image was viewed obliquely, i.e. the camera was tilted between horizontal and vertical, then the resulting perspective view will have perspective distortion. That is vertical edges will be tilted outward or inward. Post processing with my 3Drotate or rotate3D script will then correct for this perspective distortion. Perspective distortion will be more pronounced with larger values for ofov.

dtype

linear, equalarea, orthographic, stereographic

TYPE is the type of fisheye lens. The choices are: linear (equidistant), equalarea (equisolid), orthographic and stereographic. The default is linear.

format

circular, fullframe

FORMAT is the format of the fisheye lens image. The choices are: circular (image fills a circle that spans the minimum of the width or height) or fullframe (image spans a circle that spans the diagonal dimension). The default is circular.

xcenter

x center of fisheye area

ycenter

y center of fisheye area

radius

radius of fisheye area

RADIUS is the radius of the fisheye circular area in the input image. Values are floats greater than zero. The default is half the minimum value between the input image width and height.

angle

image rotation in degrees clockwise

ANGLE is the clockwise positive rotation angle for the output perspective image relative to the orientation of the input fisheye image. Values are non-negative floats in range 0<=angle<360. The default is 0.

Example

Original Original

pfov = 120

Equal area Circular Equal Area

Equal area Fullframe Equal Area

Linear Circular Equal Area

Linear Fullframe Equal Area

orthographic Circular Equal Area

Stereographic Circular Equal Area

Extra

Developed by: E. S. Pereira. e-mail: pereira.somoza@gmail.com

Based in the work of F. Weinhaus. http://www.fmwconcepts.com/imagemagick/defisheye/index.php

Copyright [2019] [E. S. Pereira]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Project details


Download files

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

Source Distribution

defisheye-1.1.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distributions

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

defisheye-1.1.0-py3.9.egg (12.8 kB view details)

Uploaded Egg

defisheye-1.1.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file defisheye-1.1.0.tar.gz.

File metadata

  • Download URL: defisheye-1.1.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for defisheye-1.1.0.tar.gz
Algorithm Hash digest
SHA256 c6bd3476bfcf179b24028251042d5ffb57aa60c2c7f3fe83d36d87f46a163da0
MD5 5587a777fe629ffea2e343b537129052
BLAKE2b-256 fa5a13e417fadf98745ddf62ecafabefd9e632221288b45ea2b79beeb6945cd4

See more details on using hashes here.

File details

Details for the file defisheye-1.1.0-py3.9.egg.

File metadata

  • Download URL: defisheye-1.1.0-py3.9.egg
  • Upload date:
  • Size: 12.8 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for defisheye-1.1.0-py3.9.egg
Algorithm Hash digest
SHA256 2bac2bda51e90852182fc09d6c3d5de219861e900cfd8d68a66e5c01c7da7a51
MD5 6fa714ca6699a9307a6b4aedbc6d5e71
BLAKE2b-256 6f05025f729913b74352ce6b8a85457c0efed06db9aaae55e69276d0d0d24fec

See more details on using hashes here.

File details

Details for the file defisheye-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: defisheye-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for defisheye-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dd058c2e8ad3bc69102fad1138469ac0c03fde39250265d335bbcf908352c8db
MD5 d4d57b5ca97fa035f3e997de8f5a4dd8
BLAKE2b-256 7d26bafd046cb92a2111d7fcf54c9917eebdab6bffe93e40866e033219cd5720

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