Hi
I have a dump of camera captured image frames @30 fps (raw format). I am trying to create a video player by displaying these images using QImage simultaneously. The problem is that I do not know the correct format of these raw images. I tried using all the available format options. Using some format caused the images to be displayed with wrong color while with some other formats, the program crashed. Here is my code snippet:
void MainWindow::on_pushButton_play_clicked()
{
QDirIterator itAmp(Amp_dir, QDirIterator::NoIteratorFlags);// Amp_dir is the image dump directory
while (itAmp.hasNext() )
{
itAmp.next();
if(!(itAmp.fileName().compare(".")) || !(itAmp.fileName().compare(".."))) continue;
QFile Afile
(itAmp.
filePath());
Afile.
open(QFile::ReadOnly);
unsigned char* Adata = (unsigned char*)&Aarray.data()[0];
QImage Aimage
(Adata,
640,
480,
QImage::Format_RGB444);
// I Do not know the format of raw image. ui
->amplitude
->setPixmap
(QPixmap::fromImage(Aimage
));
repaint();
Afile.close();
QTest::qWait(1000/30);// wait for said time before displaying next image since we have 30 images in 1 second
}
}
void MainWindow::on_pushButton_play_clicked()
{
QDirIterator itAmp(Amp_dir, QDirIterator::NoIteratorFlags);// Amp_dir is the image dump directory
while (itAmp.hasNext() )
{
itAmp.next();
if(!(itAmp.fileName().compare(".")) || !(itAmp.fileName().compare(".."))) continue;
QFile Afile(itAmp.filePath());
Afile.open(QFile::ReadOnly);
QByteArray Aarray = Afile.readAll();
unsigned char* Adata = (unsigned char*)&Aarray.data()[0];
QImage Aimage(Adata,640,480,QImage::Format_RGB444);// I Do not know the format of raw image.
ui->amplitude->setPixmap(QPixmap::fromImage(Aimage));
repaint();
Afile.close();
QTest::qWait(1000/30);// wait for said time before displaying next image since we have 30 images in 1 second
}
}
To copy to clipboard, switch view to plain text mode
It would be very helpful if someone can provide me with a workaround for the format issue or point me to some other approach for creating such video player.
Bookmarks