Giter VIP home page Giter VIP logo

camera_calibration's Introduction

Camera_Calibration

This repository is for camera calibration in C++.

GitHub


Files Structure Description

camera_calibration_pkg
    │  CMakeLists.txt
    │  package.xml
    │
    ├─config
    │      calibration_param.yaml
    │      distortion_gridpattern_compare1.png
    │      distortion_gridpattern_compare2.png
    │      setup_aruco.yaml
    │      setup_chessboard.yaml
    │      setup_ros.yaml
    │
    ├─include
    │      camera_calibration_tool.h
    │      drawing_tool.h
    │      param_code.h
    │      undistortion.h
    │
    ├─launch
    │      aruco_ext_calib.launch
    │      aruco_marker_generate.launch
    │      aruco_video_ext_calib.launch
    │      camera_calibration.launch
    │      chessboard_cam_ext_calibration.launch
    │      opencv_undistortion_time_cost_test.launch
    │      show_distorted_grid_pattern.launch
    │      undistortion.launch
    │
    ├─lib
    │      aruco_tool.cpp
    │      camera_calibration_tool.cpp
    │      drawing_tool.cpp
    │      undistortion.cpp
    │
    └─src
            aruco_ext_calib.cpp
            aruco_marker_generate.cpp
            aruco_video_ext_calib.cpp
            camera_calibration.cpp
            chessboard_cam_ext_calibration.cpp
            opencv_undistortion_time_cost_test.cpp
            show_distorted_grid_pattern.cpp
            undistortion_sample.cpp

Node File Example

To use these nodes, please use launch file for transmitting server parameters.

Example for Node "show_distorted_grid_pattern"


distortion_gridpattern_compare1 distortion_gridpattern_compare1

Method of Distorted GridPattern Generation

  1. Use cv::getOptimalNewCameraMatrix() and cv::initUndistortRectifyMap() to get map1 and map2. Map1 contains a mapping table on (x, y) which refer to the source gridpattern image pixel, and map2 is a mapping table on y for refinement of the image. Map1 and map2 is a mapping from distorted image to undistorted image.

  2. Find a mapping from undistorted image to distorted image for drawing a distorted gridpattern from a uniform grid pattern: Assume $\ X$ is the original image matrix, $\ X'$ is the target image processed by undistortion, $\ X''$ is the distorted gridpattern image we need to generate, and $\ T$ is the undistortion transform matrix. We have

    $\ X' = TX$
    $\ ΔX = X - X' = X - TX = (I - T)X$
    $\ X'' = X + ΔX = X + (I - T)X = (2I - T)X$

    Therefore, the new transform matrix is $\ G = 2I - T$

    Implementation

    newMap1.at<cv::Vec2f>(y, x) = static_cast<cv::Vec2f>(cv::Vec2f(2.0 * x, 2.0 * y) - map1.at<cv::Vec2f>(y, x));
    #This is for map1 CV_32FC2 format.
    
    newMap2.at<uchar>(y, x) = static_cast<uchar>(2 * y - map2.at<uchar>(y, x));
    #This is for map2 CV_8U format.
    
    #For other format, please check the format table for cv::Mat::at() method to edit it. You can use cv::Mat::type() function to find the format code. 
    
  3. Remapping by cv::remap() function.

Example for Node "aruco_video_ext_calib"

After the camera intrinsics calibrating, real-time external calibration can be performed using an Aruco Marker with known true dimensions. The resulting rotation and translation matrices enable mapping from 3d space to 2d space. A simple function of AR can be realized by inserting objects (pictures, point clouds, etc.) into the 3d space.

Launch File Description

Please use launch command to run the nodes. Before use it, please edit the yaml file in ./config folder.


Contributor:

QuintinUmi

camera_calibration's People

Contributors

quintinumi avatar

Stargazers

JAY avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.