mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 03:00:14 +08:00
cloud collection finalize
This commit is contained in:
parent
5dc17f5d58
commit
f1c062c30a
@ -934,6 +934,8 @@ This 3D Widget defines a collection of clouds. ::
|
|||||||
void addCloud(InputArray cloud, InputArray colors, const Affine3d &pose = Affine3d::Identity());
|
void addCloud(InputArray cloud, InputArray colors, const Affine3d &pose = Affine3d::Identity());
|
||||||
//! All points in cloud have the same color
|
//! All points in cloud have the same color
|
||||||
void addCloud(InputArray cloud, const Color &color = Color::white(), Affine3d &pose = Affine3d::Identity());
|
void addCloud(InputArray cloud, const Color &color = Color::white(), Affine3d &pose = Affine3d::Identity());
|
||||||
|
//! Repacks internal structure to sinle cloud
|
||||||
|
void finalize();
|
||||||
};
|
};
|
||||||
|
|
||||||
viz::WCloudCollection::WCloudCollection
|
viz::WCloudCollection::WCloudCollection
|
||||||
@ -964,6 +966,12 @@ Adds a cloud to the collection.
|
|||||||
|
|
||||||
.. note:: In case there are four channels in the cloud, fourth channel is ignored.
|
.. note:: In case there are four channels in the cloud, fourth channel is ignored.
|
||||||
|
|
||||||
|
viz::WCloudCollection::finalize
|
||||||
|
-------------------------------
|
||||||
|
Finalizes cloud data by repacking to single cloud. Useful for large cloud collections to reduce memory usage
|
||||||
|
|
||||||
|
.. ocv:function:: void finalize()
|
||||||
|
|
||||||
viz::WCloudNormals
|
viz::WCloudNormals
|
||||||
------------------
|
------------------
|
||||||
.. ocv:class:: WCloudNormals
|
.. ocv:class:: WCloudNormals
|
||||||
|
@ -345,6 +345,8 @@ namespace cv
|
|||||||
void addCloud(InputArray cloud, InputArray colors, const Affine3d &pose = Affine3d::Identity());
|
void addCloud(InputArray cloud, InputArray colors, const Affine3d &pose = Affine3d::Identity());
|
||||||
//! All points in cloud have the same color
|
//! All points in cloud have the same color
|
||||||
void addCloud(InputArray cloud, const Color &color = Color::white(), const Affine3d &pose = Affine3d::Identity());
|
void addCloud(InputArray cloud, const Color &color = Color::white(), const Affine3d &pose = Affine3d::Identity());
|
||||||
|
//! Repacks internal structure to sinle cloud
|
||||||
|
void finalize();
|
||||||
};
|
};
|
||||||
|
|
||||||
class CV_EXPORTS WCloudNormals : public Widget3D
|
class CV_EXPORTS WCloudNormals : public Widget3D
|
||||||
|
@ -242,6 +242,24 @@ void cv::viz::WCloudCollection::addCloud(InputArray cloud, const Color &color, c
|
|||||||
addCloud(cloud, Mat(cloud.size(), CV_8UC3, color), pose);
|
addCloud(cloud, Mat(cloud.size(), CV_8UC3, color), pose);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cv::viz::WCloudCollection::finalize()
|
||||||
|
{
|
||||||
|
vtkSmartPointer<vtkLODActor> actor = vtkLODActor::SafeDownCast(WidgetAccessor::getProp(*this));
|
||||||
|
CV_Assert("Incompatible widget type." && actor);
|
||||||
|
|
||||||
|
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkPolyDataMapper::SafeDownCast(actor->GetMapper());
|
||||||
|
CV_Assert("Need to add at least one cloud." && mapper);
|
||||||
|
|
||||||
|
vtkSmartPointer<vtkAlgorithm> producer = mapper->GetInputConnection(0, 0)->GetProducer();
|
||||||
|
vtkSmartPointer<vtkAppendPolyData> append_filter = vtkAppendPolyData::SafeDownCast(producer);
|
||||||
|
append_filter->Update();
|
||||||
|
|
||||||
|
vtkSmartPointer<vtkPolyData> polydata = append_filter->GetOutput();
|
||||||
|
mapper->RemoveInputConnection(0, 0);
|
||||||
|
VtkUtils::SetInputData(mapper, polydata);
|
||||||
|
mapper->Modified();
|
||||||
|
}
|
||||||
|
|
||||||
template<> cv::viz::WCloudCollection cv::viz::Widget::cast<cv::viz::WCloudCollection>()
|
template<> cv::viz::WCloudCollection cv::viz::Widget::cast<cv::viz::WCloudCollection>()
|
||||||
{
|
{
|
||||||
Widget3D widget = this->cast<Widget3D>();
|
Widget3D widget = this->cast<Widget3D>();
|
||||||
|
@ -103,6 +103,7 @@ TEST(Viz, show_cloud_collection)
|
|||||||
ccol.addCloud(cloud, Color::white(), Affine3d().translate(Vec3d(0, 0, 0)).rotate(Vec3d(CV_PI/2, 0, 0)));
|
ccol.addCloud(cloud, Color::white(), Affine3d().translate(Vec3d(0, 0, 0)).rotate(Vec3d(CV_PI/2, 0, 0)));
|
||||||
ccol.addCloud(cloud, Color::blue(), Affine3d().translate(Vec3d(1, 0, 0)));
|
ccol.addCloud(cloud, Color::blue(), Affine3d().translate(Vec3d(1, 0, 0)));
|
||||||
ccol.addCloud(cloud, Color::red(), Affine3d().translate(Vec3d(2, 0, 0)));
|
ccol.addCloud(cloud, Color::red(), Affine3d().translate(Vec3d(2, 0, 0)));
|
||||||
|
ccol.finalize();
|
||||||
|
|
||||||
Viz3d viz("show_cloud_collection");
|
Viz3d viz("show_cloud_collection");
|
||||||
viz.setBackgroundColor(Color::mlab());
|
viz.setBackgroundColor(Color::mlab());
|
||||||
|
Loading…
Reference in New Issue
Block a user