分类 OpenCV_图像_视觉_算法 下的文章

下面的数据是基于棋盘格和Matlab,检测到的角点,包括棋盘格世界坐标系下的3D点,以及检测出来的像素角点,2D点。 这些点可以用于测试,验证PnP问题的求解,或相机位姿的求解。 //单位:米 static double gObjectPoints[]={ 0, 0, 0, 0.1000, 0, 0.2000, 0, 0.3000, 0, 0.4000, 0, 0.5000, 0.1000, 0, 0.1000, 0.1000, 0.1000, 0.2000, 0.1000, 0.3000, 0.1000, 0.4000, 0.1000, 0.5000, 0.2000, 0, 0.2000, 0.1000, 0.2000, 0.2000, 0.2000, 0.3000, 0.2000, 0.4000, 0.2000, 0.5000, 0.3000, 0, 0.3000, 0.1000, 0.3000, 0.2000, 0.3000, 0.3000, 0.3000, 0.4000, 0.3000, 0.5000, 0.4000, 0, 0.4000, 0.1000, 0.4000, 0.2000, 0.4000, 0.3000, 0.4000, 0.4000, 0.4000, 0.5000, 0.5000, 0, 0.5000, 0.1000, 0.5000, 0.2000, 0.5000, 0.3000, 0.5000, 0.4000, 0.5000, 0.5000, 0.6000, 0, 0.6000, 0.1000, 0.6000, 0.2000, 0.6000, 0.3000, 0.6000, 0.4000, 0.6000, 0.5000, 0.7000, 0, 0.7000, 0.1000, 0.7000, 0.2000, 0.7000, 0.3000, 0.7000, 0.4000, 0.7000, 0.5000, 0.8000, 0, 0.8000, 0.1000, 0.8000, 0.2000, 0.8000, 0.3000, 0.8000, 0.4000, 0.8000, 0.5000 }; //单位:像素 static double gImagePoints[]={ 847.4886, 850.7136, 852.7741, 828.7344, 857.6515, 808.6666, 862.2272, 790.0522, 866.3762, 773.0623, 870.0391, 757.3862, 823.8635, 850.3890, 830.0303, 828.4091, 835.8287, 808.4295, 840.9203, 790.0726, 846.0095, 772.9457, 850.4819, 757.4263, 800.0982, 850.1008, 807.2758, 828.2090, 813.9884, 808.2684, 820.0247, 789.9752, 825.9340, 772.9689, 831.1547, 757.2540, 776.2370, 849.9279, 784.5996, 828.1187, 792.0801, 808.2185, 799.4100, 789.7657, 805.7051, 772.8325, 811.8602, 757.1756, 752.4512, 849.6842, 761.7646, 828.0157, 770.5236, 807.9907, 778.2557, 789.8532, 785.8090, 772.8681, 792.3529, 757.2258, 728.7513, 849.3456, 739.2453, 827.7354, 748.6905, 807.9238, 757.5654, 789.6743, 765.5367, 772.7883, 773.0747, 757.1527, 705.0985, 849.1139, 716.1335, 827.6434, 727.1556, 807.7189, 736.2896, 789.6546, 745.6337, 772.6696, 753.6428, 757.2044, 681.8501, 848.8632, 693.7321, 827.4995, 705.2987, 807.5602, 715.7386, 789.4695, 725.7770, 772.6211, 734.1417, 757.2759, 658.2809, 848.6370, 671.7648, 827.0990, 683.6927, 807.6315, 694.0555, 789.5468, 705.5133, 772.7883, 715.9418, 757.1839 }; //对应的相机内参矩阵: focalLength=[507.834589, 508.321406] % [fx fy] principalPoint = [957.612285, 493.785693] %[cx cy] imageSize = [1080, 1920] % [mrows ncols]

1、 **OpenCV** 核心函数为: cv::findChessboardCorners()/cv::cornerSubPix cv::solvePnP() 2、 **Matlab** 核心函数为: [pitch,yaw,roll,height] = estimateMonoCameraParameters(intrinsics,imagePoints,worldPoints,patternOriginHeight); %[rotationMatrix, translationVector] = estimateExtrinsics(imagePoints, worldPoints, intrinsics) % since from matlab 2022b. [rotationMatrix, translationVector] = extrinsics(imagePoints, worldPoints, intrinsics) 3、**ViSP(Visual Servoing Platform)** ViSP 代表视觉伺服平台,是一个模块化跨平台库,允许使用视觉跟踪和视觉伺服技术进行原型设计和开发应用程序,这是 IRISA - Inria Rainbow 团队(以前的 Lagadic 团队)所做研究的核心。 ViSP 能够计算可应用于机器人系统的控制定律。 它提供了一组可以使用实时图像处理或计算机视觉算法进行跟踪的视觉特征。 ViSP 还提供模拟功能。 ViSP 可用于机器人、计算机视觉、增强现实和计算机动画。 https://github.com/lagadic/visp 4、**OpenGV** https://laurentkneip.github.io/opengv/index.html https://github.com/laurentkneip/opengv

bool Load_OpenCV_Camera_Intrinsic(const std::string &intrinsics_yaml) { cv::FileStorage fs(intrinsics_yaml, cv::FileStorage::READ); if(!fs.isOpened()){ std::cout<<"Err: can't open camera intrinsic file:"<> mCamera_Model; fs["K"] >> K; fs["D"] >> D; fs.release(); cv::cv2eigen(K, mCamIntri); cv::cv2eigen(D, mDistCoeffs); return true; } bool Load_Camera_Intrinsic(const std::string &file) { std::vector K; std::vector D; try{ YAML::Node config = YAML::LoadFile(file); K = config["K"].as>(); D = config["D"].as>(); mCamera_Model = config["distortion_model"].as(); }catch(const YAML::Exception& e){ std::cout <<"load intrinsic: " <= 201703L if(!std::filesystem::exists(time_now)) \#else struct stat data; if(0!=stat(time_now.c_str(), &data) || (data.st_mode & S_IFMT)!=S_IFDIR) \#endif { std::cout<<"ERR: path:"<

float R = (float)r; float G = (float)g; float B = (float)b; float Y = 0.299*R + 0.587*G + 0.114*B; float U = -0.169*R - 0.331*G + 0.5 *B + 128.0; float V = 0.5 *R - 0.419*G - 0.081*B + 128.0;