2. 安装Cmake,可以模缺漏到官网去下载并按默认设置安装安装即可。
此处注意一般vs采用的是win32编译器进行debug和release(即使你是安装的x64),所以下载cmake的时候应该下载32位版本,这样cmake编译出来旦烂的是32位的工程文件,x64的cmake编译的是64位工程文件。
3.打开Cmake,在第一行“Where is the source code”后面的那个“Browse Source...”按钮,选择OpenCV的安装路径。
运行了楼上给的命令之后,结碧冲果是这样渗销的:# g++ `pkg-config opencv --libs --cflags opencv` facedect.cpp -o facedect -static
/tmp/丛慧游cc8XhRf6.o: In function `find_face(_IplImage*)':
facedect.cpp:(.text+0x51): undefined reference to `cvCreateImage'
facedect.cpp:(.text+0xc0): undefined reference to `cvCreateImage'
facedect.cpp:(.text+0xdd): undefined reference to `cvCvtColor'
facedect.cpp:(.text+0xf7): undefined reference to `cvResize'
facedect.cpp:(.text+0x109): undefined reference to `cvEqualizeHist'
facedect.cpp:(.text+0x116): undefined reference to `cvClearMemStorage'
facedect.cpp:(.text+0x188): undefined reference to `cvHaarDetectObjects'
facedect.cpp:(.text+0x1c6): undefined reference to `cvReleaseImage'
facedect.cpp:(.text+0x1d1): undefined reference to `cvReleaseImage'
/tmp/cc8XhRf6.o: In function `isperson(char const*)':
facedect.cpp:(.text+0x21e): undefined reference to `cvLoad'
facedect.cpp:(.text+0x22f): undefined reference to `cvCreateMemStorage'
facedect.cpp:(.text+0x25a): undefined reference to `cvLoadImage'
facedect.cpp:(.text+0x27d): undefined reference to `cvReleaseImage'
facedect.cpp:(.text+0x289): undefined reference to `cvDestroyWindow'
collect2: ld returned 1 exit status
直接编写C 或者C++ 程序,然后分别用gcc,g++编译器生成可执行程序。1) C++程序版:启轿
#include <stdio.h>
#include <opencv2/opencv.hpp>
using namespace cv
int main(int argc, char** argv )
{
if ( argc != 2 )
{
printf("usage: DisplayImage.out <Image_Path>\悄卜肆n")
return -1
}
Mat image
image = imread( argv[1], 1 )
if ( !image.data )
{
printf("No image data \n")
return -1
}
namedWindow("弊逗Display Image", WINDOW_AUTOSIZE )
imshow("Display Image", image)
waitKey(0)
return 0
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)