# Camera calibration

**URL:** <https://discourse.julialang.org/t/camera-calibration/31525>\
**Category:** Community\
**Tags:** question\
**Created:** [November 26, 2019, 11:18am UTC](https://discourse.julialang.org/t/camera-calibration/31525 "2019-11-26T11:18:37Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [November 26, 2019, 11:18am UTC](https://discourse.julialang.org/t/camera-calibration/31525/1 "2019-11-26T11:18:37Z")

</div>

I’m hoping to start a conversation about camera calibration and test how big the usage/interest is.

Do you need a camera calibration package in Julia?  
Do you know how to write such a package?

A lot of the basic pieces are already present in [CoordinateTransformations.jl](https://github.com/FugroRoames/CoordinateTransformations.jl). Automatically detecting, say, checkerboards could be done with [libcbdetect](https://github.com/ftdlyc/libcbdetect). Optimizing the intrinsic and extrinsic parameters could be done with one of the many options available to us in Julia. Or we could do it completely differently, see [here](https://github.com/FugroRoames/CoordinateTransformations.jl/issues/30#issuecomment-341002351), and [here](https://github.com/FugroRoames/CoordinateTransformations.jl/issues/33#issuecomment-353050582), and [here](https://nextjournal.com/avikpal/calibrating-camera-parameters).

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [November 26, 2019, 11:44am UTC](https://discourse.julialang.org/t/camera-calibration/31525/2 "2019-11-26T11:44:57Z")

</div>

I’d be interested in this. I’d especially like a [mean-variance analysis](https://www.researchgate.net/publication/3432305_Comparison_of_Methods_for_Estimating_the_Conversion_Gain_of_CMOS_Active_Pixel_Sensor) component of such a package.

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [November 26, 2019, 12:10pm UTC](https://discourse.julialang.org/t/camera-calibration/31525/3 "2019-11-26T12:10:36Z")

</div>

Wow, that would be awesome, to have you on board!

---

<div class="post-metadata">

**Author:** ![benelsen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/benelsen/32/1620_2.png) [@benelsen](https://discourse.julialang.org/u/benelsen)\
**Post date:** [November 26, 2019, 1:21pm UTC](https://discourse.julialang.org/t/camera-calibration/31525/4 "2019-11-26T13:21:27Z")

</div>

I haven’t really used it, but I think it could be helpful here: [ImageProjectiveGeometry.jl](https://github.com/peterkovesi/ImageProjectiveGeometry.jl)  
I discovered it after playing around with my own DLT solver and Optim to fine tune the solutions, which was mostly unsuccessful.

---

<div class="post-metadata">

**Author:** ![pontus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pontus/32/10438_2.png) [@pontus](https://discourse.julialang.org/u/pontus)\
**Post date:** [November 26, 2019, 1:52pm UTC](https://discourse.julialang.org/t/camera-calibration/31525/5 "2019-11-26T13:52:02Z")

</div>

I haven’t been active in this space for a few years, but was an avid amateur photog for a while. Regarding calibration, I jumped to color-spaces, but perhaps you want to go the geometry route, or both?  
For the color spaces, I have a full XRite system w/ a ColorMunki monitor and print colorimeter for generating icc profiles, and also color standard “swatches” that you include in the image captured (uh, hard to do that with stars and such though!).  
Here are a few links that may help, especially open-source tools or that highlight standards in this area: [https://www.argyllcms.com/](https://www.argyllcms.com/), and software built using that as a base: [https://displaycal.net/](https://displaycal.net/) this article lists 4 open-source tools: [Calibrate your Monitor with these Open Source Tools - LinuxLinks](https://www.linuxlinks.com/monitorcalibration/) hcfr: [hcfr download | SourceForge.net](https://sourceforge.net/projects/hcfr/)  
There’s also a host of tools for camera calibration to test for back/front-focusing (I used vintage and modern rangefinders, which could be a bit tetchy with focusing low f-stop high aperture lenses at times with perhaps only an inch of depth-of-field range when shot wide-open).  
Good luck!

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [November 26, 2019, 6:56pm UTC](https://discourse.julialang.org/t/camera-calibration/31525/6 "2019-11-26T18:56:26Z")

</div>

Cool stuff. I personally am most interested in the geometry kind of calibration, but all interest is great!

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [November 27, 2019, 4:58am UTC](https://discourse.julialang.org/t/camera-calibration/31525/7 "2019-11-27T04:58:56Z")

</div>

I think a good first step might be to separate between the camera model and the machinery of finding all the parameters. This way multiple implementations of this machinery can be implemented – and even used – in parallel. So how about I start with a basic `CameraModels` repo and we build on that?

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [November 27, 2019, 7:04am UTC](https://discourse.julialang.org/t/camera-calibration/31525/8 "2019-11-27T07:04:07Z")

</div>

OK, started it off with this:  
[https://github.com/yakir12/CameraModels.jl](https://github.com/yakir12/CameraModels.jl)

Please feel free to comment, contribute, or overwrite!

---

<div class="post-metadata">

**Author:** ![TsurHerman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tsurherman/32/1234_2.png) [@TsurHerman](https://discourse.julialang.org/u/TsurHerman)\
**Post date:** [November 27, 2019, 8:26am UTC](https://discourse.julialang.org/t/camera-calibration/31525/9 "2019-11-27T08:26:49Z")

</div>

Slightly off-topic … if using printed checkerboard for camera calibration, sub-pixel detection may not  
be sufficient, at least if you need _ **ultra-precise calibration** _.

We found out that iterating between camera calibration and whole bundle adjustment to re-asses further the location of the corers did the trick. That or use mechanical checkerboard.

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [November 27, 2019, 8:33am UTC](https://discourse.julialang.org/t/camera-calibration/31525/10 "2019-11-27T08:33:57Z")

</div>

he he he, awesome. So to clarify, iterating:

1. guess parameters
2. optimize
3. use optimized parameters as guesses for the next optimization

results in higher accuracy? Or do you do an additional step, like undistort the images using the intrinsic parameters, and _then_ detect the corners again?

Also, come on-board on the camera calibration train!!!

---

<div class="post-metadata">

**Author:** ![TsurHerman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tsurherman/32/1234_2.png) [@TsurHerman](https://discourse.julialang.org/u/TsurHerman)\
**Post date:** [November 27, 2019, 9:23am UTC](https://discourse.julialang.org/t/camera-calibration/31525/11 "2019-11-27T09:23:17Z")

</div>

Detected corers in sub-pixel accuracy is done only once, but the real-world position of the corners is iterated upon.

Full camera calibration flow is as follows:  
Phase 1:

1. detect corners and perform normal camera calibration assuming planar checkerboard. (openCV)

Phase 2:

1. given the detected corners the assumed real-world position of them, the distortion coefficients and the camera calibration.  
perform bundle adjustment keeping the camera calibration and distortion coefficients fixed. optimising the  
real-world location of the corners.

2. calibrate again using the optimised real-world corners. (using openCV)

repeat 1-2 several times optionally weighting outliers less based on the reprojection error.

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [November 27, 2019, 9:27am UTC](https://discourse.julialang.org/t/camera-calibration/31525/12 "2019-11-27T09:27:36Z")

</div>

Sounds cool. I hope to replace the OpenCV part of that with a Julia-version… See this for a first veryvery basic step:  
[https://github.com/yakir12/CameraModels.jl](https://github.com/yakir12/CameraModels.jl)

---

<div class="post-metadata">

**Author:** ![Evert\_Schippers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evert_schippers/32/12004_2.png) [@Evert\_Schippers](https://discourse.julialang.org/u/Evert_Schippers)\
**Post date:** [January 4, 2020, 2:18am UTC](https://discourse.julialang.org/t/camera-calibration/31525/13 "2020-01-04T02:18:32Z")

</div>

Very interested having this in julia, I endorse your “veryvery basic first step”, CameraModels.jl - happy to contribute and review. I have quite some (10y+) experience with camera calibration methods and robust parameter estimation.

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [January 4, 2020, 7:52am UTC](https://discourse.julialang.org/t/camera-calibration/31525/14 "2020-01-04T07:52:26Z")

</div>

That’s wonderful!!! Looking forward to it!

---

<div class="post-metadata">

**Author:** ![touste](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/touste/32/10758_2.png) [@touste](https://discourse.julialang.org/u/touste)\
**Post date:** [January 6, 2020, 2:32pm UTC](https://discourse.julialang.org/t/camera-calibration/31525/15 "2020-01-06T14:32:09Z")

</div>

Hi, I’m also interested in having this in Julia. As a user, I have tested multiple available packages in Matlab and OpenCV to calibrate stereo rigs, and I must say that the one giving the most accurate results is this one: [GitHub - justinblaber/camera\_calib\_matlab: Camera calibration with matlab](https://github.com/justinblaber/camera_calib)  
As it’s written in Matlab, perhaps it could be translated to Julia without too much hassle. Automatic differentiation should also make things easier.

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [January 6, 2020, 6:13pm UTC](https://discourse.julialang.org/t/camera-calibration/31525/16 "2020-01-06T18:13:06Z")

</div>

Wow, that camera\_calib looks monstrous! It does everything…

---

<div class="post-metadata">

**Author:** ![kevin.squire](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevin.squire/32/62_2.png) [@kevin.squire](https://discourse.julialang.org/u/kevin.squire)\
**Post date:** [January 18, 2020, 10:55pm UTC](https://discourse.julialang.org/t/camera-calibration/31525/17 "2020-01-18T22:55:09Z")

</div>

> [@touste](#):
>
> As it’s written in Matlab, perhaps it could be translated to Julia without too much hassle. Automatic differentiation should also make things easier.

Unfortunately, there’s no license, so whoever wants to translate it would need to get the permission of the author of that package and the packages that it is based off of.

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [September 1, 2020, 3:26pm UTC](https://discourse.julialang.org/t/camera-calibration/31525/18 "2020-09-01T15:26:42Z")

</div>

Hi good people!  
Not much has happened with camera calibration in Julia (that I know of – please correct me if I’m wrong!).

I’m still in need of a free and platform-agnostic solution for camera (spatial) calibration, so I thought I’d ask here: _what is everyone currently using…?_

I’ve been using Matlab’s camera calibration toolbox (both the Caltech one and the one shipped with Matlab) which is proprietary.

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [October 5, 2020, 11:55am UTC](https://discourse.julialang.org/t/camera-calibration/31525/19 "2020-10-05T11:55:01Z")

</div>

So not much of an update, but @touste did point out to me that in camera calibration there are two very different tasks in hand. It might be helpful to consider these as two separate goals, making the road to a camera calibration package in Julia clearer:

1. detecting the checkerboards corners.
2. optimizing the intrinsic and extrinsic parameters of the camera.

The first require image analysis while the latter doesn’t.

While we can’t have camera calibration without both of these two parts, getting one will facilitate the creation of the other.

Does anyone have any knowledge about how to code the corner detection algorithm suggested [here](http://bmvc2018.org/contents/papers/0508.pdf) by Duda and Frese? Or perhaps there is an alternative you might know of?

---

<div class="post-metadata">

**Author:** ![dehann](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dehann/32/2003_2.png) [@dehann](https://discourse.julialang.org/u/dehann)\
**Post date:** [September 21, 2021, 2:21pm UTC](https://discourse.julialang.org/t/camera-calibration/31525/20 "2021-09-21T14:21:54Z")

</div>

Hi All,

Just and FYI on camera work we’ve been doing over at JuliaRobotics:

- Calibration with tag fiducial markers: [Home · AprilTags.jl](https://juliarobotics.org/AprilTags.jl/latest/#Camera-Calibration-1)
  - As agnostic as possible, and consolidated with ImageDraw.jl features to understand whether calibration is working or not.

- Common Camera intrinsic models (registration TBD): [https://github.com/JuliaRobotics/CameraModels.jl](https://github.com/JuliaRobotics/CameraModels.jl)
- Sparse visual feature tracking (more TBD): [https://github.com/JuliaRobotics/SensorFeatureTracking.jl](https://github.com/JuliaRobotics/SensorFeatureTracking.jl)

Best,  
Dehann

[Next page](https://discourse.julialang.org/t/camera-calibration/31525.md?page=2)
