opencv读取RAW图像

// 读取RAW图像
//cv::Mat raw_image = cv::imread("E:/016.raw", cv::IMREAD_UNCHANGED);

// 显示RAW图像
/*cv::imshow("RAW Image", raw_image);*/

const std::string path = "E:/defect-g3.raw";
std::ifstream fin;
fin.open(path, std::ios::binary);
//需要偏移的65536字节,有的图像没有偏移头帧;
fin.seekg(65536, fin.end);
int len = fin.tellg();
fin.seekg(0, fin.beg);
qDebug() << "file length" << len;
//图像的宽w,高h;
const int imageSize = w* h;
unsigned short* buf = new unsigned short[imageSize];
fin.read(reinterpret_cast<char*>(buf), imageSize * sizeof(unsigned short));
cv::Mat img(cv::Size(w, h), CV_16UC1, buf);
cv::imshow("test", img);
posted @ 2023-12-25 14:42  力能扛鼎的5270  阅读(680)  评论(0编辑  收藏  举报