27 cv::setUseOptimized(
true);
30 void getCloud(yarp::sig::PointCloudXYZNormalRGBA & cloudWithNormals)
const override
32 cv::UMat points, normals;
35 handle->getCloud(points, normals);
38 cv::Mat _points = points.getMat(cv::ACCESS_FAST);
39 cv::Mat _normals = normals.getMat(cv::ACCESS_FAST);
41 cloudWithNormals.resize(points.rows);
43 for (
auto i = 0; i < points.rows; i++)
45 const auto & point = _points.at<cv::Vec4f>(i);
46 const auto & normal = _normals.at<cv::Vec4f>(i);
47 cloudWithNormals(i) = {{point[0], point[1], point[2]}, {normal[0], normal[1], normal[2]}, 0};
51 void getPoints(yarp::sig::PointCloudXYZ & cloud)
const override
56 handle->getPoints(points);
59 cv::Mat _points = points.getMat(cv::ACCESS_FAST);
60 auto data =
const_cast<const char *
>(
reinterpret_cast<char *
>(_points.data));
62 cloud.fromExternalPC(data, yarp::sig::PointCloudBasicType::PC_XYZ_DATA, _points.rows, 1);
65 void getPose(yarp::sig::Matrix & pose)
const override
68 const auto & affine = handle->getPose().matrix;
73 for (
int i = 0; i < 4; i++)
75 for (
int j = 0; j < 4; j++)
77 pose(i, j) = affine(i, j);
82 bool update(
const yarp::sig::ImageOf<yarp::sig::PixelFloat> & depthFrame,
const yarp::sig::FlexImage & colorFrame)
override
86 auto & nonConstDepthFrame =
const_cast<yarp::sig::ImageOf<yarp::sig::PixelFloat> &
>(depthFrame);
87 cv::Mat mat = yarp::cv::toCvMat(nonConstDepthFrame);
90 mat.convertTo(umat, mat.type(), 1000.0);
92 std::lock_guard lock(mtx);
93 return handle->update(umat);
98 std::lock_guard lock(mtx);
102 void render(yarp::sig::FlexImage & image)
const override
107 handle->render(umat);
110 cv::Mat mat = umat.getMat(cv::ACCESS_FAST);
111 const auto & bgr = yarp::cv::fromCvMat<yarp::sig::PixelBgra>(mat);
117 mutable std::mutex mtx;
139void updateParam(TParams & params, TRet TParams::* param, const yarp::os::Searchable & config,