基于OPENCV的投影仪标定(源码)

这个示例展示了如何使用OpenCV库来校准相机和投影仪。通过读取棋盘格图案的参数,计算相机和投影仪的内参、外参,并保存校准结果。
摘要由CSDN通过智能技术生成
opencv3.0的源码,之前很苦恼投影仪的标定,opencv提供了一个demo,上传源码:

#include <opencv2/highgui.hpp>
#include
#include
#include

#include <opencv2/core.hpp>
#include <opencv2/core/utility.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/calib3d.hpp>

using namespace std;
using namespace cv;

static const char* keys =
{
“{@camSettingsPath | | Path of camera calibration file}”
“{@projSettingsPath | | Path of projector settings}”
“{@patternPath | | Path to checkerboard pattern}”
“{@outputName | | Base name for the calibration data}”
};

static void help()
{
cout << “\nThis example calibrates a camera and a projector” << endl;
cout << “To call: ./example_structured_light_projectorcalibration <cam_settings_path> "
" <proj_settings_path> <chessboard_path> <calibration_basename>”
" cam settings are parameters about the chessboard that needs to be detected to"
" calibrate the camera and proj setting are the same kind of parameters about the chessboard"
" that needs to be detected to calibrate the projector" << endl;
}
enum calibrationPattern
{
CHESSBOARD,
CIRCLES_GRID,
ASYMETRIC_CIRCLES_GRID
};

struct Settings
{
Settings();
int patternType;
Size patternSize;
Size subpixelSize;
Size imageSize;
float squareSize;
int nbrOfFrames;
};

void loadSettings(String path, Settings &sttngs);
void createObjectPoints(vector &patternCorners, Size patternSize, float squareSize,
int patternType);
void createProjectorObjectPoints(vector &patternCorners, Size patternSize, float squareSize,
int patternType);
double calibrate(vector< vector > objPoints, vector< vector > imgPoints,
Mat &cameraMatrix, Mat &distCoeffs, vector &r, vector &t, Size imgSize);
void fromCamToWorld(Mat cameraMatrix, vector rV, vector tV,
vector< vector > imgPoints, vector< vector > &worldPoints);
void saveCalibrationResults(String path, Mat camK, Mat camDistCoeffs, Mat projK, Mat projDistCoeffs,
Mat fundamental);
void saveCalibrationData(String path, vector T1, vector T2, vector ptsProjCam, vector ptsProjProj, vector ptsProjCamN, vector ptsProjProjN);
void normalize(const Mat &pts, const int& dim, Mat& normpts, Mat &T);
void fromVectorToMat(vector v, Mat &pts);
void fromMatToVector(Mat pts, vector &v);

int main(int argc, char **argv)
{
VideoCapture cap(CAP_PVAPI);
Mat frame;

int nbrOfValidFrames = 0;

vector< vector<Point2f> > imagePointsCam, imagePointsProj, PointsInProj, imagePointsProjN, pointsInProjN;
vector< vector<Point3f> > objectPointsCam, worldPointsProj;
vector<Point3f> tempCam;
vector<Point2f> tempProj;
vector<Mat> T1, T2;
vector<Mat> pro
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值