环境:ubuntu14.04+opencv2.4.11
步骤
1.在/home/renye/allKindOfLibs/opencv-2.4.11/samples/cpp/tutorial_code/calib3d/camera_calibration下看到有4个文件。将其中的camera_calibration.cpp和in_VID5.xml拷贝到另一个新建的文件夹下。
2.插入usb摄像头,输入命令 :ls /dev/video* 查看当前摄像头占用的设备号
3.在in_VID5.xml中
input use for calibration下,更改对应的参数为摄像头占用的设备号,我的是“0”
4.在新建的文件夹Camera_calibration 中新建CMakeLists.txt。
cmake_minimum_required(VERSION 2.8)
project(Camera_calibration)
set(CMAKE_CXX_STANDARD11)
find_package(OpenCV 2.4.11 QUIET)
if(NOT OpenCV_FOUND)
message(FATAL_ERROR"OpenCV 2.4.11 NOT FOUND!")
endif()
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(Camera_calibration camera_calibration.cpp)
target_link_libraries(Camera_calibration ${OpenCV_LIBS})
5.
mkdir build
cd build
cmake ..
make
6.renye@renye-All-Series:~/CVProject/camera_calibration$ ./Camera_calibration ../in_VID5.xml
按g start calibration 从不同角度各拍2到3张,结果保存在build下的out_camera_data.xml里,里面有一个camera matrix 就是提供了fx 0 cx o fy cy 0 0 1的相机内参矩阵,标定完毕
网友评论