我希望熟悉openCV和图像处理的人能尽快帮助我。
我对 openCV 和 VC++ 完全陌生,这是本周第三次遇到错误 LNK2019。
我知道这个错误意味着包含指定函数的 .lib 文件尚未链接到项目,并且代码顶部未包含相应的头文件。
但是这次基于这个网页我收集到 cvSmooth 是其中包含的函数,opencv_imgproc243d.lib
所以我添加了这个 .lib 作为Additional Dependencies
并写了这一行
#include "opencv2\imgproc\imgproc.hpp"
在我的代码顶部,但错误
error LNK2019: unresolved external symbol cvSmooth referenced in function "void __cdecl example2_4(struct _IplImage *)"
不会改变并且保持不变。
我真的很迷茫????
任何帮助将不胜感激,如果需要,请告诉我将代码作为已编辑部分添加到我的问题中。
它是错误的并且cvSmooth
属于另一个 .lib 文件吗?
根据 h3now 的建议编辑了我的问题部分
我的代码如下:
#include "stdafx.h"
#include "opencv\cv.h"
#include "opencv\highgui.h"
#include "opencv2\core\core.hpp"
#include "opencv2\imgproc\imgproc.hpp"
void example2_4( IplImage* image )
{
// Create some windows to show the input
// and output images in.
//
cvNamedWindow( "Example4-in",CV_WINDOW_AUTOSIZE );
cvNamedWindow( "Example4-out",CV_WINDOW_AUTOSIZE );
// Create a window to show our input image
//
cvShowImage( "Example4-in", image );
// Create an image to hold the smoothed output
//
IplImage* out = cvCreateImage(cvGetSize(image),IPL_DEPTH_8U,3);
// Do the smoothing
//
// Do the smoothing
//
cvSmooth( image, out, CV_GAUSSIAN, 3, 3 );
// Show the smoothed image in the output window
//
cvShowImage( "Example4-out", out );
// Be tidy
//
cvReleaseImage( &out );
// Wait for the user to hit a key, then clean up the windows
//
cvWaitKey( 0 );
cvDestroyWindow( "Example4-in" );
cvDestroyWindow( "Example4-out" );
}
int main(int argc, char* argv[])
{
IplImage* img = cvLoadImage(argv[1]);
example2_4( img );
cvReleaseImage( &img );
system("pause");
return 0;
}
例如,当我右键单击该函数cvCreateImage
并选择Go To Definition
一个名为 core_c.h 的文件时,就会打开。所以明白这个函数的原型是包含在core_c.h中的。
所以出于这个原因,我们明白我们应该在我们的代码顶部写#include "opencv2\core\core.hpp"
或(我认为使用两个代码中的任何一个都没有区别)并链接到项目以使用该功能#include "opencv2\core\core_c.h"
opency_core243d.lib
cvCreateImage
但是当我右键单击cvSmooth
并选择Go To Definition
时,什么都没有@ h3now
建议的解决方案是否适用于所有功能?
因为当我也右键单击 cvShowImage 时,什么也没有发生。