Coder Social home page Coder Social logo

multicamera-calibration's Introduction

Multi Camera Calibration Suite

This toolset provides the basics for calibrating a multi-camera scene. it contains six utilities for different purposes. In this README I will walk the user through the calibration of a multi camera scene using this toolset.

Dependencies

the use of this suite requires

Getting the source

clone the repository using :

git clone [email protected]:idiap/multicamera-calibration.git

Building the source

Go to the source directory

Do

mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make

Compute intrinsic camera parameters

The intrinsic camera parameters are usually computed finding a known grid with multiple poses on different images. To do so we propose the following method.

Capture a video by waving the camera over a grid such as this one or that one. Extract then the frames as images in a folder then run the software bin\intrinsic

intrinsic [-h] [-n NUM] [-W WIDTH] [-H HEIGHT]
          [-p {chessboard,circles,asymmetric_circles}] [-o FULL_OUTPUT]
          [-s SELECT_OUTPUT]
          input output

          -h:     show help
          -n:     number of frames to use
          -w:     width of grid
          -h:     height of grid
          -p:     type of grid
          -o:     output for all frames with a visible grid (optionnal)
          -s:     output for all n frames (option -n) selected for the calibration computation (optionnal)
          input:  pattern for the images
          output: calibration file (json format)

For example: let's imagine we have the frames in the folder /home/user1/camera1/frames with the asymmetric circles grid provided earlier.

you would use the script this way

bin/intrinsic -o /home/user1/frames_with_grid -s /home/user1/camera1/selected_frames_with_grid /home/user1/camera1/frames/\*.bmp /home/user1/camera1/intrinsic.json

once the computation is done, the undistorted frames are shown.

  • 'n' goes to next frame
  • 'p' goes to previous frame
  • 'q' quits

this produces the folders with the usable frames and the selected frames so that reproducing the calibration takes less time.

Compute extrinsic camera parameters

The extrinsic parameters are computed by clicking on points with known coordinates (in cm) in an image. The syntax is the following.

extrinsic [-h] [-p POINTS] [-o OUTPUT_POINTS] intrinsic input output

          -h:        show help
          -p:        saved points file, used to resume or correct the calibration (optionnal)
          -o:        output point file. this file will be used with the -p option (optionnal)
          intrinsic: intrinsic camera parameters
          input:     image to annotate
          output:    calibration output

Now using the intrinsic.json file we computed on the previous step, do.

bin/extrinsic /home/user1/camera1/intrinsic.json /home/user1/camera1/video_frames/000000.bmp /home/user1/camera1/extrinsic.json

it shows an the frame 000000.bmp you can left click on a point to add it. it will ask for x and y in cm. right click removes last point.

  • 'q' quits without saving
  • 's' computes the extrinsics and saves

Verify the 3d projections in the scene

Now both the intrinsic and extrinsic calibrations have been computed for cameras 1 to 4 to check the correspondance between the cameras, you can use the following utility

check3d [-h] intrinsic extrinsic images cameras
        -h: help
        intrinsic: pattern to intrinsic calibrations files
        extrinsic: pattern to extrinsic calibrations files
        images:    pattern to camera images (same frame for each camera)
        cameras:   camera list comma separated

using all our cameras calibrated, we would go to something like that

bin/check3d /home/user1/{}/intrinsic.json /home/user1/{}/extrinsic.json /home/user1/{}/video_frames/000000.bmp camera1,camera2,camera3,camera4

once the soft launched you get an image from the frame list. you can click on a point in some views, it will appear as a blue dot. once you clicked at least two views you get a red dot representing the projection on the other views. left click removes the blue dot. if you clicked wrong, a right click moves the blue dot to the new location.

  • pressing 'n' goes to the next image
  • pressing 'p' goes to the previous image
  • pressing 'r' resets the points
  • pressing 'q' quits the soft

Perform the bundle adjustment

to perform the bundle adjustment you need to provide annotations in the .pos format the pos format has one file per frame such as /home/user1/camera1/annotations/000000.pos is the annotation for the /home/user1/camera1/video_frames/000000.bmp image.

the pos format is done as such:

identity_name_1
0 x_val y_val
1 x_val y_val

identity_name_2
0 x_val y_val
1 x_val y_val

point number 0 corresponds to feet, 1 to head. point numbers can be sparse and identities don't have to exist on each frame

once some frames are annotated, run

build_ba [-h] [-f FIXED_POINTS]
         intrinsic extrinsic observations cameras output

         -h:           help
         -f:           pattern to known points that must remain at the same place 
                       i.e. points outputed by the -o option in extrinsic calibration (optionnal)
         intrinsic:    pattern to intrinsic calibrations files
         extrinsic:    pattern to extrinsic calibrations files
         observations: pattern to pos files
         cameras:      camera list comma separated
         output:       bundle adjustment problem file
bin/build_ba -f /home/user1/{}/points.json /home/user1/{}/intrinsic.json /home/user1/{}/extrinsic.json /home/user1/{}/annotations/\*.pos /home/user1/ba_problem.txt

then run the bundle adjustment

bundle_adjuster --input=input --output=output --intrinsic_adjustment=[fixed, unconstrained, two_pass]
                --input:                bundle adjustment problem file
                --output:               bundle adjustment problem file, post processing
                --intrinsic_adjustment: type of adjustment to perform

there are three types of adjustment

  • fixed: the intrinsics are fixed, only perform on the extrinsics
  • unconstrained: adjust all parameters
  • two_pass: run once fixed and then unconstrained

