// Filter colors
Vec3b* colors_data = new Vec3b[nr_points];
- NanFilter::copy(colors, colors_data, cloud);
+ NanFilter::copyColor(colors, colors_data, cloud);
vtkSmartPointer<vtkUnsignedCharArray> scalars = vtkSmartPointer<vtkUnsignedCharArray>::New ();
scalars->SetNumberOfComponents (3);
{
Vec3b * colors_data = 0;
colors_data = new Vec3b[nr_points];
- NanFilter::copy(mesh.colors, colors_data, mesh.cloud);
+ NanFilter::copyColor(mesh.colors, colors_data, mesh.cloud);
scalars = vtkSmartPointer<vtkUnsignedCharArray>::New ();
scalars->SetNumberOfComponents (3);
Vec3b point_color;
poly_colors->GetTupleValue (i, point_color.val);
- //RGB or BGR? should we swap channels????
+ std::swap(point_color[0], point_color[2]); // RGB -> BGR
mesh_colors[i] = point_color;
}
}
return (true);
}
-bool cv::viz::Viz3d::VizImpl::addPolylineFromPolygonMesh (const Mesh3d& mesh, const std::string &id)
+bool cv::viz::Viz3d::VizImpl::addPolylineFromPolygonMesh (const Mesh3d& /*mesh*/, const std::string &/*id*/)
{
// CV_Assert(mesh.cloud.rows == 1 && mesh.cloud.type() == CV_32FC3);
//
void cv::viz::Viz3d::VizImpl::setWindowPosition (int x, int y) { window_->SetPosition (x, y); }
void cv::viz::Viz3d::VizImpl::setWindowSize (int xw, int yw) { window_->SetSize (xw, yw); }
-bool cv::viz::Viz3d::VizImpl::addPolygonMesh (const Mesh3d& mesh, const Mat& mask, const std::string &id)
+bool cv::viz::Viz3d::VizImpl::addPolygonMesh (const Mesh3d& /*mesh*/, const Mat& /*mask*/, const std::string &/*id*/)
{
// CV_Assert(mesh.cloud.type() == CV_32FC3 && mesh.cloud.rows == 1 && !mesh.polygons.empty ());
// CV_Assert(mesh.colors.empty() || (!mesh.colors.empty() && mesh.colors.size() == mesh.cloud.size() && mesh.colors.type() == CV_8UC3));
}
-bool cv::viz::Viz3d::VizImpl::updatePolygonMesh (const Mesh3d& mesh, const cv::Mat& mask, const std::string &id)
+bool cv::viz::Viz3d::VizImpl::updatePolygonMesh (const Mesh3d& /*mesh*/, const cv::Mat& /*mask*/, const std::string &/*id*/)
{
// CV_Assert(mesh.cloud.type() == CV_32FC3 && mesh.cloud.rows == 1 && !mesh.polygons.empty ());
// CV_Assert(mesh.colors.empty() || (!mesh.colors.empty() && mesh.colors.size() == mesh.cloud.size() && mesh.colors.type() == CV_8UC3));
}
return output;
}
+
+ static _Out* copyColor(const Mat& source, _Out* output, const Mat& nan_mask)
+ {
+ CV_Assert(DataDepth<_Tp>::value == source.depth() && source.size() == nan_mask.size());
+ CV_Assert(nan_mask.channels() == 3 || nan_mask.channels() == 4);
+ CV_DbgAssert(DataDepth<_Msk>::value == nan_mask.depth());
+
+ int s_chs = source.channels();
+ int m_chs = nan_mask.channels();
+
+ for(int y = 0; y < source.rows; ++y)
+ {
+ const _Tp* srow = source.ptr<_Tp>(y);
+ const _Msk* mrow = nan_mask.ptr<_Msk>(y);
+
+ for(int x = 0; x < source.cols; ++x, srow += s_chs, mrow += m_chs)
+ if (!isNan(mrow[0]) && !isNan(mrow[1]) && !isNan(mrow[2]))
+ {
+ *output = _Out(srow);
+ std::swap((*output)[0], (*output)[2]); // BGR -> RGB
+ ++output;
+ }
+ }
+ return output;
+ }
};
template<typename _Tp>
return table[nan_mask.depth() - 5](source, output, nan_mask);
}
+
+ template<typename _Tp>
+ static inline Vec<_Tp, 3>* copyColor(const Mat& source, Vec<_Tp, 3>* output, const Mat& nan_mask)
+ {
+ CV_Assert(nan_mask.depth() == CV_32F || nan_mask.depth() == CV_64F);
+
+ typedef Vec<_Tp, 3>* (*copy_func)(const Mat&, Vec<_Tp, 3>*, const Mat&);
+ const static copy_func table[2] = { &NanFilter::Impl<_Tp, float>::copyColor, &NanFilter::Impl<_Tp, double>::copyColor };
+
+ return table[nan_mask.depth() - 5](source, output, nan_mask);
+ }
};
struct ApplyAffine