码迷,mamicode.com
首页 > 其他好文 > 详细

相机标定

时间:2019-05-16 23:05:15      阅读:247      评论:0      收藏:0      [点我收藏+]

标签:lse   ppi   ndis   stc   res   after   ima   map   namespace   

相机标定&读取摄像头


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

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; } ```

相机标定

标签:lse   ppi   ndis   stc   res   after   ima   map   namespace   

原文地址:https://www.cnblogs.com/elong1995/p/10878563.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!