Skip to content

Commit a1794ec

Browse files
committed
Stream grayscale renders
1 parent d9d0d07 commit a1794ec

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

programs/sceneReconstruction/DynaFu.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,13 @@ class DynaFu : public KinectFusionAdapter
127127
handle->reset();
128128
}
129129

130-
void render(yarp::sig::ImageOf<yarp::sig::PixelRgb> & image) const override
130+
void render(yarp::sig::ImageOf<yarp::sig::PixelMono> & image) const override
131131
{
132132
cv::UMat umat;
133133
handle->render(umat);
134-
cv::Mat mat = umat.getMat(cv::ACCESS_RW);
135-
image = yarp::cv::fromCvMat<yarp::sig::PixelRgb>(mat);
134+
cv::Mat mat = umat.getMat(cv::ACCESS_FAST); // no memcpy
135+
const auto & temp = yarp::cv::fromCvMat<yarp::sig::PixelBgra>(mat); // no conversion
136+
image.copy(temp); // bgra to grayscale (single step convert+assign)
136137
}
137138

138139
private:

programs/sceneReconstruction/KinFu.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,13 @@ class KinFu : public KinectFusionAdapter
136136
handle->reset();
137137
}
138138

139-
void render(yarp::sig::ImageOf<yarp::sig::PixelRgb> & image) const override
139+
void render(yarp::sig::ImageOf<yarp::sig::PixelMono> & image) const override
140140
{
141141
cv::UMat umat;
142142
handle->render(umat);
143-
cv::Mat mat = umat.getMat(cv::ACCESS_RW);
144-
image = yarp::cv::fromCvMat<yarp::sig::PixelRgb>(mat);
143+
cv::Mat mat = umat.getMat(cv::ACCESS_FAST); // no memcpy
144+
const auto & temp = yarp::cv::fromCvMat<yarp::sig::PixelBgra>(mat); // no conversion
145+
image.copy(temp); // bgra to grayscale (single step convert+assign)
145146
}
146147

147148
private:

programs/sceneReconstruction/KinectFusionAdapter.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class KinectFusionAdapter
2929

3030
virtual void reset() = 0;
3131

32-
virtual void render(yarp::sig::ImageOf<yarp::sig::PixelRgb> & image) const = 0;
32+
virtual void render(yarp::sig::ImageOf<yarp::sig::PixelMono> & image) const = 0;
3333
};
3434

3535
std::unique_ptr<KinectFusionAdapter> makeKinFu(const yarp::os::Searchable & config, const yarp::sig::IntrinsicParams & intrinsic, int width, int height);

programs/sceneReconstruction/SceneReconstruction.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class SceneReconstruction : public yarp::os::RFModule,
6262
yarp::dev::PolyDriver cameraDriver;
6363
yarp::dev::IRGBDSensor * iRGBDSensor;
6464
yarp::os::RpcServer rpcServer;
65-
yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelRgb>> renderPort;
65+
yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelMono>> renderPort;
6666
};
6767

6868
} // namespace roboticslab

0 commit comments

Comments
 (0)