由 zelda1228 » 2011-07-29 12:28
我是用VSC++的button寫的,目的是要將視訊的畫面轉存為AVI,起初是用opencv2.0寫的,但是cvCreateVideoWriter函式一直過不了,故改用opencv2.2去編譯,過了是過了,但是卻不會轉存,只會顯示webcam的畫面
private: System::Void button8_Click(System::Object^ sender, System::EventArgs^ e) {
//frameH=(int)cvGetCaptureProperty(capture,CV_CAP_PROP_FRAME_HEIGHT);
//frameW=(int)cvGetCaptureProperty(capture,CV_CAP_PROP_FRAME_WIDTH);
//webcam程式碼存成AVI檔
CvCapture *capture;
IplImage *frame;
capture=cvCreateCameraCapture(0);
cvNamedWindow("play",0);
CvVideoWriter *writer;
/*char AviFileName[]="Output.avi";
int AviForamt = -1;
int FPS = 15;
CvSize AviSize = cvSize(640,480);
int AviColor = 1; */
//writer=cvCreateVideoWriter(AviFileName,AviForamt,FPS,AviSize,1);
writer = cvCreateVideoWriter( "Output.avi ", CV_FOURCC('F', 'L', 'V', '1'), 15 , cvSize(320,240), 1 ) ;//arg3:640*480
//cvCreateVideoWriter第二個引數 影片格式如下
//CV_FOURCC('P','I','M','1') MPEG-1 codec
//CV_FOURCC('M','J','P','G') motion-jpeg codec (does not work well)
//CV_FOURCC('M', 'P', '4', '2') MPEG-4.2 codec
//CV_FOURCC('D', 'I', 'V', '3') MPEG-4.3 codec
//CV_FOURCC('D', 'I', 'V', 'X') MPEG-4 codec
//CV_FOURCC('U', '2', '6', '3') H263 codec
//CV_FOURCC('I', '2', '6', '3') H263I codec
//CV_FOURCC('F', 'L', 'V', '1') FLV1 codec
//writer=cvCreateVideoWriter("out.avi",-1,fps,cvSize(pFrame->width, pFrame->height),isColor);cvWriteFrame(writer,pFrame1);
//int AviForamt=CV_FOURCC('P','I','M','1');
int i=0;
while(true)
{
frame = cvQueryFrame(capture);
cvWriteFrame(writer,frame);
cvShowImage("play",frame);
printf("%d\n",i);
if(cvWaitKey(20)>0) break;
i++;
}
cvReleaseCapture(&capture);
cvReleaseVideoWriter(&writer);
cvDestroyWindow("play");
//多個Webcam的程式實作
/*
CvCapture *capture0;
CvCapture *capture1;
IplImage *frame0;
IplImage *frame1;
capture0 =cvCaptureFromCAM(0);
capture1 =cvCaptureFromCAM(0);
cvNamedWindow("Webcam0",1);
cvNamedWindow("Webcam1",1);
while(true)
{
frame0 = cvQueryFrame(capture0);
frame1 = cvQueryFrame(capture1);
cvShowImage("Webcam0",frame0);
cvShowImage("Webcam1",frame1);
if(cvWaitKey(10)>=0)
{
break;
}
}
cvReleaseCapture(&capture0);
cvDestroyWindow("Webcam0");
*/
}
按了重新生成之後,就跑出以下問題了,沒有按之前都可以執行..................求救~!!!!!!!!
project setting的link有添加相应的库!!!!
opencv_core220d.lib
opencv_highgui220d.lib
opencv_video220d.lib
opencv_ml220d.lib
opencv_legacy220d.lib
opencv_imgproc220d.lib
還是不行!!!
1>OPENCV.obj : warning LNK4248: 無法解析的 typeref 語彙基元 (01000028) (對 'CvVideoWriter' 而言),映像可能無法執行
1>OPENCV.obj : warning LNK4248: 無法解析的 typeref 語彙基元 (01000029) (對 'CvCapture' 而言),映像可能無法執行
1>OPENCV.obj : warning LNK4248: 無法解析的 typeref 語彙基元 (0100002A) (對 '_CvContourScanner' 而言),映像可能無法執行
1>OPENCV.obj : error LNK2001: 無法解析的外部符號 "public: virtual void __thiscall cv::HOGDescriptor::setSVMDetector(class std::vector<float,class std::allocator<float> > const &)" (?setSVMDetector@HOGDescriptor@cv@@UAEXABV?$vector@MV?$allocator@M@std@@@std@@@Z)
1>OPENCV.obj : error LNK2001: 無法解析的外部符號 "public: virtual bool __thiscall cv::HOGDescriptor::read(class cv::FileNode &)" (?read@HOGDescriptor@cv@@UAE_NAAVFileNode@2@@Z)
1>OPENCV.obj : error LNK2001: 無法解析的外部符號 "public: virtual void __thiscall cv::HOGDescriptor::write(class cv::FileStorage &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)const " (?write@HOGDescriptor@cv@@UBEXAAVFileStorage@2@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>OPENCV.obj : error LNK2001: 無法解析的外部符號 "public: virtual bool __thiscall cv::HOGDescriptor::load(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?load@HOGDescriptor@cv@@UAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0@Z)
1>OPENCV.obj : error LNK2001: 無法解析的外部符號 "public: virtual void __thiscall cv::HOGDescriptor::save(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)const " (?save@HOGDescriptor@cv@@UBEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0@Z)
1>OPENCV.obj : error LNK2001: 無法解析的外部符號 "public: virtual void __thiscall cv::HOGDescriptor::copyTo(struct cv::HOGDescriptor &)const " (?copyTo@HOGDescriptor@cv@@UBEXAAU12@@Z)
1>OPENCV.obj : error LNK2001: 無法解析的外部符號 "public: virtual void __thiscall cv::HOGDescriptor::compute(class cv::Mat const &,class std::vector<float,class std::allocator<float> > &,class cv::Size_<int>,class cv::Size_<int>,class std::vector<class cv::Point_<int>,class std::allocator<class cv::Point_<int> > > const &)const " (?compute@HOGDescriptor@cv@@UBEXABVMat@2@AAV?$vector@MV?$allocator@M@std@@@std@@V?$Size_@H@2@2ABV?$vector@V?$Point_@H@cv@@V?$allocator@V?$Point_@H@cv@@@std@@@5@@Z)
1>OPENCV.obj : error LNK2001: 無法解析的外部符號 "public: virtual void __thiscall cv::HOGDescriptor::detect(class cv::Mat const &,class std::vector<class cv::Point_<int>,class std::allocator<class cv::Point_<int> > > &,double,class cv::Size_<int>,class cv::Size_<int>,class std::vector<class cv::Point_<int>,class std::allocator<class cv::Point_<int> > > const &)const " (?detect@HOGDescriptor@cv@@UBEXABVMat@2@AAV?$vector@V?$Point_@H@cv@@V?$allocator@V?$Point_@H@cv@@@std@@@std@@NV?$Size_@H@2@2ABV45@@Z)
1>OPENCV.obj : error LNK2001: 無法解析的外部符號 "public: virtual void __thiscall cv::HOGDescriptor::detectMultiScale(class cv::Mat const &,class std::vector<class cv::Rect_<int>,class std::allocator<class cv::Rect_<int> > > &,double,class cv::Size_<int>,class cv::Size_<int>,double,int)const " (?detectMultiScale@HOGDescriptor@cv@@UBEXABVMat@2@AAV?$vector@V?$Rect_@H@cv@@V?$allocator@V?$Rect_@H@cv@@@std@@@std@@NV?$Size_@H@2@2NH@Z)
1>OPENCV.obj : error LNK2001: 無法解析的外部符號 "public: virtual void __thiscall cv::HOGDescriptor::computeGradient(class cv::Mat const &,class cv::Mat &,class cv::Mat &,class cv::Size_<int>,class cv::Size_<int>)const " (?computeGradient@HOGDescriptor@cv@@UBEXABVMat@2@AAV32@1V?$Size_@H@2@2@Z)
1>C:\Users\Devil-Zelda\OPENCV\Debug\OPENCV.exe : fatal error LNK1120: 10 個無法解析的外部符號