camera calibration:a lot of undefined reference error
Hey all!
I am trying to do the camera calibration, because i need a calibration file in XML or YML format. I have read the official "Camera calibration with OpenCV" tutorial, link: link text I tried to run the code in terminal with the following command: "gcc camera_calibration.cpp" I also tried to run it with the Geany IDE, but I got the following errors:
g++ -Wall -o "camera_calibration" "camera_calibration.cpp" (in directory: /home/mirind4/DiplomaMSC/OpenCV/opencv-2.4.10/samples/cpp/tutorial_code/calib3d/camera_calibration)
/tmp/ccodHJGb.o: In function `cv::operator<<(cv::FileStorage&, char const*)':
camera_calibration.cpp:(.text+0x43): undefined reference to `cv::operator<<(cv::FileStorage&, std::string const&)'
/tmp/ccodHJGb.o: In function `cv::operator<<(cv::FileStorage&, char*)':
camera_calibration.cpp:(.text+0xdc): undefined reference to `cv::operator<<(cv::FileStorage&, std::string const&)'
/tmp/ccodHJGb.o: In function `main':
camera_calibration.cpp:(.text+0x5aa): undefined reference to `cv::FileStorage::FileStorage(std::string const&, int, std::string const&)'
camera_calibration.cpp:(.text+0x5c8): undefined reference to `cv::FileStorage::isOpened() const'
camera_calibration.cpp:(.text+0x632): undefined reference to `cv::FileStorage::operator[](char const*) const'
camera_calibration.cpp:(.text+0x65a): undefined reference to `cv::FileStorage::release()'
camera_calibration.cpp:(.text+0x983): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
camera_calibration.cpp:(.text+0x99c): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
camera_calibration.cpp:(.text+0x9ba): undefined reference to `cv::flip(cv::_InputArray const&, cv::_OutputArray const&, int)'
camera_calibration.cpp:(.text+0xa35): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
camera_calibration.cpp:(.text+0xa57): undefined reference to `cv::findChessboardCorners(cv::_InputArray const&, cv::Size_<int>, cv::_OutputArray const&, int)'
camera_calibration.cpp:(.text+0xa71): undefined reference to `cv::SimpleBlobDetector::Params::Params()'
camera_calibration.cpp:(.text+0xa90): undefined reference to
To be honest, these errors are only about the 25% of total error messages, but I do not want to "spam" this post with them, because in my opinion the problem lies somewhere else....
Some Additional Informations:
My inVID.xml file:
<?xml version="1.0"?>
<opencv_storage>
<Settings>
<!-- Number of inner corners per a item row and column. (square, circle) -->
<BoardSize_Width> 9</BoardSize_Width>
<BoardSize_Height>6</BoardSize_Height>
<!-- The size of a square in some user defined metric system (pixel, millimeter)-->
<Square_Size>25</Square_Size>
<!-- The type of input used for camera calibration. One of: CHESSBOARD CIRCLES_GRID ASYMMETRIC_CIRCLES_GRID -->
<Calibrate_Pattern>"CHESSBOARD"</Calibrate_Pattern>
<!-- The input to use for calibration.
To use an input camera -> give the ID of the camera, like "1"
To use an input video -> give the path of the input video, like "/tmp/x.avi"
To use an image list -> give the path to the XML or YAML file containing the list of the images, like "/tmp/circles_list.xml"
-->
<Input>"images/CameraCalibraation/VID5/VID5.xml"</Input>
<!-- If true (non-zero) we flip the input images around the horizontal axis.-->
<Input_FlipAroundHorizontalAxis>0</Input_FlipAroundHorizontalAxis>
<!-- Time delay between frames in case of camera. -->
<Input_Delay>100</Input_Delay>
<!-- How many frames to use, for calibration. -->
<Calibrate_NrOfFrameToUse>25</Calibrate_NrOfFrameToUse>
<!-- Consider only fy as a free parameter, the ratio fx/fy stays the same as in the input cameraMatrix ...
you seem to forget all of the opencv libs, try like:
g++ -Wall -o camera_calibration camera_calibration.cpp -lopencv_calib3d -lopencv_imgproc -lopencv_highgui -lopencv_core
hey! Thanks for the comment. I have tried it, but still got some problem: /usr/bin/ld: /tmp/ccGRBWZ8.o: undefined reference to symbol '_ZN2cv18SimpleBlobDetector6ParamsC1Ev' //usr/local/lib/libopencv_features2d.so.2.4: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status
ah, that's another one:
-lopencv_features2d
basically, you'll need the respective lib for each of the opencv headers in your code ;)
ohh nice thanks! Now there is no error! I would like to ask one more question, if no problem. So now I wrote this command in terminal, but I got no any answer, and I also can not find any yml or xml file in camera_calibration folder. What am i doing wrong, could you help please! I really appreciate your help!
did you mean this xml file ? - you will have to write your own (with your calibration images), i guess
ohh i see! Sorry i am a beginner in this topic. I would have one more question...what does the camera_calibration.cpp do exactly? then Where are the results of it? Thanks in advance for your answer
it calculates the camera matrix and the distortion coeffs, which are nessecary for a couple of other operations, like undistorting the image, solvePnP, projections from 2d -> 3d, etc.
again, see the results here right at the end there's a final xml file
(also, don't be sorry for being a noob, you're doing fine !)
you are so kind, thanks for it! I have read the result. I also have a similar xml file with images like VID5.xml in the tutorial. Now I tried to write in the terminal : "./camera_calibration VID5.xml", but it says, invalid input :S ---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. Invalid input detected. Application stopping. --- In my question post, I also enclosed this file, and for me, it seems all right... Really thanks! :)
./camera_calibration inVID.xml
!! (yea, confusing names, but the configuration file, not the one with the images)ohh I think i got it, thanks a lot! I will let you know how i am going :)