using our example, run

bin/bundle_adjuster --input=/home/user1/ba_problem.txt --output=/home/user1/processed_ba.txt

then we need to convert back the bundle adjustment problem file to camera calibrations

extract_ba [-h] input intrinsic extrinsic cameras
           -h:        help
           input:     bundle adjustment problem file
           intrinsic: output to intrinsic calibration file
           extrinsic: output to extrinsic calibration file
           cameras:   camera list comma separated

In our example it translates to

bin/extract_ba /home/user1/processed_ba.txt /home/user1/{}/intrinsic_ba.json /home/user1/{}/extrinsic_ba.json camera1,camera2,camera3,camera4

then you may check again the projections in 3d like seen previously

bin/check3d /home/user1/{}/intrinsic_ba.json /home/user1/{}/extrinsic_ba.json /home/user1/{}/video_frames/000000.bmp camera1,camera2,camera3,camera4

multicamera-calibration's People

Contributors

salimkayal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

multicamera-calibration's Issues

Running the build_ba

Hi,
l'm learning your code.
I need a .pos file to launch the build_ba script,but I don't understand the instructions of the file.Can you tell me what this file is?What is 'feet'?What is 'head'?

The setup for bundle adjustment is a bit unclear

Hi,
Great mini-library, I wanted to teach others using your code base.
After "perform the bundle adjustment" section, it seems to be unclear to me.
I have 3 cameras setup, lets say starting at 0 degrees, 45 degrees, and 90 degrees (quarter circle) facing inwards. I take 40 images between all of the cameras; some grid points can be seen by only 2 cameras at a time.

Using a checkerboard with a known grid, what annotations do I need to provide for build_ba.py?
The input to build_ba.py along with the functions build_3d_points and write_ba_problem does not seem to be all that clear to me.

After performing the bundle adjustment, does extract_ba.py provide the transformations between each camera or all cameras to a single camera considered to be the origin? What I am looking for is the transformations between cameras.

Thank you.

fixed_point file

Now I'm using build_ba without fixed_point and I want to test fixed_point to use build_ba

But I don't know the input of point.json file

Could you explain more of this file or can I get example of point.json?

Annotations file required to perform the bundle adjustment

To perform the bundle adjustment we need to provide annotations in the .pos format the pos format has one file per frame. Could you please explain what exactly this file requires? Is it the image (x,y) coordinates or the world (x,y) coordinates?

Running the calibration

Hi there,

I am currently trying to run the intrinsic calibration for a dataset of 40 images of a checkerboard with squares of 25mm by 25mm. The directory that these images are in is /home/images/. I tried to run the intrinsic calibration using the following command:

bin/intrinsic -p chessboard -n 40 -W 25 -H 25 /home/images/*.png /home/images/intrinsic.json

But this is throwing the error:

[ INFO:0] Initialize OpenCL runtime...
Traceback (most recent call last):
File "bin/intrinsic", line 173, in
main()
File "bin/intrinsic", line 121, in main
images, image_points = filter_images(opts.input, opts.pattern, opts.width, opts.height)
File "bin/intrinsic", line 72, in filter_images
ret, interest_points = cv2.findChessboardCorners(gray, (width, height), None)
TypeError: an integer is required

Is anyone able to explain where I have gone wrong?

Cheers,
Gerard

Running the intrinsic calibration

Thanks for the uploading of this useful code. While something goes wrong when I run the intrinsic calibration. My command is:
bin/intrinsic -p chessboard -n 15 -W 25 -H 25 /home/usr1/CalibImg/ImageChessBoard4/left/*.bmp /home/usr1/CalibImg/ImageChessBoard4/left/intrinsic.json
Then the terminal shows:
Traceback (most recent call last):
File "bin/intrinsic", line 178, in
main()
File "bin/intrinsic", line 128, in main
selected_indices = select_images(image_points, opts.num)
File "bin/intrinsic", line 104, in select_images
imgpoint = image_points[imlist[-1]]
IndexError: list index out of range
Could I ask how to fix it?

How to run the extrinsic calibration

When I execute the extrinsic calibration, I click the point and the question that request the x coordinate appears. I then input an integer, but Nothing happens...

How could I run the extrinsic calibration?

how to run extrinsics calibration

Hi,
I have 2 cameras with known intrinsic parameters and a chessboard. How should I compute extrinsic parameters between 2 cameras using the source code?
Thanks

Error when building the project (libgomp.so.1)

Hi. I'm trying to build the project, but run into error when calling 'make'. This is the output:

[ 33%] Linking CXX executable ../bin/bundle_adjuster /usr/bin/x86_64-linux-gnu-ld: CMakeFiles/bundle_adjuster.dir/main.cpp.o: undefined reference to symbol 'omp_get_max_threads@@OMP_1.0' //usr/lib/x86_64-linux-gnu/libgomp.so.1: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status src/CMakeFiles/bundle_adjuster.dir/build.make:139: recipe for target 'bin/bundle_adjuster' failed make[2]: *** [bin/bundle_adjuster] Error 1 CMakeFiles/Makefile2:85: recipe for target 'src/CMakeFiles/bundle_adjuster.dir/all' failed make[1]: *** [src/CMakeFiles/bundle_adjuster.dir/all] Error 2 Makefile:129: recipe for target 'all' failed make: *** [all] Error 2

Can you help me out here? All of the dependencies installed fine.
After googling around, I suspect that libgomp1 does not get linked properly. What can I do about it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.