相机标定

相机标定&读取摄像头


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

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<:string>& filelist, cv::Size & boardSize); // Add scene points and corresponding image points void addPoints(const std::vector<:point2f>& imageCorners, const std::vector<:point3f>& 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; } ```

转载于:https://www.cnblogs.com/elong1995/p/10878563.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值