{"id":20371318,"url":"https://github.com/elcorto/unfish","last_synced_at":"2025-04-12T06:24:11.150Z","repository":{"id":62592585,"uuid":"100411909","full_name":"elcorto/unfish","owner":"elcorto","description":"Correct fisheye distortions in images using OpenCV","archived":false,"fork":false,"pushed_at":"2019-10-03T13:34:02.000Z","size":199,"stargazers_count":30,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-26T01:51:06.103Z","etag":null,"topics":["fisheye","fisheye-lens-distortion","fisheye-undistorting","image-processing","opencv"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elcorto.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-15T19:36:23.000Z","updated_at":"2024-09-23T11:45:46.000Z","dependencies_parsed_at":"2022-11-03T23:00:35.289Z","dependency_job_id":null,"html_url":"https://github.com/elcorto/unfish","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elcorto%2Funfish","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elcorto%2Funfish/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elcorto%2Funfish/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elcorto%2Funfish/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elcorto","download_url":"https://codeload.github.com/elcorto/unfish/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248526248,"owners_count":21118848,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fisheye","fisheye-lens-distortion","fisheye-undistorting","image-processing","opencv"],"created_at":"2024-11-15T01:07:25.829Z","updated_at":"2025-04-12T06:24:11.118Z","avatar_url":"https://github.com/elcorto.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"unfish -- correct fisheye distortions in images using OpenCV\n\nabout\n-----\nThis is basically a packaged and polished version of the OpenCV tutorial_ (see\nalso hack_) with a command line interface. It shows how to correct lens\ndistortions in images using OpenCV, based on chessboard calibration images\ntaken with the same camera.\n\nIn my case, my mobile phone camera introduces a radial distortion (inverse\nfisheye effect), hence the name.\n\nHere is an example of a distorted and corrected image.\n\n.. image:: examples/fish.jpg\n   :width: 40%\n\n.. image:: examples/unfish.jpg\n   :width: 40%\n\nThe script ``bin/unfish`` does all this and a little more::\n\n    usage:\n        unfish prep [-f \u003cfraction\u003e] (-p \u003cpattern-size\u003e \u003cfiles\u003e...)\n        unfish calib [-r \u003cmax-rms\u003e -f \u003cfraction\u003e] (-p \u003cpattern-size\u003e \u003cfiles\u003e...)\n        unfish apply [-k \u003ckeep-path-levels\u003e] \u003cfiles\u003e...\n\n    commands:\n        prep   optional preparation run, create rms_db.json\n        calib  calibration run, calculate and write camera matrix and camera model\n               coeffs using chessboard calibration images to ./unfish_data\n        apply  apply correction model to images, images are written to\n               ./corrected_images\n\n    options:\n        -p \u003cpattern-size\u003e, --pattern-size \u003cpattern-size\u003e  size of the chessboard\n                (number of corners) in the calibration images, e.g. \"9x6\"\n        -f \u003cfraction\u003e, --fraction \u003cfraction\u003e  fraction by which calibration files\n                have been scaled down (see bin/resize.sh)\n        -r \u003cmax-rms\u003e, --max-rms \u003cmax-rms\u003e  in calibration, use only files with\n                rms reprojection error less than \u003cmax-rms\u003e, uses rms_db.json\n                written by \"prep\"\n        -k \u003ckeep-path-levels\u003e  keep that many path levels from \u003cfiles\u003e, e.g.\n                files = /a/b/c/file1,/a/b/c/file2, and -k2, then store\n                ./corrected_images/a/b/fileX instead of ./corrected_images/fileX  [default: 0]\n\nIn addition to the tutorial_, we added things like the ability to calculate the\nRMS reprojection error per calibration image (``unfish prep``), in order to get\na feeling for the quality of the calibration per image.\n\nworkflow\n--------\n\nFirst, you print a chessboard and take a bunch of calibration images with the\naffected camera, like this one:\n\n.. image:: examples/calib_pattern.jpg\n   :width: 40%\n\nNext, a calibration run will calculate correction parameters (camera matrix and\nlens model coefficients, written to ``./unfish_data/``). Finally, you apply the\ncorrection to all affected images. Corrected images are written to\n``./corrected_images``.\n\nWe found that it is a very good idea to scale down the chessboard calibration\nimages first. That makes the calibration part *a lot* faster (else the code\nwhich searches for chessboard corners will run forever).\n\nHere is what you need to do, using a 9x6 chessboard.\n\n::\n\n    $ ./bin/resize.sh 0.2 chess_pics/orig chess_pics/small\n    $ unfish calib -f 0.2 -p 9x6 chess_pics/small/*\n    $ unfish apply affected_pics/orig/*\n\ntips \u0026 tricks\n-------------\n\nchessboard\n    You can grab a 7x7 chessboard image from the `OpenCV repo \u003cchessboard_\u003e`_,\n    or a 9x6 from `older documentation \u003cchessboard_old_\u003e`_. Remember: NxM are\n    the number of *corners*. It's hard to say how many calibration images you\n    need to take. We used around 100, but found that 5-10 good images have\n    basically the same effect. Also, make sure that the paper with the printed\n    chessboard is completely flat when you take photos.\n\n``\u003cmax-rms\u003e``\n    We found that excluding calibration images with a high per-image RMS\n    reprojection error (``unfish calib -r \u003cmax-rms\u003e ...``) doesn't actually\n    improve the overall calibration, not sure why yet.\n\n.. _tutorial: http://docs.opencv.org/3.3.0/dc/dbb/tutorial_py_calibration.html\n.. _hack: https://hackaday.io/project/12384-autofan-automated-control-of-air-flow/log/41862-correcting-for-lens-distortions\n.. _chessboard: https://github.com/opencv/opencv/blob/master/samples/data/chessboard.png\n.. _chessboard_old: http://docs.opencv.org/2.4/_downloads/pattern.png\n\ninstall\n-------\nTo let pip install all deps for you::\n\n    $ git clone ...\n    $ pip3 install -e .\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felcorto%2Funfish","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felcorto%2Funfish","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felcorto%2Funfish/lists"}