相机标定

Posted elong1995

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了相机标定相关的知识,希望对你有一定的参考价值。

相机标定&读取摄像头


(因为用到的摄像头是红外线摄像头(监控摄像头),有必要了解其原理)从光谱来讲,和普通摄像头感可见光原理类似。红外摄像头工作原理是红外灯发出红外线照射物体,红外线漫反射,被监控摄像头接收,形成视频图像。

calibrate.h() ``` class CameraCalibrator { vector> objectPoints; vector> imagePoints; Mat cameraMatrix; Mat distCoeffs; int flag; Mat map1, map2; bool mustInitUndistort; public: CameraCalibrator() : flag(0), mustInitUndistort(true) {}; int addChessboardPoints(const std::vector& filelist, cv::Size & boardSize); // Add scene points and corresponding image points void addPoints(const std::vector& imageCorners, const std::vector& objectCorners); // Calibrate the camera double calibrate(cv::Size &imageSize); // Set the calibration flag void setCalibrationFlag(bool radial8CoeffEnabled = false, bool tangentialParamEnabled = false); // Remove distortion in an image (after calibration) cv::Mat CameraCalibrator::remap(const cv::Mat &image); // Getters cv::Mat getCameraMatrix() { return cameraMatrix; } cv::Mat getDistCoeffs() { return distCoeffs; } }; ```
CameraCalibrator.cpp ``` #include "CameraCalibrator.h" using namespace cv; cv::Mat CameraCalibrator::remap(const cv::Mat &image) { cv::Mat undistorted; if (mustInitUndistort) { // called once per calibration cv::initUndistortRectifyMap( cameraMatrix, // computed camera matrix distCoeffs, // computed distortion matrix cv::Mat(), // optional rectification (none) cv::Mat(), // camera matrix to generate undistorted cv::Size(720, 540), // image.size(), // size of undistorted CV_32FC1, // type of output map map1, map2); // the x and y mapping functions mustInitUndistort = false; } // Apply mapping functions cv::remap(image, undistorted, map1, map2, cv::INTER_LINEAR); // interpolation type return undistorted; } ```

以上是关于相机标定的主要内容,如果未能解决你的问题,请参考以下文章

工业相机斜着装怎么标定

工业相机需不需要标定?

opencv相机标定

计算机视觉——相机内外参、相机标定

Halcon相机标定问题,请高手指点。

Matlab相机标定总结