How Does a Camera Calibration File Work in ROS 2?

asked 2022-05-12 09:22:17 -0500

kyubot gravatar image

updated 2022-05-13 13:31:08 -0500

kscottz gravatar image

Hello all,

I am trying to implement a camera node for jetson nano using opencv for tegra. I did check following lines of code successfully open CSI camera attached to the jetson nano and see images from it.

#include <opencv2/opencv.hpp>
std::string get_tegra_pipeline(int width, int height, int fps) {
    return "nvarguscamerasrc ! video/x-raw(memory:NVMM), width=(int)" + std::to_string(width) + ", height=(int)" +
           std::to_string(height) + ", format=(string)NV12, framerate=(fraction)" + std::to_string(fps) +
           "/1 ! nvvidconv flip-method=0 ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink";
}
int main() {
    // Options
    int WIDTH = 1280;
    int HEIGHT = 720;
    int FPS = 60;
    // Define the gstream pipeline
    std::string pipeline = get_tegra_pipeline(WIDTH, HEIGHT, FPS);
    std::cout << "Using pipeline: \n\t" << pipeline << "\n";
    // Create OpenCV capture object, ensure it works.
    cv::VideoCapture cap(pipeline, cv::CAP_GSTREAMER);
    if (!cap.isOpened()) {
        std::cout << "Connection failed";
        return -1;
    }
    // View video
    cv::Mat frame;
    while (1) {
        cap >> frame;  // Get a new frame from camera
        // Display frame
        imshow("Display window", frame);
        cv::waitKey(1); //needed to show frame
    }
}

Based on this https://github.com/klintan/ros2_usb_c... package, I am trying to implement camera driver for jetson nano but it is not working as below.

image description

The node is running but no image are shown in ros2 rqt_image_view.

All the codes are available from my git https://github.com/kyuhyong/jetson_ca...
This package can be built on jetson nano with following command

~/ros2_ws$ colcon build --symlink-install --packages-select jetson_camera_driver
Starting >>> jetson_camera_driver
[Processing: jetson_camera_driver]                             
[Processing: jetson_camera_driver]_camera_driver:build 75% - 1min 0.0s]
[Processing: jetson_camera_driver]                                        
Finished <<< jetson_camera_driver [1min 34s]                              

Summary: 1 package finished [1min 36s]

I still don't understand how calibration file is supplied to the driver to suppress error like this. Any suggestion or comments will be much appreciated.

Kyu

edit retag flag offensive close merge delete