์๋ ํ์ธ์, ๋จผ์ Q&A ํ์ด์ง์ ์ง๋ฌธ์ ํ๊ณ ์ถ์๋ฐ ๋ค์ด๋์ด ์ฌ๊ธฐ์ ๋จผ์ ๊ธ์ ์ฌ๋ฆฝ๋๋ค.
์นด๋ฉ๋ผ ๋ณด์ ์ ๋ํด ์ฃผ์ด์ง C++ ์์ต์๋ฅผ ์คํํ ๋ Windows(3.1.0 ๋ฐ์ด๋๋ฆฌ) ๋ฐ Linux(๊ธฐ๋ณธ Ubuntu 14.04์์ github repo์ ์ต์ ํด๋ก ) ๋ชจ๋์์ ๋ค์ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค. ์ํ ๋ฐ์ดํฐ์์ ์ฌ์ฉํ ์ ์๋ ๋ณด์ ์ด๋ฏธ์ง๋ฅผ ์ฌ์ฉํ์ต๋๋ค. ๋์ผํ ์ด๋ฏธ์ง๋ฅผ ์ฌ์ฉํ๊ณ ๋์ผํ ์ค์ ์ ์๋ ํ ์ ์ฌํ Python ์์ต์( $OPENCV_DIR/samples/python/calibrate.py
)๋ฅผ ์ฌ์ฉํ ๋ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ง ์์์ต๋๋ค.
์นด๋ฉ๋ผ ๋ณด์ , ํต์ฌ.
settings.xml์ ์ ๊ณต๋ ๊ฒฝ๋ก/ํ์ผ์ ์นด๋ฉ๋ผ ๋ฐ์ดํฐ ์ฐ๊ธฐ
$ ./camera_calibration settings.xml
This is a camera calibration sample.
Usage: calibration configurationFile
Near the sample file you'll find the configuration file, which has detailed help of how to edit it. It may be any OpenCV supported file format XML/YAML.
OpenCV Error: Assertion failed (src.size == dst.size && src.channels() == dst.channels()) in cvConvertScale, file $OPENCV_DIR/modules/core/src/convert.cpp, line 5474
terminate called after throwing an instance of 'cv::Exception'
what(): $OPENCV_DIR/modules/core/src/convert.cpp:5474: error: (-215) src.size == dst.size && src.channels() == dst.channels() in function cvConvertScale
Aborted (core dumped)
์๋ ๊ทธ๋๋ก ์ปดํ์ผ๋๋ ์ ์ฒด ์์ ๋ฅผ ์ ๊ณตํ์ญ์์ค.
$OPENCV_DIR/samples/data
ํด๋์ images
$OPENCV_DIR/samples/cpp/tutorial_code/calib3d/camera_calbration
์์ ์์
๋๋ ํ ๋ฆฌ๋ก ์ํ ์ฝ๋ ๋ณต์ฌcmake .
๋ค์์ make
์ฌ์ฉํ์ฌ ์ปดํ์ผํฉ๋๋ค. CMakeLists.txt๋ http://docs.opencv.org/3.1.0/db/df5/tutorial_linux_gcc_cmake.html#gsc.tab =0์ ์ ๊ณต๋ ์์ ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํฉ๋๋ค../camera_calibration settings.xml
, ๋๋ Windows camera_calibration.exe settings.xml
image_list.xml์ ๋์ด๋ ๋๋ก $OPENCV_DIR/samples/data
(left1-14.jpg ๋ฐ right1-14.jpg)์์ ์ฌ์ฉํ ์ ์๋ ์ผ๋ จ์ ๋ณด์ ์ด๋ฏธ์ง ์ฌ์ฉ
ํ์ํ ๊ฒฝ์ฐ xml์ ๊ฐ์ ธ์ค๋ ค๋ฉด .txt
์์ ์ด๋ฆ์ ๋ฐ๊ฟ๋๋ค.
์ค์ .xml.txt
image_list.xml.txt
CMake:
CMakeLists.txt
image_list.xml์ ์๋ชป๋ ์ด๋ฏธ์ง ๊ฒฝ๋ก๊ฐ ํฌํจ๋์ด ์์ต๋๋ค. ๋ค์๊ณผ ๊ฐ์์ผ ํฉ๋๋ค.
images/left01.jpg
images/left02.jpg
images/left03.jpg
...
๋๋์ด ๋ฒ๊ทธ๊ฐ ์์ต๋๋ค.
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.0.0-pre) /opt/opencv/modules/core/src/convert_c.cpp:112: error: (-215:Assertion failed) src.size == dst.size && src.channels() == dst.channels() in function 'cvConvertScale'
in_VID5.xml
...
<BoardSize_Width>9</BoardSize_Width>
<BoardSize_Height>13</BoardSize_Height>
...
<Input>"/home/monxarat/projects/test/image/calibration/img/VID5.xml"</Input>
...
VID5.ml
<?xml version="1.0"?>
<opencv_storage>
<images>
/home/monxarat/projects/test/image/calibration/img/chess_6.jpg
/home/monxarat/projects/test/image/calibration/img/chess_6.jpg
</images>
</opencv_storage>
์์
n - 1
๋ฐ m - 1
config size_width
๋ฐ size_height
๋ฅผ ์ค์ ํ๋ฉด ์คํ์ด ์ ์์
๋๋ค(n์ ์ค์ ๋ณด๋ ํฌ๊ธฐ์ ์ด ์, m์ ํ ์ ์ค์ ๋ณด๋ ํฌ๊ธฐ)
<BoardSize_Width>12</BoardSize_Width>
<BoardSize_Height>8</BoardSize_Height>
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
image_list.xml์ ์๋ชป๋ ์ด๋ฏธ์ง ๊ฒฝ๋ก๊ฐ ํฌํจ๋์ด ์์ต๋๋ค. ๋ค์๊ณผ ๊ฐ์์ผ ํฉ๋๋ค.