I try to get point cloud using my ZED2. The cloud has a lot of noise. My code is:
#include <sl/Camera.hpp>
#include <chrono>
using namespace std;
using namespace sl;
int main(int argc, char** argv) {
Camera zed;
POSITIONAL_TRACKING_STATE tracking_state = POSITIONAL_TRACKING_STATE::OFF;
// Set configuration parameters for the ZED
InitParameters init_parameters;
init_parameters.depth_mode = DEPTH_MODE::ULTRA;
init_parameters.coordinate_system = COORDINATE_SYSTEM::RIGHT_HANDED_Y_UP;
init_parameters.camera_resolution = sl::RESOLUTION::HD1080;
init_parameters.depth_maximum_distance = 2;
init_parameters.depth_minimum_distance = 0.2;
init_parameters.coordinate_units = sl::UNIT::METER;
PositionalTrackingParameters track;
track.enable_imu_fusion = true;
// Open the camera
auto returned_state = zed.open(init_parameters);
zed.enablePositionalTracking(track);
if (returned_state != ERROR_CODE::SUCCESS) {
return -1;
}
auto camera_config = zed.getCameraInformation().camera_configuration;
RuntimeParameters runParameters;
// Setting the depth confidence parameters
runParameters.confidence_threshold = 50;
runParameters.texture_confidence_threshold = 100;
runParameters.sensing_mode = SENSING_MODE::FILL;
// Allocation of 4 channels of float on GPU
Mat point_cloud(camera_config.resolution, MAT_TYPE::F32_C4, MEM::GPU);
auto first_time_counter = std::chrono::high_resolution_clock::now();
// Main Loop
std::cout << "Start" << std::endl;
while (std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - first_time_counter).count() < 4000) {
// Check that a new image is successfully acquired
if (zed.grab(runParameters) == ERROR_CODE::SUCCESS) {
// retrieve the current 3D coloread point cloud in GPU
zed.retrieveMeasure(point_cloud, MEASURE::XYZRGBA, MEM::GPU);
}
}
// free allocated memory before closing the ZED
point_cloud.write("point_cloud.ply", MEM::GPU);
point_cloud.free();
std::cout << "end" << std::endl;
// close the ZED
zed.close();
return 0;
}
Why is it happening?