gpt4 book ai didi

opencv - 将RGB转换为灰色OpenCV时发生 fatal error

转载 作者:行者123 更新时间:2023-12-02 17:51:48 25 4
gpt4 key购买 nike

我是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 );
}

最佳答案

我添加了库imgproc。我正在使用opencv 2.3。对于此新闻

ALT + F7
配置属性->输入->其他依赖项->编辑
并复制此opencv_imgproc230.lib

关于opencv - 将RGB转换为灰色OpenCV时发生 fatal error ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18787696/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com