跳转至

CaptureOptionsX1

单目模式打印拍摄参数,四种传参方式说明,调用相机内参数拍摄。

#include <RVC/RVC.h>

#include <iostream>

#include "IO/FileIO.h"
#include "IO/SavePointMap.h"


int main(int argc, char *argv[]) {
    // Initialize RVC X system.
    RVC::SystemInit();

    // Find Device
    RVC::Device devices[10];
    size_t actual_size = 0;
    SystemListDevices(devices, 10, &actual_size, RVC::SystemListDeviceType::All);
    if (actual_size == 0) {
        std::cout << "Can not find any Camera!" << std::endl;
        return -1;
    }
    RVC::Device device = devices[0];

    RVC::DeviceInfo info;
    device.GetDeviceInfo(&info);

    // Create and Open
    RVC::X1 x1 = RVC::X1::Create(device);
    x1.Open();
    if (!x1.IsOpen()) {
        std::cout << "RVC X Camera is not opened!" << std::endl;
        RVC::X1::Destroy(x1);
        RVC::SystemShutdown();
        return -1;
    }

    // Capture Options
    RVC::X1::CaptureOptions options;
    bool ret;
    std::cout << info.name << "-" << info.sn << std::endl;
    std::cout << "Print capture options---" << std::endl;
    {
        std::string captureMode =
            options.capture_mode == RVC::CaptureMode_Normal ? "CaptureMode_Normal" :
            options.capture_mode == RVC::CaptureMode_Fast ? "CaptureMode_Fast" :
            options.capture_mode == RVC::CaptureMode_Ultra ? "CaptureMode_Ultra" :
            options.capture_mode == RVC::CaptureMode_Robust ? "CaptureMode_Robust" :
            "Error";

        std::cout << "[capture_mode] = {" << captureMode << "}" << std::endl;
        std::cout << "[exposure_time_2d] = {" << options.exposure_time_2d << "}" << std::endl;
        std::cout << "[gain_2d] = {" << options.gain_2d << "}" << std::endl;
        std::cout << "[gamma_2d] = {" << options.gamma_2d << " }" << std::endl;
        std::cout << "[use_projector_capturing_2d_image] = {" << options.use_projector_capturing_2d_image << "}" << std::endl;
        std::cout << "[exposure_time_3d] = {" << options.exposure_time_3d << "}" << std::endl;
        std::cout << "[gain_3d] = {" << options.gain_3d << "}" << std::endl;
        std::cout << "[gamma_3d] = {" << options.gamma_3d << "}" << std::endl;
        std::cout << "[light_contrast_threshold] = {" << options.light_contrast_threshold << "}" << std::endl;
        std::cout << "[projector_brightness] = {" << options.projector_brightness << "}" << std::endl;

        std::cout << "[hdr_exposure_times] = {" << options.hdr_exposure_times << "}" << std::endl;
        std::cout << "[hdr_exposuretime_content] = {" << options.hdr_exposuretime_content[0] << "," << options.hdr_exposuretime_content[1] << "," << options.hdr_exposuretime_content[2] << "}" << std::endl;
        std::cout << "[hdr_gain_3d] = {" << options.hdr_gain_3d[0] << "," << options.hdr_gain_3d[1] << "," << options.hdr_gain_3d[2] << "}" << std::endl;
        std::cout << "[hdr_scan_times] = {" << options.hdr_scan_times[0] << "," << options.hdr_scan_times[1] << "," << options.hdr_scan_times[2] << "}" << std::endl;
        std::cout << "[hdr_projector_brightness] = {" << options.hdr_projector_brightness[0] << "," << options.hdr_projector_brightness[1] << "," << options.hdr_projector_brightness[2] << "}" << std::endl;

        std::cout << "[confidence_threshold] = {" << options.confidence_threshold << "}" << std::endl;
        std::cout << "[noise_removal_distance] = {" << options.noise_removal_distance << "}" << std::endl;
        std::cout << "[noise_removal_point_number] = {" << options.noise_removal_point_number << "}" << std::endl;

        std::string smoothness =
            options.smoothness == RVC::SmoothnessLevel_Off ? "SmoothnessLevel_Off" :
            options.smoothness == RVC::SmoothnessLevel_Weak ? "SmoothnessLevel_Weak" :
            options.smoothness == RVC::SmoothnessLevel_Normal ? "SmoothnessLevel_Normal" :
            options.smoothness == RVC::SmoothnessLevel_Strong ? "SmoothnessLevel_Strong" :
            "Error";
        std::cout << "[smoothness] = {" << smoothness << "}" << std::endl;
        std::cout << "[downsample_distance] = {" << options.downsample_distance << "}" << std::endl;
        std::cout << "[calc_normal] = {" << options.calc_normal << "}" << std::endl;
        std::cout << "[calc_normal_radius] = {" << options.calc_normal_radius << "}" << std::endl;

        std::cout << "ROI(x,y,w,h)--[roi] = {" << options.roi.x << "," << options.roi.y << "," << options.roi.width << "," << options.roi.height << "}" << std::endl;

        //G-series camera, number of scans
        std::cout << "[G-series scan_times] = {" << options.scan_times << "}" << std::endl;

        //Bilateral filtering [cuda version not supported]
        std::cout << "[truncate_z_min] = {" << options.truncate_z_min << "}" << std::endl;
        std::cout << "[truncate_z_max] = {" << options.truncate_z_max << "}" << std::endl;
        std::cout << "[bilateral_filter_kernal_size] = {" << options.bilateral_filter_kernal_size << "}" << std::endl;
        std::cout << "[bilateral_filter_depth_sigma] = {" << options.bilateral_filter_depth_sigma << "}" << std::endl;
        std::cout << "[bilateral_filter_space_sigma] = {" << options.bilateral_filter_space_sigma << "}" << std::endl;
    }

    // Method 1, Use Default Options and Modify.
    {
        //options = RVC::X1::CaptureOptions();
        // todo:modify options
        //ret = x1.Capture(options);
    }

    // Method 2 , Load Options From Camera and Modify.
    {
        //x1.LoadCaptureOptionParameters(options);
        // todo:modify options
        //ret = x1.Capture(options);
    }

    // *****
    // Method 3 , Using the internal parameters of the camera.
    {
        // We suggest adjusting the camera parameters By RVC Manager.
        // Then, when we use SDK, we directly use the parameters inside the camera.
        ret = x1.Capture();
    }

    // Method 4 , Load Options From File and Capture.
    {
        // If you need to capture multiple scenes, their parameters are different.
        // You can save these parameters as different configuration files  By RVC Manager and then import the files before capture.
        // ret = x1.LoadSettingFromFile("file.json");
        // ret = x1.Capture();
    }

    if(ret == false)
    {
        std::cout << RVC::GetLastErrorMessage() << std::endl;
        x1.Close();
        RVC::X1::Destroy(x1);
        RVC::SystemShutdown();
        return -1;
    }

    // Data Process
    std::string dir = "./Data/";
    MakeDirectories(dir);
    dir += info.sn;
    MakeDirectories(dir);
    dir += "/x1";
    MakeDirectories(dir);

    RVC::PointMap pointcloud = x1.GetPointMap();
    RVC::Image image = x1.GetImage();
    pointcloud.Save((dir + "/pointcloud.ply").c_str(), RVC::PointMapUnit::Millimeter, true);
    pointcloud.Save((dir + "/pointcloud_color.ply").c_str(),RVC::PointMapUnit::Millimeter,true,image);
    image.SaveImage((dir + "/image.png").c_str());


    // Close RVC X Camera.
    x1.Close();
    RVC::X1::Destroy(x1);
    RVC::SystemShutdown();


    return 0;
}