fix(grpc): preserve BGR snapshot contract
This commit is contained in:
parent
d1b65507d7
commit
0bd6c548c6
@ -12,7 +12,6 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace cmvr::service;
|
using namespace cmvr::service;
|
||||||
@ -220,13 +219,6 @@ grpc::Status gRPCCameraServiceImpl::GetRGBImage(grpc::ServerContext* context,
|
|||||||
response->mutable_header()->set_success(true);
|
response->mutable_header()->set_success(true);
|
||||||
setCurrentTimestamp(response->mutable_header()->mutable_timestamp());
|
setCurrentTimestamp(response->mutable_header()->mutable_timestamp());
|
||||||
|
|
||||||
// FrameData::U8C3 is defined as RGB byte order. OpenCV/RealSense
|
|
||||||
// color frames are BGR, so normalize the single-frame contract here.
|
|
||||||
if (image.type() == CV_8UC3) {
|
|
||||||
cv::Mat rgb_image;
|
|
||||||
cv::cvtColor(image, rgb_image, cv::COLOR_BGR2RGB);
|
|
||||||
image = std::move(rgb_image);
|
|
||||||
}
|
|
||||||
auto imageType = image.type();
|
auto imageType = image.type();
|
||||||
if (imageType == CV_8UC1) {
|
if (imageType == CV_8UC1) {
|
||||||
response->mutable_color_frame()->set_type(api::FrameData::U8C1);
|
response->mutable_color_frame()->set_type(api::FrameData::U8C1);
|
||||||
@ -345,12 +337,9 @@ grpc::Status gRPCCameraServiceImpl::GetRGBDImages(grpc::ServerContext* context,
|
|||||||
response->mutable_header()->set_success(true);
|
response->mutable_header()->set_success(true);
|
||||||
setCurrentTimestamp(response->mutable_header()->mutable_timestamp());
|
setCurrentTimestamp(response->mutable_header()->mutable_timestamp());
|
||||||
|
|
||||||
// FrameData::U8C3 is defined as RGB byte order. OpenCV/RealSense
|
// color image is serialized in the existing OpenCV BGR byte order;
|
||||||
// color frames are BGR, so normalize the single-frame contract here.
|
// clients convert it once when constructing an RGB image.
|
||||||
if (color_image.type() == CV_8UC3) {
|
if (color_image.type() == CV_8UC3) {
|
||||||
cv::Mat rgb_image;
|
|
||||||
cv::cvtColor(color_image, rgb_image, cv::COLOR_BGR2RGB);
|
|
||||||
color_image = std::move(rgb_image);
|
|
||||||
response->mutable_color_frame()->set_type(api::FrameData::U8C3);
|
response->mutable_color_frame()->set_type(api::FrameData::U8C3);
|
||||||
}
|
}
|
||||||
else if (color_image.type() == CV_16UC3) {
|
else if (color_image.type() == CV_16UC3) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user