2013-10-19 36 views

回答

0

爲什麼不使用

的main.cpp

int main(int argc, char** argv) { 
    CvCapture* capture = cvCaptureFromCAM(0); 

    int index = 0; 
    while(cvGrabFrame(capture)) { 
     /*Get webcam image!*/ 
     IplImage *camImg = cvRetrieveFrame(capture); 

     /*Save the image to the disk!*/ 
     string fileName = "tmp/" + int2str(index) + ".jpg"; 
     cvSaveImage(fileName.c_str(), screenShotImg); 

     index++; 

     int key = cvWaitKey(10); 
     if(key == 27) { 
      break; 
     } 
    } 

    cvReleaseCapture(&capture); 
    return 0; 
} 

TypeConvert.cpp

#include "TypeConvert.h" 

#include <iostream> 
#include <sstream> 

string int2str(int &num) { 
    string emptyStr; 
    stringstream ss(emptyStr); 
    ss << num; 

    return ss.str(); 
}