I have a code in C++ based on QT running on windows built using visual studio 2017.
In this there is a vector of pixmap images.
QVector<QPixmap> imageVector;
The images in the vector we need to write to video file for which we use open cv.
VideoWriter video;
for (long i = 0; i < imageVector.size(); ++i)
{
QPixmap originalPixmap = imageVector.at(i);
QImage qImageSingle = originalPixmap->toImage(); // Convert QPixmap to QImage
if(qImageSingle.width() != 0 && qImageSingle.height() != 0)
{
video.open("C:\\temp\\signals.avi",
// CV_FOURCC_DEFAULT,
/// CV_FOURCC('M','J','P','G'),
CV_FOURCC('D','I','V','X'),
25, Size(qImageSingle.width(), qImageSingle.height()), 1);
break;
}
}
for (long i = 0; i < imageVector.size(); ++i)
{
QPixmap originalPixmap = imageVector.at(i);
QImage qImageSingle = originalPixmap->toImage(); // Convert QPixmap to QImage
if(qImageSingle.width() != 0 && qImageSingle.height() != 0)
{
Mat trialFrame;
trialFrame = Mat(qImageSingle.height(), qImageSingle.width(), CV_8UC3, qImageSingle.bits(), qImageSingle.bytesPerLine()).clone();
if (trialFrame.channels()== 3)
{
Mat trialRGBframe;
cvtColor(trialFrame, trialRGBframe, CV_BGR2RGB);
if(trialRGBframe.empty() == true)
{
}
else
{
video.write(trialRGBframe);
}
}
}
}
video.release();
The images in the vector we need to write to video file for which we use open cv.
Created Video Screenshot
Original videos screenshot is clear.
How to rectify this issue and create proper video?