opencv并不能直接打开raw图像文件,所以这里我们要进行图像数据的拷贝;这里是基于QT的
直接上代码:
static quint8 v4l2ConstantFrame[INPUT_VIDEO_W*INPUT_VIDEO_H*1];
static quint8 v4l2ConstantFrame1[INPUT_VIDEO_W*INPUT_VIDEO_H*1];
bool MainWindow::lockRawLmagePixel()
{
memset(v4l2ConstantFrame,0,sizeof(v4l2ConstantFrame));
//if path is empty. set it
fileName.clear ();
QString fileDir = QApplication::applicationDirPath ();
fileName = QFileDialog::getOpenFileName(NULL,"open image",fileDir,"*.raw");
qDebug() << imagePath;
if (fileName.isEmpty())
qDebug() << "imagePath = " << fileName;
QFile raw(fileName);
if (!raw.open(QIODevice::ReadWrite)) {
qDebug() << "file open error";
}
qDebug() << "file open success";
raw.read((char*)v4l2ConstantFrame,1024*1280);
memcpy(v4l2ConstantFrame1,v4l2ConstantFrame