-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcamera_calibrate.sh
executable file
·61 lines (45 loc) · 1.76 KB
/
camera_calibrate.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
set -eu
ASSEMBLY_TOOL_DIR=$(dirname "$(realpath $0)")
OBJ="charuco_7x10_id0-id500.json"
CALIB_UUID=$(cat /proc/sys/kernel/random/uuid | sed 's/[-]//g' | head -c 8)
CALIBRATION_FOLDER="/tmp/$CALIB_UUID"
# Update the permissions of the calibration folder to the current user
mkdir -p $CALIBRATION_FOLDER
chown $(id -u):$(id -g) $CALIBRATION_FOLDER
camera_tools()
{
docker run -it --rm --user="$(id -u):$(id -g)"\
--privileged \
-v /dev:/dev \
-v $CALIBRATION_FOLDER:/out/ \
--device-cgroup-rule "c 81:* rmw" \
--device-cgroup-rule "c 189:* rmw" \
bipedrobotics/camera_tools:latest \
-- "$@";
}
metrical() {
docker run --rm --init --user="$(id -u):$(id -g)" \
--volume="$CALIBRATION_FOLDER:/$CALIB_UUID" \
--workdir="/$CALIB_UUID" \
--net=host \
tangramvision/cli:11.0.0 \
--license="key/$TANGRAM_KEY" \
"$@";
}
camera_tools --mode calibrate -o /out/$CALIB_UUID
cp $ASSEMBLY_TOOL_DIR/assets/$OBJ $CALIBRATION_FOLDER
_INIT_PLEX_FILE="tmp_plex.json"
_UMBRA_OUTPUT="umbra_$CALIB_UUID.json"
metrical init \
--topic-to-model *:opencv_radtan \
--preset-device RealSense435:[cam_right_left_ir,cam_right_right_ir,_] \
--preset-device RealSense435:[cam_middle_left_ir,cam_middle_right_ir,_] \
--preset-device RealSense435:[cam_left_left_ir,cam_left_right_ir,_] \
$CALIB_UUID $_INIT_PLEX_FILE
echo "Computing calibration"
metrical calibrate --interactive --disable-filter $CALIB_UUID $_INIT_PLEX_FILE $OBJ --output-json $_UMBRA_OUTPUT
echo "Generating the calibration table"
jq .plex "$CALIBRATION_FOLDER/$_UMBRA_OUTPUT" > "$CALIBRATION_FOLDER/calib_table.json"
mv $CALIBRATION_FOLDER/$CALIB_UUID/camera_position_to_camera_serial.json $CALIBRATION_FOLDER
camera_tools --mode flash_calibration -i /out