Quote Originally Posted by marcel View Post
Qt Code:
  1. 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....

Qt Code:
  1. void QtGLContext::GrabImage()
  2. {
  3. qDebug() << "### GrabImage gooo ";
  4. const QString unixt = QString("_%1").arg(unixtime);
  5. adesso.setDate(QDate::currentDate());
  6. const QString oggi = adesso.toString("d.M.yyyy");
  7. IplImage* img = cvQueryFrame( capture );
  8. QString cfileName = QFileDialog::getSaveFileName(this, "Export image",oggi+unixt+".bmp", "*.bmp");
  9. if (!cfileName.endsWith(".bmp")) {
  10. cfileName = cfileName+".bmp";
  11. }
  12. QByteArray infile = cfileName.toAscii();
  13. cvSaveImage(infile.data(),img);
  14. QImage *i=new QImage(cfileName);
  15. const QString pngfileName = cfileName.replace(".bmp",".png");
  16. if (!i->isNull()) {
  17. qDebug() << "### valid img ";
  18. i->save(pngfileName,"PNG",100);
  19. } else {
  20. qDebug() << "### noooo valid img ";
  21. return;
  22. }
  23. }
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




Qt Code:
  1. void QtGLContext::GrabAvi()
  2. {
  3. StopGrab(); /* dont display live cam opengl */
  4. qDebug() << "### avi gooo ";
  5.  
  6. int isColor=1;
  7. int fps=15;
  8. int frameW=640;
  9. int frameH=480;
  10. int nFrames=8;
  11.  
  12. CvVideoWriter* writer = cvCreateVideoWriter("out.avi", CV_FOURCC('M','J','P','G'),fps,cvSize(frameW,frameH),isColor);
  13.  
  14. for(int i=0;i<nFrames;i++){
  15. qDebug() << "### Frames " << i;
  16. IplImage* img = cvQueryFrame( capture );
  17. cvWriteFrame(writer, img);//add the frame to the file
  18. }
  19. qDebug() << "### loop end ..... ";
  20. cvReleaseVideoWriter(&writer);
  21. qDebug() << "### after write avi ";
  22. //////// cvReleaseCapture(&capture); /* crash all */
  23. /////StartGrab();
  24. }
To copy to clipboard, switch view to plain text mode