4 #include <opencv2/imgcodecs.hpp>
5 #include <opencv2/imgproc.hpp>
6 #include <opencv2/opencv.hpp>
23 std::vector<unsigned char> buffer;
26 auto shape =
data->getShape();
31 cv::cvtColor(img, img, CV_RGB2BGR);
32 cv::imencode(
suffix, img, buffer);
33 return {buffer,
".rgb"};
38 cv::imencode(
suffix, img, buffer);
39 return {buffer,
".gs"};
43 cv::imencode(
suffix, img, buffer);
50 if (
data.suffix ==
".rgb")
52 cv::Mat img = cv::imdecode(
data.data, cv::IMREAD_COLOR);
53 cv::cvtColor(img, img, CV_BGR2RGB);
57 if (
data.suffix ==
".gs")
59 cv::Mat img = cv::imdecode(
data.data, cv::IMREAD_GRAYSCALE);
64 cv::Mat img = cv::imdecode(
data.data, cv::IMREAD_ANYCOLOR);