我是opencv的新手我试图将rgb视频转换为灰度但它总是给出错误错误LNK2019:函数_wmain中引用的未解析的外部符号_cvCvtColor 请告诉我我做错了什么
#include "stdafx.h"
#include "highgui.h"
#include <stdio.h>
#include <cv.h>
#include <tchar.h>
#include <highgui.h>
#include <stdio.h>
#include <conio.h>
#include <opencv2/imgproc/imgproc.hpp> // Gaussian Blur
#include <opencv2/core/core.hpp> // Basic OpenCV structures (cv::Mat, Scalar)
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <conio.h>
using namespace cv;
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
CvCapture* capture = 0;
capture = cvCreateFileCapture( "video.avi" );
if(!capture)
{
return -1;
}
IplImage *bgr_frame=cvQueryFrame(capture);//Init the video read
double fps = cvGetCaptureProperty (capture,CV_CAP_PROP_FPS);
CvSize size = cvSize((int)cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH),(int)cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT));
CvVideoWriter *writer = cvCreateVideoWriter("izlaz.avi",CV_FOURCC_DEFAULT,fps,size);
IplImage *grayScaleImage = cvCreateImage(size ,IPL_DEPTH_8U,1);
while( (bgr_frame=cvQueryFrame(capture)) != NULL )
{
cvCvtColor(bgr_frame, grayScaleImage, CV_BGR2GRAY);
cvWriteFrame( writer, grayScaleImage );
}
cvReleaseVideoWriter( &writer );
cvReleaseCapture( &capture );
}
答案 0 :(得分:1)
我添加了库imgproc。我正在使用opencv 2.3。对于这个新闻
ALT + F7 配置属性 - &gt;输入 - &gt;其他依赖关系 - &gt;编辑 并复制此opencv_imgproc230.lib
答案 1 :(得分:0)
尝试更新
#include
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\imgproc\imgproc.hpp>
#include <iostream>
int main (){
cv::Mat frame;
cv::VideoCapture cap("Grabbed video.avi");//("Wildlife.wmv");
int key =0;
cap>>frame;
cv::VideoWriter record("Grabbed2 video.avi",CV_FOURCC('M','J','P','G'), 30,frame.size(), 0);
while(key != 27){
if(cap.isOpened()){
cap >>frame;
if(!frame.empty()){
cv::cvtColor(frame,frame,CV_BGR2GRAY);
record<<frame;
imshow("fvakjb",frame);
}
}
else key =27;
//cv::cvtColor(frame,frame,CV_BGR2GRAY);
key= cv::waitKey(10);
}
record.release();
cap.release();
return 0;
}
答案 2 :(得分:0)
此外,
如果您使用的是cmake和qibuild,可以尝试使用它进行链接:
它会自动链接到相应的库并使其标题可用。
qi_use_lib(yourProgramName your libraries)
像这样:
qi_use_lib(getimages ALCOMMON ALPROXIES ALVISION OPENCV2_CORE OPENCV2_HIGHGUI OPENCV2_IMGPROC)