Connecting OpenCV with netbeans 7.3.1



我正在尝试使用Netbeans 7.3.1的OpenCV。我试过各种教程和博客但不能运行的任何文件。以下代码被列为检查opencv安装的良好示例代码:

#include <cstdlib>
using namespace std;
#include "opencv.hpp"
#include "opencv_modules.hpp"
int main ( int argc, char **argv ) { 
    cvNamedWindow( "My Window", 1 ); 
    IplImage *img = cvCreateImage( cvSize( 640, 480 ), IPL_DEPTH_8U, 1 ); 
    CvFont font; 
    double hScale = 1.0; 
    double vScale = 1.0; 
    int lineWidth = 1; 
    cvInitFont( &font, CV_FONT_HERSHEY_SIMPLEX | CV_FONT_ITALIC, hScale, vScale, 0, lineWidth ); 
    cvPutText( img, "Hello World!, I can now code openCV ", cvPoint( 0, 200 ), &font, Scalar    
    (255, 255, 0 ) ); 
    cvPutText( img, "in a kickass IDE ", cvPoint( 150, 300 ), &font, cvScalar( 255, 255, 0 ) ); 
    cvShowImage( "My Window", img ); 
    cvWaitKey(); 
return 0; 
}

代码导致以下错误:"/usr/bin/make" -f nbproject/Makefile-Debug。mkqmake = SUBPROJECTS= .build-confmake[1]:进入目录/cygdrive/c/Users/Daniel/Documents/NetBeansProjects/CppApplication_4' "/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin_1-Windows/cppapplication_4.exe make[2]: Entering directory/cygdrive/c/Users/Daniel/Documents/NetBeansProjects/CppApplication_4'mkdir -p build/Debug/Cygwin_1-Windowsrm -f build/Debug/Cygwin_1-Windows/main.o.dg++ -c -g -I…/…/…/Program Files/OpenCV/build/include/opencv2 -MMD -MP -MF build/Debug/Cygwin_1-Windows/main.od -o build/Debug/Cygwin_1-Windows/maino main.cpp在main.cpp:11中包含的文件中:../../../../../Program Files/OpenCV/build/include/opencv2/OpenCV .hpp:46:33: opencv2/core/core_c.h: No such file or directory../../../../../Program Files/OpenCV/build/include/opencv2/OpenCV .hpp:47:33: opencv2/core/core.hpp: No such file or directory../../../../../Program Files/OpenCV/build/include/opencv2/OpenCV .hpp:48:39: opencv2/flann/miniflann.hpp: No such file or directory../../../../../Program Files/OpenCV/build/include/opencv2/OpenCV .hpp:49:39: opencv2/imgproc/imgproc_c.h: No such file or directory../../../../../Program Files/OpenCV/build/include/opencv2/OpenCV .hpp:50:39: opencv2/imgproc/imgproc.hpp: No such file or directory../../../../../Program Files/OpenCV/build/include/opencv2/OpenCV .hpp:51:35: opencv2/photo/photo.hpp: No such file or directory../../../../../Program Files/OpenCV/build/include/opencv2/OpenCV .hpp:52:35: opencv2/video/video.hpp: No such file or directory../../../../../Program Files/OpenCV/build/include/opencv2/OpenCV .hpp:53:45: opencv2/features2d/features2d.hpp: No such file or directory../../../../../Program Files/OpenCV/build/include/opencv2/OpenCV .hpp:54:43: opencv2/objdetect/objdetect.hpp: No such file or directory../../../../../Program Files/OpenCV/build/include/opencv2/OpenCV .hpp:55:39: opencv2/calib3d/calib3d.hpp: No such file or directory../../../../../Program Files/OpenCV/build/include/opencv2/OpenCV .hpp:56:29: opencv2/ml/ml.hpp: No such file or directory../../../../../Program Files/OpenCV/build/include/opencv2/OpenCV .hpp:57:39: opencv2/highgui/highgui_c.h: No such file or directory../../../../../Program Files/OpenCV/build/include/opencv2/OpenCV .hpp:58:39: opencv2/highgui/highgui.hpp: No such file or directory../../../../../Program Files/OpenCV/build/include/opencv2/OpenCV .hpp:59:39: opencv2/contrib/contrib.hpp: No such file or directorymain.cpp:在int main(int, char**)': main.cpp:14: error:函数中cvNamedWindow'未声明(首先使用此函数)main.cpp:14: error:(每个未声明的标识符只在它出现的每个函数中报告一次。)main.cpp:15:错误:IplImage' undeclared (first use this function) main.cpp:15: error: img'未声明(第一次使用这个函数)main.cpp:15:错误:cvSize' undeclared (first use this function) main.cpp:15: error: IPL_DEPTH_8U'未声明(第一次使用此函数)main.cpp:15:错误:cvCreateImage' undeclared (first use this function) main.cpp:16: error: CvFont'未声明(第一次使用此函数)main.cpp:16: error: expected ;' before "font" main.cpp:17: error: font'未声明(第一次使用这个函数)main.cpp:17: error: CV_FONT_HERSHEY_SIMPLEX' undeclared (first use this function) main.cpp:17: error: CV_FONT_ITALIC'未声明(第一次使用此函数)main.cpp:17:错误:cvInitFont' undeclared (first use this function) main.cpp:18: error: cvPoint'未声明(第一次使用此函数)main.cpp:18:错误:cvScalar' undeclared (first use this function) main.cpp:18: error: cvPutText'未声明(第一次使用此函数)main.cpp:20:错误:cvShowImage' undeclared (first use this function) main.cpp:21: error: cvWaitKey'未声明(第一次使用此函数)nbproject/Makefile-Debug。mk:86:配方的目标build/Debug/Cygwin_1-Windows/main.o' failed make[2]: *** [build/Debug/Cygwin_1-Windows/main.o] Error 1 make[2]: Leaving directory/cygdrive/c/Users/Daniel/Documents/NetBeansProjects/CppApplication_4'nbproject/Makefile-Debug。mk:59:配方的目标.build-conf' failed make[1]: *** [.build-conf] Error 2 make[1]: Leaving directory/cygdrive/c/Users/Daniel/Documents/NetBeansProjects/CppApplication_4'nbproject/Makefile-impl。Mk:39:目标的配方。build-impl的失败Make: *[。build-impl] Error 2

BUILD FAILED (exit value 2, total time: 2s)

有没有人可以提供一套清晰的说明,或者至少指向一个简明的指南?

谢谢,丹尼尔

假设您的包含路径包含C:Program FilesOpenCVinclude,并且包含文件确实位于那里,替换

#include "opencv.hpp"

#include "opencv2/opencv.hpp"

你可能不需要#include "opencv_modules.hpp",否则应该是#include "opencv2/opencv_modules.hpp"

相关内容

  • 没有找到相关文章

最新更新