switched source to InputArrays
This commit is contained in:
parent
f610c295f2
commit
1615527426
@ -56,12 +56,9 @@ namespace cv
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// Point Cloud Widget implementation
|
/// Point Cloud Widget implementation
|
||||||
|
|
||||||
cv::viz::WCloud::WCloud(InputArray _cloud, InputArray _colors)
|
cv::viz::WCloud::WCloud(InputArray cloud, InputArray colors)
|
||||||
{
|
{
|
||||||
CV_Assert(!_cloud.empty() && !_colors.empty());
|
CV_Assert(!cloud.empty() && !colors.empty());
|
||||||
|
|
||||||
Mat cloud = _cloud.getMat();
|
|
||||||
Mat colors = _colors.getMat();
|
|
||||||
|
|
||||||
vtkSmartPointer<vtkCloudMatSource> cloud_source = vtkSmartPointer<vtkCloudMatSource>::New();
|
vtkSmartPointer<vtkCloudMatSource> cloud_source = vtkSmartPointer<vtkCloudMatSource>::New();
|
||||||
cloud_source->SetColorCloud(cloud, colors);
|
cloud_source->SetColorCloud(cloud, colors);
|
||||||
@ -81,10 +78,8 @@ cv::viz::WCloud::WCloud(InputArray _cloud, InputArray _colors)
|
|||||||
WidgetAccessor::setProp(*this, actor);
|
WidgetAccessor::setProp(*this, actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
cv::viz::WCloud::WCloud(InputArray _cloud, const Color &color)
|
cv::viz::WCloud::WCloud(InputArray cloud, const Color &color)
|
||||||
{
|
{
|
||||||
Mat cloud = _cloud.getMat();
|
|
||||||
|
|
||||||
vtkSmartPointer<vtkCloudMatSource> cloud_source = vtkSmartPointer<vtkCloudMatSource>::New();
|
vtkSmartPointer<vtkCloudMatSource> cloud_source = vtkSmartPointer<vtkCloudMatSource>::New();
|
||||||
cloud_source->SetCloud(cloud);
|
cloud_source->SetCloud(cloud);
|
||||||
|
|
||||||
|
@ -164,15 +164,11 @@ void cv::viz::unregisterAllWindows() { VizStorage::unregisterAll(); }
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// Read/write clouds. Supported formats: ply, stl, xyz, obj
|
/// Read/write clouds. Supported formats: ply, stl, xyz, obj
|
||||||
|
|
||||||
void cv::viz::writeCloud(const String& file, InputArray _cloud, InputArray _colors, InputArray _normals, bool binary)
|
void cv::viz::writeCloud(const String& file, InputArray cloud, InputArray colors, InputArray normals, bool binary)
|
||||||
{
|
{
|
||||||
CV_Assert(file.size() > 4 && "Extention is required");
|
CV_Assert(file.size() > 4 && "Extention is required");
|
||||||
String extention = file.substr(file.size()-4);
|
String extention = file.substr(file.size()-4);
|
||||||
|
|
||||||
Mat cloud = _cloud.getMat();
|
|
||||||
Mat colors = _colors.getMat();
|
|
||||||
Mat normals = _normals.getMat();
|
|
||||||
|
|
||||||
vtkSmartPointer<vtkCloudMatSource> source = vtkSmartPointer<vtkCloudMatSource>::New();
|
vtkSmartPointer<vtkCloudMatSource> source = vtkSmartPointer<vtkCloudMatSource>::New();
|
||||||
source->SetColorCloudNormals(cloud, colors, normals);
|
source->SetColorCloudNormals(cloud, colors, normals);
|
||||||
|
|
||||||
|
@ -71,12 +71,14 @@ namespace cv { namespace viz
|
|||||||
cv::viz::vtkCloudMatSource::vtkCloudMatSource() { SetNumberOfInputPorts(0); }
|
cv::viz::vtkCloudMatSource::vtkCloudMatSource() { SetNumberOfInputPorts(0); }
|
||||||
cv::viz::vtkCloudMatSource::~vtkCloudMatSource() {}
|
cv::viz::vtkCloudMatSource::~vtkCloudMatSource() {}
|
||||||
|
|
||||||
int cv::viz::vtkCloudMatSource::SetCloud(const Mat& cloud)
|
int cv::viz::vtkCloudMatSource::SetCloud(InputArray _cloud)
|
||||||
{
|
{
|
||||||
CV_Assert(cloud.depth() == CV_32F || cloud.depth() == CV_64F);
|
CV_Assert(_cloud.depth() == CV_32F || _cloud.depth() == CV_64F);
|
||||||
CV_Assert(cloud.channels() == 3 || cloud.channels() == 4);
|
CV_Assert(_cloud.channels() == 3 || _cloud.channels() == 4);
|
||||||
|
|
||||||
int total = cloud.depth() == CV_32F ? filterNanCopy<float>(cloud) : filterNanCopy<double>(cloud);
|
Mat cloud = _cloud.getMat();
|
||||||
|
|
||||||
|
int total = _cloud.depth() == CV_32F ? filterNanCopy<float>(cloud) : filterNanCopy<double>(cloud);
|
||||||
|
|
||||||
vertices = vtkSmartPointer<vtkCellArray>::New();
|
vertices = vtkSmartPointer<vtkCellArray>::New();
|
||||||
vertices->Allocate(vertices->EstimateSize(1, total));
|
vertices->Allocate(vertices->EstimateSize(1, total));
|
||||||
@ -87,15 +89,18 @@ int cv::viz::vtkCloudMatSource::SetCloud(const Mat& cloud)
|
|||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cv::viz::vtkCloudMatSource::SetColorCloud(const Mat &cloud, const Mat &colors)
|
int cv::viz::vtkCloudMatSource::SetColorCloud(InputArray _cloud, InputArray _colors)
|
||||||
{
|
{
|
||||||
int total = SetCloud(cloud);
|
int total = SetCloud(_cloud);
|
||||||
|
|
||||||
if (colors.empty())
|
if (_colors.empty())
|
||||||
return total;
|
return total;
|
||||||
|
|
||||||
CV_Assert(colors.depth() == CV_8U && colors.channels() <= 4 && colors.channels() != 2);
|
CV_Assert(_colors.depth() == CV_8U && _colors.channels() <= 4 && _colors.channels() != 2);
|
||||||
CV_Assert(colors.size() == cloud.size());
|
CV_Assert(_colors.size() == _cloud.size());
|
||||||
|
|
||||||
|
Mat cloud = _cloud.getMat();
|
||||||
|
Mat colors = _colors.getMat();
|
||||||
|
|
||||||
if (cloud.depth() == CV_32F)
|
if (cloud.depth() == CV_32F)
|
||||||
filterNanColorsCopy<float>(colors, cloud, total);
|
filterNanColorsCopy<float>(colors, cloud, total);
|
||||||
@ -105,25 +110,28 @@ int cv::viz::vtkCloudMatSource::SetColorCloud(const Mat &cloud, const Mat &color
|
|||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cv::viz::vtkCloudMatSource::SetColorCloudNormals(const Mat &cloud, const Mat &colors, const Mat &normals)
|
int cv::viz::vtkCloudMatSource::SetColorCloudNormals(InputArray _cloud, InputArray _colors, InputArray _normals)
|
||||||
{
|
{
|
||||||
int total = SetColorCloud(cloud, colors);
|
int total = SetColorCloud(_cloud, _colors);
|
||||||
|
|
||||||
if (normals.empty())
|
if (_normals.empty())
|
||||||
return total;
|
return total;
|
||||||
|
|
||||||
CV_Assert(normals.depth() == CV_32F || normals.depth() == CV_64F);
|
CV_Assert(_normals.depth() == CV_32F || _normals.depth() == CV_64F);
|
||||||
CV_Assert(normals.channels() == 3 || normals.channels() == 4);
|
CV_Assert(_normals.channels() == 3 || _normals.channels() == 4);
|
||||||
CV_Assert(normals.size() == cloud.size());
|
CV_Assert(_normals.size() == _cloud.size());
|
||||||
|
|
||||||
|
Mat cloud = _cloud.getMat();
|
||||||
|
Mat normals = _normals.getMat();
|
||||||
|
|
||||||
if (normals.depth() == CV_32F && cloud.depth() == CV_32F)
|
if (normals.depth() == CV_32F && cloud.depth() == CV_32F)
|
||||||
filterNanNormalsCopy<float, float>(colors, cloud, total);
|
filterNanNormalsCopy<float, float>(normals, cloud, total);
|
||||||
else if (normals.depth() == CV_32F && cloud.depth() == CV_64F)
|
else if (normals.depth() == CV_32F && cloud.depth() == CV_64F)
|
||||||
filterNanNormalsCopy<float, double>(colors, cloud, total);
|
filterNanNormalsCopy<float, double>(normals, cloud, total);
|
||||||
else if (normals.depth() == CV_64F && cloud.depth() == CV_32F)
|
else if (normals.depth() == CV_64F && cloud.depth() == CV_32F)
|
||||||
filterNanNormalsCopy<double, float>(colors, cloud, total);
|
filterNanNormalsCopy<double, float>(normals, cloud, total);
|
||||||
else if (normals.depth() == CV_64F && cloud.depth() == CV_64F)
|
else if (normals.depth() == CV_64F && cloud.depth() == CV_64F)
|
||||||
filterNanNormalsCopy<double, double>(colors, cloud, total);
|
filterNanNormalsCopy<double, double>(normals, cloud, total);
|
||||||
else
|
else
|
||||||
CV_Assert(!"Unsupported normals type");
|
CV_Assert(!"Unsupported normals type");
|
||||||
|
|
||||||
|
@ -61,9 +61,9 @@ namespace cv
|
|||||||
static vtkCloudMatSource *New();
|
static vtkCloudMatSource *New();
|
||||||
vtkTypeMacro(vtkCloudMatSource,vtkPolyDataAlgorithm);
|
vtkTypeMacro(vtkCloudMatSource,vtkPolyDataAlgorithm);
|
||||||
|
|
||||||
virtual int SetCloud(const Mat& cloud);
|
virtual int SetCloud(InputArray cloud);
|
||||||
virtual int SetColorCloud(const Mat &cloud, const Mat &colors = cv::Mat());
|
virtual int SetColorCloud(InputArray cloud, InputArray colors = noArray());
|
||||||
virtual int SetColorCloudNormals(const Mat &cloud, const Mat &colors = cv::Mat(), const Mat &normals = cv::Mat());
|
virtual int SetColorCloudNormals(InputArray cloud, InputArray colors = noArray(), InputArray normals = noArray());
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
vtkCloudMatSource();
|
vtkCloudMatSource();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user