
Originally Posted by
marcel
IplImage* imgPtr = cvQueryFrame( capture );
IplImage* imgPtr = cvQueryFrame( capture );
To copy to clipboard, switch view to plain text mode
I am not really sure, but it seems that the image data ( pixel data ) is imgPtr->imageData.
I see you already have the image dimensions and the bit depth.
I suppose you will need a third party library to create an avi ( mplayer maybe? last time I checked it had the ability to encode video, or any other library you find fit ).
.
To grab and display image is not the problem
take a shoot here....
void QtGLContext::GrabImage()
{
qDebug() << "### GrabImage gooo ";
adesso.
setDate(QDate::currentDate());
const QString oggi
= adesso.
toString("d.M.yyyy");
IplImage* img = cvQueryFrame( capture );
QString cfileName
= QFileDialog::getSaveFileName(this,
"Export image",oggi
+unixt
+".bmp",
"*.bmp");
if (!cfileName.endsWith(".bmp")) {
cfileName = cfileName+".bmp";
}
cvSaveImage(infile.data(),img);
const QString pngfileName
= cfileName.
replace(".bmp",
".png");
if (!i->isNull()) {
qDebug() << "### valid img ";
i->save(pngfileName,"PNG",100);
} else {
qDebug() << "### noooo valid img ";
return;
}
}
void QtGLContext::GrabImage()
{
qDebug() << "### GrabImage gooo ";
const QString unixt = QString("_%1").arg(unixtime);
adesso.setDate(QDate::currentDate());
const QString oggi = adesso.toString("d.M.yyyy");
IplImage* img = cvQueryFrame( capture );
QString cfileName = QFileDialog::getSaveFileName(this, "Export image",oggi+unixt+".bmp", "*.bmp");
if (!cfileName.endsWith(".bmp")) {
cfileName = cfileName+".bmp";
}
QByteArray infile = cfileName.toAscii();
cvSaveImage(infile.data(),img);
QImage *i=new QImage(cfileName);
const QString pngfileName = cfileName.replace(".bmp",".png");
if (!i->isNull()) {
qDebug() << "### valid img ";
i->save(pngfileName,"PNG",100);
} else {
qDebug() << "### noooo valid img ";
return;
}
}
To copy to clipboard, switch view to plain text mode
Take avi from cam !!! or grab from source avi ... i not know....
i found
http://www.koders.com/cpp/fid8AC9F0D...5E42EF904.aspx
http://forum.hardware.fr/hfr/Program...et_90460_1.htm
void QtGLContext::GrabAvi()
{
StopGrab(); /* dont display live cam opengl */
qDebug() << "### avi gooo ";
int isColor=1;
int fps=15;
int frameW=640;
int frameH=480;
int nFrames=8;
CvVideoWriter* writer = cvCreateVideoWriter("out.avi", CV_FOURCC('M','J','P','G'),fps,cvSize(frameW,frameH),isColor);
for(int i=0;i<nFrames;i++){
qDebug() << "### Frames " << i;
IplImage* img = cvQueryFrame( capture );
cvWriteFrame(writer, img);//add the frame to the file
}
qDebug() << "### loop end ..... ";
cvReleaseVideoWriter(&writer);
qDebug() << "### after write avi ";
//////// cvReleaseCapture(&capture); /* crash all */
/////StartGrab();
}
void QtGLContext::GrabAvi()
{
StopGrab(); /* dont display live cam opengl */
qDebug() << "### avi gooo ";
int isColor=1;
int fps=15;
int frameW=640;
int frameH=480;
int nFrames=8;
CvVideoWriter* writer = cvCreateVideoWriter("out.avi", CV_FOURCC('M','J','P','G'),fps,cvSize(frameW,frameH),isColor);
for(int i=0;i<nFrames;i++){
qDebug() << "### Frames " << i;
IplImage* img = cvQueryFrame( capture );
cvWriteFrame(writer, img);//add the frame to the file
}
qDebug() << "### loop end ..... ";
cvReleaseVideoWriter(&writer);
qDebug() << "### after write avi ";
//////// cvReleaseCapture(&capture); /* crash all */
/////StartGrab();
}
To copy to clipboard, switch view to plain text mode
Bookmarks