fix(camera): normalize snapshot RGB channel order
This commit is contained in:
parent
8a98b77a04
commit
03476734d4
@ -12,6 +12,7 @@
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
|
||||
using namespace std;
|
||||
using namespace cmvr::service;
|
||||
@ -219,6 +220,13 @@ grpc::Status gRPCCameraServiceImpl::GetRGBImage(grpc::ServerContext* context,
|
||||
response->mutable_header()->set_success(true);
|
||||
setCurrentTimestamp(response->mutable_header()->mutable_timestamp());
|
||||
|
||||
// Keep the single-frame contract explicit: FrameData::U8C3 is RGB
|
||||
// byte order, while OpenCV/RealSense images are normally BGR.
|
||||
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();
|
||||
if (imageType == CV_8UC1) {
|
||||
response->mutable_color_frame()->set_type(api::FrameData::U8C1);
|
||||
@ -337,9 +345,12 @@ grpc::Status gRPCCameraServiceImpl::GetRGBDImages(grpc::ServerContext* context,
|
||||
response->mutable_header()->set_success(true);
|
||||
setCurrentTimestamp(response->mutable_header()->mutable_timestamp());
|
||||
|
||||
// color image is serialized in the existing OpenCV BGR byte order;
|
||||
// clients convert it once when constructing an RGB image.
|
||||
// Keep the single-frame contract explicit: FrameData::U8C3 is RGB
|
||||
// byte order, while OpenCV/RealSense images are normally BGR.
|
||||
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);
|
||||
}
|
||||
else if (color_image.type() == CV_16UC3) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user