---
layout: default
title: Getting started with 3D-PTV
---
Getting started with 3D-PTV
How to calibrate
using a
single plane?
In
your “working
folder” or "test" folder there are three folders called
“img”,
“parameters”, and “res”.
We
are using the “Tu/e-Jet”
test data. First, few preparations:
- In
“Change parameters”->”Main parameters” for calibration you need
to adapt 5 fields: 1) Number of cameras=4, “Refractive inices”
2) air=1.33, 3) glass=1.33, 4) water=1.33, thickness of glass=1.
Yes, this is not very physical but there is a simple explanation:
The “Tu/e-jet” setup uses prismas
at the interface air water. The effect is that all the rays
towards the camera cross the water/air interface at a very
perpendicular angle. In the optical model we can treat this by
lying to the code and by pretending that the entire experiment,
including the cameras, is inside water.
- Copy
the file “a_plane.txt” containing the true coordinates of your
calibration plate into the “working folder”. It has 25 points
numbered from upper left to lower right. Plane “a” is 186mm away
from the glass interface.
- Copy
the calibration images “calib_<a>_cam<1-4>.tif”
into the folder “img”.
- Adjust
the some setting under “Change Parameters”->”Change Calibration
Parameters”, as shown in fig3.
You tell the program many things: Where it should look for the
calibration images, where it should look for the files with your
initial guess, where it should look where the points are located
in real world, how big the pictures are (pixel * pixel), how large
each pixel is, gray value threshold
and stuff for point detection, and which 4 of the 25 possible
calibration points you will manually click and thereby “teach” the
program where the cameras are. The fields “Calibrate with
different z-positions” and “Combine preprocessed
plane” are set to zero, because here we are doing single target
calibration.
- This
is an important and ‘easy to get wrong’ step: Provide the four
files with you initial guess of where the cameras are and how they
are oriented. The easy way is: copy the files cal<1-4>.ori
into the folder “working folder”. The
hard way is: Sit down and figure them out yourself or verify, why
cal<1-4>.ori
are as they are. The first row is the camera position. The second
row tells how the camera is rotated around x, y, and z-axis. Don’t
worry about the 3*3 matrix. Don’t worry about the second last row.
The last number is very important: it tells the ‘focal distance’.
How can it be guessed: In Our situation we have an ratio of “world
image” to “Chip image” of 500mm to 65mm (384 pixels mal
17microns), e.g. 1:8. The distance fro lens to calibration target
is about 800mm. Hence our focal distance is about 100mm. Don’t
continue if you don’t understand this step. The situation of the
setup is sketched in fig4.
See fig5
for an initial guess that works.
Now, we
come to the actual calibration:
- In
“Calibration” click “Show calib
images”.
- Then
click detection. You should get 25 detections for each image. If
you don’t detect all it is still ok. The only requirement is that
those points that are defined in “Point number for manual
pre-orientation” are detected.
- Click
“Manual orientation”. You are then asked to click each of the four
points of each image. Once you have successfully done this you can
check your clicks with the menu “Orientation with file”. It should
look like fig6. Again if you are confused at this step do not
continue, but think again or ask for help.
- To
give you a feedback how good or bad your initial guess is you can
use “Show initial guess”. The yellow dots show where the dots from
the calibration plane would end up on your images if the initial
guess would be correct.
- To
establish which detected point belongs to which calibration point
click “Sortgrid”. There is
little you can do, but to check that the outcome looks like fig7.
Four
files
have been produced “raw<1-4>.ori”
and they are
next to your initial guesses. Have a look at them. Thee first six
numbers are
changed, i.e. camera position and orientation have been adapted.
They will be
used as starting values for the actual calibration in the next step.
- Click
“Orientation”. If all goes well you should get something like in fig8. You will find 8 new files created next to your
calibration image files. There names are like your calibration
images, but with .ori and
.addpar appended. They
contain the calibration your final result.
How to calibrate
using
multiple planes?
Don’t
do
this before you have understood and done a single plane calibration.
Basically,
now you have to tell the code that you will do a multi plane
calibration and
then you perform one calibration per each plane plus a final
calibration that
combines it all.
- Under
“Change calibration parameters” set the field of “Calibrate with
different z-positions” to “1”.
- For
each plane you have to: 1) adjust image file names, adjust “File
of coordinates on Plate”, 2) perform sequence
of steps “Show calib. images”,
“Detection”, “Manual orientation” (use “Orientation with file” as
a hint) , Sortgrid, and Orientation.
- Usually
it is a good idea to restart the program after such a step.
You
will
see that after “Orientation” next to your calibration images 12 new
files have
been created. 4* .ori: never mind those.
4* .crd: they contain the metric image
coordinates of the
calibration dots for each camera. 4*.fix: they contain the
corresponding real
world coordinates of each image dot. The “crd”
and
“fix” files will be used of the program for the final step.
Now,
you
tell the program that it is about to perform the last step, a
combined
calibration where the dots of all calibration planes will be jointly
used.
- Create
or change a file in the folder “parameter” that is called “multi_planes.par”.
It defines 1) how many planes you use, and 2) what the base name
of each plane is. Please have a look at
fig9.
- In
“Change calibration parameter” you have to change the image file
names to something new, e.g. “img/calib_d_cam<1-4>.tif.
“d” is reflecting that now from the
previous planes a-c we will create a virtual target (fig9)
- Below
you have to set the flag “Combine preprocessed
planes?” to “1”, see fig9.
In addition you can check the fields “xp”
and “yp”. This allows for an image
center that is offset to the centre optical axis.
- In
addition you may choose to use more parameters for your
calibration like “k1”, “k2” etc. However, usually these parameters
don’t bring
lot of gain and sometime lead to a crash of the
operation “Orientation”.
- Restart
the program, click “Show calib.
images” and then immediately
“Orientation”.
If
all went
well you are done. You should see something like in fig10. Next to you
image
files 8 new files (4 .ori and 4
.addpar) have been created.
They contain your final
multi-plane calibration. You may choose to experiment with different
settings
of calibration parameters (k1, k2, etc..)
to further
improve the quality.