opencv里鼠标绘图程序运行一直提示error LNK2019: 无法解析的外部符号 _cvInpaint,该符号在函数 _main
#ifdef_CH_#pragmapackage<opencv>#endif#include"cv.h"#include"highgui.h"#include<stdio...
#ifdef _CH_
#pragma package <opencv>
#endif
#include "cv.h"
#include "highgui.h"
#include <stdio.h>
#include <stdlib.h>
#include "opencv2/photo/photo_c.h"
#include "opencv2/photo/photo.hpp"
IplImage* inpaint_mask = 0;
IplImage* img0 = 0, *img = 0, *inpainted = 0;
CvPoint prev_pt = {-1,-1};
void on_mouse( int event, int x, int y, int flags, void* zhang)
{
if( !img )
return;
if( event == CV_EVENT_LBUTTONUP || !(flags & CV_EVENT_FLAG_LBUTTON) )
prev_pt = cvPoint(-1,-1);
else if( event == CV_EVENT_LBUTTONDOWN )
prev_pt = cvPoint(x,y);
else if( event == CV_EVENT_MOUSEMOVE && (flags & CV_EVENT_FLAG_LBUTTON) )
{
CvPoint pt = cvPoint(x,y);
if( prev_pt.x < 0 )
prev_pt = pt;
cvLine( inpaint_mask, prev_pt, pt, cvScalarAll(255), 5, 8, 0 );
cvLine( img, prev_pt, pt, cvScalarAll(255), 5, 8, 0 );
prev_pt = pt;
cvShowImage( "image", img );
}
}
int main( int argc, char** argv )
{
char* filename = argc >= 2 ? argv[1] : (char*)"fruits.jpg";
if( (img0 = cvLoadImage(filename,-1)) == 0 )
return 0;
printf( "Hot keys: \n"
"\tESC - quit the program\n"
"\tr - restore the original image\n"
"\ti or ENTER - run inpainting algorithm\n"
"\t\t(before running it, paint something on the image)\n" );
cvNamedWindow( "image", 1 );
img = cvCloneImage( img0 );
inpainted = cvCloneImage( img0 );
inpaint_mask = cvCreateImage( cvGetSize(img), 8, 1 );
cvZero( inpaint_mask );
cvZero( inpainted );
cvShowImage( "image", img );
cvShowImage( "watershed transform", inpainted );
cvSetMouseCallback( "image", on_mouse, 0 );
for(;;)
{
int c = cvWaitKey(0);
if( (char)c == 27 )
break;
if( (char)c == 'r' )
{
cvZero( inpaint_mask );
cvCopy( img0, img,0 );
cvShowImage( "image", img );
}
if( (char)c == 'i' || (char)c == '\n' )
{
cvNamedWindow( "inpainted image", 1 );
cvInpaint( img, inpaint_mask, inpainted, 3, CV_INPAINT_TELEA );
cvShowImage( "inpainted image", inpainted );
}
}
return 1;
}
运行后一直提示:
1>on_mouse.c.obj : error LNK2019: 无法解析的外部符号 _cvInpaint,该符号在函数 _main 中被引用
1>d:\documents\visual studio 2010\Projects\on_mouse.c\Debug\on_mouse.c.exe : fatal error LNK1120: 1 个无法解析的外部命令 展开
#pragma package <opencv>
#endif
#include "cv.h"
#include "highgui.h"
#include <stdio.h>
#include <stdlib.h>
#include "opencv2/photo/photo_c.h"
#include "opencv2/photo/photo.hpp"
IplImage* inpaint_mask = 0;
IplImage* img0 = 0, *img = 0, *inpainted = 0;
CvPoint prev_pt = {-1,-1};
void on_mouse( int event, int x, int y, int flags, void* zhang)
{
if( !img )
return;
if( event == CV_EVENT_LBUTTONUP || !(flags & CV_EVENT_FLAG_LBUTTON) )
prev_pt = cvPoint(-1,-1);
else if( event == CV_EVENT_LBUTTONDOWN )
prev_pt = cvPoint(x,y);
else if( event == CV_EVENT_MOUSEMOVE && (flags & CV_EVENT_FLAG_LBUTTON) )
{
CvPoint pt = cvPoint(x,y);
if( prev_pt.x < 0 )
prev_pt = pt;
cvLine( inpaint_mask, prev_pt, pt, cvScalarAll(255), 5, 8, 0 );
cvLine( img, prev_pt, pt, cvScalarAll(255), 5, 8, 0 );
prev_pt = pt;
cvShowImage( "image", img );
}
}
int main( int argc, char** argv )
{
char* filename = argc >= 2 ? argv[1] : (char*)"fruits.jpg";
if( (img0 = cvLoadImage(filename,-1)) == 0 )
return 0;
printf( "Hot keys: \n"
"\tESC - quit the program\n"
"\tr - restore the original image\n"
"\ti or ENTER - run inpainting algorithm\n"
"\t\t(before running it, paint something on the image)\n" );
cvNamedWindow( "image", 1 );
img = cvCloneImage( img0 );
inpainted = cvCloneImage( img0 );
inpaint_mask = cvCreateImage( cvGetSize(img), 8, 1 );
cvZero( inpaint_mask );
cvZero( inpainted );
cvShowImage( "image", img );
cvShowImage( "watershed transform", inpainted );
cvSetMouseCallback( "image", on_mouse, 0 );
for(;;)
{
int c = cvWaitKey(0);
if( (char)c == 27 )
break;
if( (char)c == 'r' )
{
cvZero( inpaint_mask );
cvCopy( img0, img,0 );
cvShowImage( "image", img );
}
if( (char)c == 'i' || (char)c == '\n' )
{
cvNamedWindow( "inpainted image", 1 );
cvInpaint( img, inpaint_mask, inpainted, 3, CV_INPAINT_TELEA );
cvShowImage( "inpainted image", inpainted );
}
}
return 1;
}
运行后一直提示:
1>on_mouse.c.obj : error LNK2019: 无法解析的外部符号 _cvInpaint,该符号在函数 _main 中被引用
1>d:\documents\visual studio 2010\Projects\on_mouse.c\Debug\on_mouse.c.exe : fatal error LNK1120: 1 个无法解析的外部命令 展开
2个回答
展开全部
看好衫提示应该是辩数该函数的2个头文件 photo_c.h 和 photo.hpp 没有包含在cv.h内
我看你代码中已经包含了
#include "opencv2/photo/photo_c.h"
#include "opencv2/photo/photo.hpp"
还友灶腔是仔细查看下头文件和库文件吧 版本 路径等
我看你代码中已经包含了
#include "opencv2/photo/photo_c.h"
#include "opencv2/photo/photo.hpp"
还友灶腔是仔细查看下头文件和库文件吧 版本 路径等
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
debug和release里面lib没加全吧
追问
追答
http://blog.csdn.net/ldd901/article/details/5795799
是不是你创建的是win32的项目,改成空白的?
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询