在畸变校正中需要用到图像中四个角点的坐标,当固定好硬件后,便可使用鼠标来调试软件的矫正参数。使摄像头实时播放图像,在播放界面选择要校正的图像点位
当选择点数等于4个时突出8校正功能,并保存校正参数。
实现的功能如下图:
源码如下:
int calibration_image(int camera_index) {
if (!camera_capture.isOpened()) {
if (camera_play(camera_index) != 0) {
return -1;
}
}
Mat cap_frame;
bool first_flag = true;
mark_position.clear();
//camera_capture.set(CAP_PROP_SETTINGS, 1);
while (1)
{
if (!first_flag) {
int property = getWindowProperty("usb camera", 0);
if (property == -1) {
destroyAllWindows();
return 0;
}
}
first_flag = false;
camera_capture >> cap_frame;
cam