读取 rgb planner 二进制数据 resize 重采样

2022/4/23 6:21:10

本文主要是介绍读取 rgb planner 二进制数据 resize 重采样,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

#include <fstream> #include <iostream> #include <opencv2/opencv.hpp>
using namespace cv; using namespace std;
int main(int argc, char **argv) {     const uint32_t cols = 640;     const uint32_t rows = 426;
    ifstream fin0("000000000139.planner", ios::in | ios::binary);     if(!fin0.is_open())     {         cout << "open fail!\n";         return 1;     }
    Mat img0_r = Mat::zeros(rows, cols, CV_8UC1);     Mat img0_g = Mat::zeros(rows, cols, CV_8UC1);     Mat img0_b = Mat::zeros(rows, cols, CV_8UC1);
    fin0.read(&img0_r.at< char >(0, 0), sizeof(char) * rows * cols);     fin0.read(&img0_g.at< char >(0, 0), sizeof(char) * rows * cols);     fin0.read(&img0_b.at< char >(0, 0), sizeof(char) * rows * cols);     fin0.close();
    Mat channels[3] = { img0_b, img0_g, img0_r };     Mat img0;     merge(channels, 3, img0);
    Mat imgDst = Mat::zeros(224, 224, CV_8UC3);     resize(img0, imgDst, imgDst.size(), 0, 0, INTER_LINEAR);
    imwrite("out2.jpg", imgDst);
    return 0; }

这篇关于读取 rgb planner 二进制数据 resize 重采样的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程