8 #if (defined(_WIN32) || defined(_WIN64))
18 #if (defined(_WIN32) || defined(_WIN64))
19 ret = _mkdir(directory.c_str());
21 ret = mkdir(directory.c_str(), 0777);
23 if (ret == EEXIST) ret = 0;
28 cv::Mat frame = cv::Mat(h, w, CV_8UC3);
30 for(
int i = 0; i < w*h; i++) {
31 auto b =
data.data()[i + w*h * 0] * scale + mean;
32 frame.data[i*3+0] = (uint8_t)b;
34 for(
int i = 0; i < w*h; i++) {
35 auto g =
data.data()[i + w*h * 1] * scale + mean;
36 frame.data[i*3+1] = (uint8_t)g;
38 for(
int i = 0; i < w*h; i++) {
39 auto r =
data.data()[i + w*h * 2] * scale + mean;
40 frame.data[i*3+2] = (uint8_t)r;
45 cv::Mat
toMat(
const std::vector<uint8_t>&
data,
int w,
int h ,
int numPlanes,
int bpp){
50 frame = cv::Mat(h, w, CV_8UC3);
53 for(
int i = 0; i < w*h; i++) {
54 uint8_t b =
data.data()[i + w*h * 0];
55 frame.data[i*3+0] = b;
57 for(
int i = 0; i < w*h; i++) {
58 uint8_t g =
data.data()[i + w*h * 1];
59 frame.data[i*3+1] = g;
61 for(
int i = 0; i < w*h; i++) {
62 uint8_t r =
data.data()[i + w*h * 2];
63 frame.data[i*3+2] = r;
68 frame = cv::Mat(h, w, CV_8UC3);
69 for(
int i = 0; i < w*h*bpp; i+=3) {
71 b =
data.data()[i + 2];
72 g =
data.data()[i + 1];
73 r =
data.data()[i + 0];
74 frame.at<cv::Vec3b>( (i/bpp) / w, (i/bpp) % w) = cv::Vec3b(b,g,r);
81 frame = cv::Mat(h, w, CV_8UC3);
82 for(
int y = 0; y < h; y++){
83 for(
int x = 0; x < w; x++){
85 const uint16_t* fp16 = (
const uint16_t*) (
data.data() + (y*w+x)*bpp);
86 uint8_t r = (uint8_t) (fp16_ieee_to_fp32_value(fp16[0]) * 255.0f);
87 uint8_t g = (uint8_t) (fp16_ieee_to_fp32_value(fp16[1]) * 255.0f);
88 uint8_t b = (uint8_t) (fp16_ieee_to_fp32_value(fp16[2]) * 255.0f);
89 frame.at<cv::Vec3b>(y, x) = cv::Vec3b(b,g,r);
102 data.resize(bgr.cols * bgr.rows * 3);
103 for(
int y = 0; y < bgr.rows; y++){
104 for(
int x = 0; x < bgr.cols; x++){
105 auto p = bgr.at<cv::Vec3b>(y,x);
106 data[x + y*bgr.cols + 0 * bgr.rows*bgr.cols] = p[0];
107 data[x + y*bgr.cols + 1 * bgr.rows*bgr.cols] = p[1];
108 data[x + y*bgr.cols + 2 * bgr.rows*bgr.cols] = p[2];
117 double h1 = dstSize.width * (input.rows/(double)input.cols);
118 double w2 = dstSize.height * (input.cols/(double)input.rows);
119 if( h1 <= dstSize.height) {
120 cv::resize( input, output, cv::Size(dstSize.width, h1));
122 cv::resize( input, output, cv::Size(w2, dstSize.height));
125 int top = (dstSize.height-output.rows) / 2;
126 int down = (dstSize.height-output.rows+1) / 2;
127 int left = (dstSize.width - output.cols) / 2;
128 int right = (dstSize.width - output.cols+1) / 2;
130 cv::copyMakeBorder(output, output, top, down, left, right, cv::BORDER_CONSTANT, bgcolor );