Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How convert RealSenseID::Image RAW10_1080P to cv::Mat or What image format have array RealSense ID::Image::buffer? #149

Open
ZeosBios opened this issue Aug 14, 2022 · 0 comments

Comments

@ZeosBios
Copy link

ZeosBios commented Aug 14, 2022

I'm trying to convert Image RealSenseID::RAW10 to cv::Mat. I get an image from PreviewImageReadyCallback, as shown in the example: https://github.com/IntelRealSense/RealSenseID/blob/master/samples/cpp/preview.cc#L14. But in the finish, I have always gray square. The conversation I make like:

(previewMode=RAW10_1080P)
void ConvertToMat(unsigned char * buffer, unsigned int width, unsigned int height) {
        cv::Mat rgb;
        cv::Mat raw10Img(image.height, image.width, CV_16UC1, image.buffer);

        cv::cvtColor(raw10Img, rgb, cv::COLOR_BayerRG2RGB);
        cv::imwrite("myimage.png", rgb);
}

From web-camera API:
Callback will be used to provide RGB preview image
and into samples/README.md:
Run preview for few seconds. Preview callback prints information on each frame.images are rgb24
I’ll take that as "API return raw data in RGB format", but code bellow don’t work:

        cv::Mat rgb;
        cv::Mat raw10Img(image.height, image.width, CV_8UC3, image.buffer);

        cv::cvtColor(raw10Img, rgb, cv::COLOR_BGR2RGB);
        cv::imwrite("myimage.png", rgb);

What image format have array RealSense ID::Image::unsigned char * buffer in void On Preview ImageReady(const RealSense ID::Image image) when preview Mode=RAW10_1080P? And how much channels in frame?

@ZeosBios ZeosBios reopened this Aug 16, 2022
@ZeosBios ZeosBios changed the title How convert RealSenseID::Image RAW10_1080P to cv::Mat How convert RealSenseID::Image RAW10_1080P to cv::Mat or What image format have array RealSense ID::Image::buffer? Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant