PCL: объединение двух наборов точек в одно облако и визуализация с помощью PCL cloudviewer - PullRequest
0 голосов
/ 18 сентября 2018

Я пытаюсь объединить два набора точек из двух разных видов в одно облако точек и визуализировать его с помощью средства просмотра облаков PCL.

    mPtrPointCloud->points.clear();
    mPtrPointCloud->points.resize(mFrameSize * 2);
    auto it = mPtrPointCloud->points.begin();
    received = PopReceived();
    if(received != nullptr)
    {
        // p_data_cloud = (float*)received->mTransformedPC.data;
        p_data_cloud = (float*)received->mCVPointCloud.data;
        index = 0;
        for (size_t i = 0; i < mFrameSize; ++i) 
        {
            float X = p_data_cloud[index];
            if (!isValidMeasure(X)) // Checking if it's a valid point
            {
                it->x = it->y = it->z = it->rgb = 0;
            }
            else 
            {
                it->x = X;
                it->y = p_data_cloud[index + 1];
                it->z = p_data_cloud[index + 2];
                it->rgb = convertColor(p_data_cloud[index + 3]); // Convert a 32bits float into a pcl .rgb format
            }
            index += 4;
            ++it;
        }
    }

    frame = PopFrame();
    if(frame != nullptr)
    {
        // p_data_cloud = frame->mSLPointCloud.getPtr<float>();
        p_data_cloud = (float*)frame->mCVPointCloud.data;
        index = 0;

        for (size_t i = 0; i < mFrameSize; ++i) 
        {
            float X = p_data_cloud[index];
            if (!isValidMeasure(X)) // Checking if it's a valid point
            {
                it->x = it->y = it->z = it->rgb = 0;
            }
            else 
            {
                it->x = X;
                it->y = p_data_cloud[index + 1];
                it->z = p_data_cloud[index + 2];
                it->rgb = convertColor(p_data_cloud[index + 3]); // Convert a 32bits float into a pcl .rgb format
            }
                index += 4;
                ++it;
            }
        }
mPtrPCViewer->showCloud(mPtrPointCloud);

То, что я хочу получить, это то, что два набора точек «слиты» в один кадр.Тем не менее, кажется, что эти два набора точек по-прежнему показаны отдельно один за другим.

Может ли кто-нибудь помочь объяснить, как действительно объединить два набора точек в одно облако?Спасибо

1 Ответ

0 голосов
/ 19 сентября 2018

(1) Создайте новое пустое облако точек, которое будет объединенным облаком точек в конце

pcl::PointCloud<pcl::PointXYZ>  mPtrPointCloud;

(2) Преобразование облаков точек в начало координат

pcl::PointCloud<pcl::PointXYZ> recieved_transformed;
Eigen::Transform<Scalar, 3, Eigen::Affine> recieved_transformation_mat(recieved.sensor_origin_ * recieved.sensor_orientation_);
pcl::transformPointCloud(recieved, recieved_transformed, recieved_transformation_mat);

pcl::PointCloud<pcl::PointXYZ> frame_transformed;
Eigen::Transform<Scalar, 3, Eigen::Affine> frame_transformation_mat(frame.sensor_origin_ * frame.sensor_orientation_);
pcl::transformPointCloud(frame, frame_transformed, frame_transformation_mat);

(3) Использованиеоператор + =

mPtrPointCloud += received_transformed;
mPtrPointCloud += frame_transformed;

(4) Визуализировать объединенное облако точек

mPtrPCViewer->showCloud(mPtrPointCloud);

Вот и все.Смотрите также пример http://pointclouds.org/documentation/tutorials/concatenate_clouds.php http://pointclouds.org/documentation/tutorials/matrix_transform.php

...