我有用于计算相机矩阵和修复图像失真的 OpenCV 代码。
这是 OpenCV 和 C++ 中的代码部分。
//default capture width and height
const int FRAME_WIDTH = 1288;
const int FRAME_HEIGHT = 964;
//max number of objects to be detected in frame
const int MAX_NUM_OBJECTS=50;
//minimum and maximum object area
const int MIN_OBJECT_AREA = 2*2;
const int MAX_OBJECT_AREA = FRAME_HEIGHT*FRAME_WIDTH/1.5;
Mat DistortedImg; //storage for copy of the image raw
Mat UndistortedImg; //
double cameraM[3][3] = {{1103.732864, 0.000000, 675.056365}, {0.000000, 1100.058630, 497.063376}, {0, 0, 1}}; //camera matrix to be edited
Mat …Run Code Online (Sandbox Code Playgroud)