原始RAW数据是16位的,代码如下:
void saveToTiff(const std::string &sourcePath, const std::string &destPath)
{
cv::Mat input_image(IMAGEHEIGHT,IMAGEWIDTH,CV_16UC1);
std::ifstream in(sourcePath, std::ios::in | std::ios::binary);
if (!in) {
qDebug()<< "Open raw image file fail!";
return;
}
else {
in.read((char*)(input_image.data), IMAGEHEIGHT * IMAGEWIDTH * sizeof(uint16_t));
}
in.close();
if(!cv::imwrite(destPath,input_image))
{
qDebug()<<"save to tiff failed";
}
}