OpenCV Tutorials —— Camera calibration with square chessboard

获取摄像机内部参数矩阵和摄像机畸变参数

Test data: use images in your data/chess folder.

  1. 1,Compile opencv with samples by setting BUILD_EXAMPLES to ON in cmake configuration.
  2. 2,Go to bin folder and use imagelist_creator to create an XML/YAML list of your images.
  3. 3,Then, run calibration sample to get camera parameters. Use square size equal to 3cm.

获取到的摄像机参数信息存放在XML /YAML 文件中,然后对失真图像进行矫正

Test data: use chess_test*.jpg images from your data folder.

  1. 1,Create an empty console project. Load a test image:

    Mat img = imread(argv[1], CV_LOAD_IMAGE_GRAYSCALE);
  2. 2,Detect a chessboard in this image using findChessboard function.
  3. bool found = findChessboardCorners( img, boardSize, ptvec, CV_CALIB_CB_ADAPTIVE_THRESH );
  4. 3,Now, write a function that generates a vector<Point3f> array of 3d coordinates of a chessboard in any coordinate system. For simplicity, let us choose a system such that one of the chessboard corners is in the origin and the board is in the plane z = 0.
  5. 4,Read camera parameters from XML/YAML file:
  6. FileStorage fs(filename, FileStorage::READ);
    Mat intrinsics, distortion;
    fs["camera_matrix"] >> intrinsics;
    fs["distortion_coefficients"] >> distortion;
  7. 5,Now we are ready to find chessboard pose by running solvePnP:
    vector<Point3f> boardPoints;
    // fill the array
    ...
    
    solvePnP(Mat(boardPoints), Mat(foundBoardCorners), cameraMatrix,
                         distCoeffs, rvec, tvec, false);
  8. Calculate reprojection error like it is done in calibration sample (see opencv/samples/cpp/calibration.cpp, function computeReprojectionErrors).
时间: 2024-08-03 16:20:26

OpenCV Tutorials —— Camera calibration with square chessboard的相关文章

OpenCV Tutorials &mdash;&mdash; Camera calibration With OpenCV

获取摄像机参数是为了来处理图像失真或者实现图像度量 ~~ Unfortunately, this cheapness comes with its price: significant distortion. Luckily, these are constants and with a calibration and some remapping we can correct this. Furthermore, with calibration you may also determine

学习opencv tutorials

1.opencv里头动态库和静态库的区别 lib是动态库,staticlib是静态库. 这是opencv tutorials中对动态库和静态库的说明.动态库是在runtime时候才load的库文件.而静态库文件会在你build的时候build-in inside your exe file.优点是可以避免误删,缺点是应用程序变大,加载时间也会变长. 2.  Visual Studio中solution和project的关系 在VS中,一个solution中可以包含多个project. 3.  两

Camera Calibration&#39;s fx and fy do Cares in SLAM

In my original thinking, fx and fy, which are focus lenth of camera, is trivial.  They play a role of just an actually non-sense part to the final output. Today I test ORB-SLAM2 with my own video. I inherit the kitti00-02.yaml config file. That means

OpenCV Tutorials —— Video Input with OpenCV and similarity measurement

OpenCV 的视频操作都与 VideoCapture 相关 If this argument is an integer then you will bind the class to a camera, a device. The number passed here is the ID of the device, assigned by the operating system. If you have a single camera attached to your system it

OpenCV Open Camera 打开摄像头

这是一个用OpenCV2.4.10打开摄像头的一个例子,参见代码如下: #include <iostream> #include <stdio.h> #include <opencv2/opencv.hpp> using namespace cv; using namespace std; int main(int argc, char *argv[]) { CvCapture* cam0 = cvCaptureFromCAM(0); if(!cam0) { fprin

opencv实现camera模组的暗电流和lenshading补偿

简介 在接触过的qcom和mtk平台中,camera调试软件和流程基本都是大同小异.所以查了点资料,然后模仿这些软件,自己练习写了下最开始的 两步:暗电流和len shading补偿. 基本原理 产生原因 在camera模组中,会因为sensor本身的暗电流,从而对图像参数噪声.同时也会因为模组镜头的原因,导致拍摄照片的亮度,中间亮而四周相对较暗. 所以在模组工作中,我们需要对模组做暗电流的校正和len shading相关的补偿.对这方面深入的了解,请自己查询相关资料吧,这里只简单讲解下. 校正

OpenCV Tutorials &mdash;&mdash; Hough Line Transform

霍夫直线变换 -- 用于检测图像中的直线 利用图像空间和Hough参数空间的点--直线对偶性,把图像空间中的检测问题转换到参数空间,通过在参数空间进行简单的累加统计,然后在Hough参数空间中寻找累加器峰值的方法检测直线 Standard and Probabilistic Hough Line Transform OpenCV implements two kind of Hough Line Transforms: The Standard Hough Transform It consis

OpenCV Tutorials &mdash;&mdash; Feature Matching with FLANN

Extractors of keypoint descriptors in OpenCV have wrappers with a common interface that enables you to easily switch between different algorithms solving the same problem.   DescriptorExtractor::compute Computes the descriptors for a set of keypoints

OpenCV Tutorials &mdash;&mdash; Creating a video with OpenCV

写video 需要用到 VideoWriter  视频文件可看作一个容器 视频的类型由视频文件的后缀名来指定   Due to this OpenCV for video containers supports only the avi extension, its first version. A direct limitation of this is that you cannot save a video file larger than 2 GB. Furthermore you ca