width; 步长=img->widthStep; 通道=img->n通道; 数据=(uchar*)img->imageData; printf(“使用%d个通道处理%dx%d个图像\n”,高度、宽度、通道); //创建一个窗口 cvNamedWindow(“mainWin”,CV_窗口_自动调整大小); cvMoveWindow(“mainWin”,100100); //反转图像 对于(i=0;i,c,netbeans,opencv,C,Netbeans,Opencv" /> width; 步长=img->widthStep; 通道=img->n通道; 数据=(uchar*)img->imageData; printf(“使用%d个通道处理%dx%d个图像\n”,高度、宽度、通道); //创建一个窗口 cvNamedWindow(“mainWin”,CV_窗口_自动调整大小); cvMoveWindow(“mainWin”,100100); //反转图像 对于(i=0;i,c,netbeans,opencv,C,Netbeans,Opencv" />

opencv不使用NetBeans 我尝试用NETBeCon上的OpenCV编写C++中的简单图像修饰符程序。我正在使用ubuntu 10.04。每次我尝试运行或编译它时,它都会返回以下错误。我在链接器和其他工具中配置了opencv。出什么事了 include stdlib.h include stdio.h include math.h include cv.h include highgui.h int main(int argc, char *argv[]) { IplImage* img = 0; int height,width,step,channels; uchar *data; int i,j,k; if(argc<2){ printf("Usage: main <image-file-name>\n\7"); exit(0); } // load an image img=cvLoadImage(argv[1]); if(!img){ printf("Could not load image file: %s\n",argv[1]); exit(0); } // get the image data height = img->height; width = img->width; step = img->widthStep; channels = img->nChannels; data = (uchar *)img->imageData; printf("Processing a %dx%d image with %d channels\n",height,width,channels); // create a window cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE); cvMoveWindow("mainWin", 100, 100); // invert the image for(i=0;i<height;i++) for(j=0;j<width;j++) for(k=0;k<channels;k++) data[i*step+j*channels+k]=255-data[i*step+j*channels+k]; // show the image cvShowImage("mainWin", img ); // wait for a key cvWaitKey(0); // release the image cvReleaseImage(&img ); return 0; } "/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf make[1]: Entering directory `/home/kevin/NetBeansProjects/CppApplication_4' "/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/cppapplication_4 make[2]: Entering directory `/home/kevin/NetBeansProjects/CppApplication_4' mkdir -p build/Debug/GNU-Linux-x86 rm -f build/Debug/GNU-Linux-x86/main.o.d g++ -c -g -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/ main.o main.cpp main.cpp:4:16: warning: cv.h: No such file or directory main.cpp:5:21: warning: highgui.h: No such file or directory main.cpp: In function ‘int main(int, char**)’: main.cpp:10: error: ‘IplImage’ was not declared in this scope main.cpp:10: error: ‘img’ was not declared in this scope main.cpp:12: error: ‘uchar’ was not declared in this scope main.cpp:12: error: ‘data’ was not declared in this scope main.cpp:21: error: ‘cvLoadImage’ was not declared in this scope main.cpp:32: error: expected primary-expression before ‘)’ token main.cpp:32: error: expected ‘;’ before ‘img’ main.cpp:36: error: ‘CV_WINDOW_AUTOSIZE’ was not declared in this scope main.cpp:36: error: ‘cvNamedWindow’ was not declared in this scope main.cpp:37: error: ‘cvMoveWindow’ was not declared in this scope main.cpp:44: error: ‘cvShowImage’ was not declared in this scope main.cpp:47: error: ‘cvWaitKey’ was not declared in this scope main.cpp:50: error: ‘cvReleaseImage’ was not declared in this scope make[2]: *** [build/Debug/GNU-Linux-x86/main.o] Error 1 make[1]: *** [.build-conf] Error 2 make: *** [.build-impl] Error 2 make[2]: Leaving directory `/home/kevin/NetBeansProjects/CppApplication_4' make[1]: Leaving directory `/home/kevin/NetBeansProjects/CppApplication_4' BUILD FAILED (exit value 2, total time: 115ms) 包括stdlib.h 包括stdio.h 包括数学 包括cv.h 包括highgui.h int main(int argc,char*argv[]) { IplImage*img=0; 整数高度、宽度、步长、通道; uchar*数据; int i,j,k; if(argcheight; 宽度=img->width; 步长=img->widthStep; 通道=img->n通道; 数据=(uchar*)img->imageData; printf(“使用%d个通道处理%dx%d个图像\n”,高度、宽度、通道); //创建一个窗口 cvNamedWindow(“mainWin”,CV_窗口_自动调整大小); cvMoveWindow(“mainWin”,100100); //反转图像 对于(i=0;i

opencv不使用NetBeans 我尝试用NETBeCon上的OpenCV编写C++中的简单图像修饰符程序。我正在使用ubuntu 10.04。每次我尝试运行或编译它时,它都会返回以下错误。我在链接器和其他工具中配置了opencv。出什么事了 include stdlib.h include stdio.h include math.h include cv.h include highgui.h int main(int argc, char *argv[]) { IplImage* img = 0; int height,width,step,channels; uchar *data; int i,j,k; if(argc<2){ printf("Usage: main <image-file-name>\n\7"); exit(0); } // load an image img=cvLoadImage(argv[1]); if(!img){ printf("Could not load image file: %s\n",argv[1]); exit(0); } // get the image data height = img->height; width = img->width; step = img->widthStep; channels = img->nChannels; data = (uchar *)img->imageData; printf("Processing a %dx%d image with %d channels\n",height,width,channels); // create a window cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE); cvMoveWindow("mainWin", 100, 100); // invert the image for(i=0;i<height;i++) for(j=0;j<width;j++) for(k=0;k<channels;k++) data[i*step+j*channels+k]=255-data[i*step+j*channels+k]; // show the image cvShowImage("mainWin", img ); // wait for a key cvWaitKey(0); // release the image cvReleaseImage(&img ); return 0; } "/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf make[1]: Entering directory `/home/kevin/NetBeansProjects/CppApplication_4' "/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/cppapplication_4 make[2]: Entering directory `/home/kevin/NetBeansProjects/CppApplication_4' mkdir -p build/Debug/GNU-Linux-x86 rm -f build/Debug/GNU-Linux-x86/main.o.d g++ -c -g -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/ main.o main.cpp main.cpp:4:16: warning: cv.h: No such file or directory main.cpp:5:21: warning: highgui.h: No such file or directory main.cpp: In function ‘int main(int, char**)’: main.cpp:10: error: ‘IplImage’ was not declared in this scope main.cpp:10: error: ‘img’ was not declared in this scope main.cpp:12: error: ‘uchar’ was not declared in this scope main.cpp:12: error: ‘data’ was not declared in this scope main.cpp:21: error: ‘cvLoadImage’ was not declared in this scope main.cpp:32: error: expected primary-expression before ‘)’ token main.cpp:32: error: expected ‘;’ before ‘img’ main.cpp:36: error: ‘CV_WINDOW_AUTOSIZE’ was not declared in this scope main.cpp:36: error: ‘cvNamedWindow’ was not declared in this scope main.cpp:37: error: ‘cvMoveWindow’ was not declared in this scope main.cpp:44: error: ‘cvShowImage’ was not declared in this scope main.cpp:47: error: ‘cvWaitKey’ was not declared in this scope main.cpp:50: error: ‘cvReleaseImage’ was not declared in this scope make[2]: *** [build/Debug/GNU-Linux-x86/main.o] Error 1 make[1]: *** [.build-conf] Error 2 make: *** [.build-impl] Error 2 make[2]: Leaving directory `/home/kevin/NetBeansProjects/CppApplication_4' make[1]: Leaving directory `/home/kevin/NetBeansProjects/CppApplication_4' BUILD FAILED (exit value 2, total time: 115ms) 包括stdlib.h 包括stdio.h 包括数学 包括cv.h 包括highgui.h int main(int argc,char*argv[]) { IplImage*img=0; 整数高度、宽度、步长、通道; uchar*数据; int i,j,k; if(argcheight; 宽度=img->width; 步长=img->widthStep; 通道=img->n通道; 数据=(uchar*)img->imageData; printf(“使用%d个通道处理%dx%d个图像\n”,高度、宽度、通道); //创建一个窗口 cvNamedWindow(“mainWin”,CV_窗口_自动调整大小); cvMoveWindow(“mainWin”,100100); //反转图像 对于(i=0;i,c,netbeans,opencv,C,Netbeans,Opencv,好的,先生,这里是您的编译行: g++ -c -g -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/ main.o main.cpp 使用以下命令包括标题时: 编辑: 你知道吗?我只是粘贴了一些代码(opencv/camera)(我们称之为funcam.cpp)。你可以用它来测试你的系统上是否安装了opencv并编译了一些东西。你可以使用以下工具来编译它: g++ funcam.c

好的,先生,这里是您的编译行:

g++    -c -g -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/  main.o main.cpp
使用以下命令包括标题时:

编辑:

你知道吗?我只是粘贴了一些代码(opencv/camera)(我们称之为funcam.cpp)。你可以用它来测试你的系统上是否安装了opencv并编译了一些东西。你可以使用以下工具来编译它:

g++ funcam.cpp -o funcam `pkg-config --cflags opencv` `pkg-config --libs opencv`

如果它能工作,您必须弄清楚如何配置Netbeans。如果不能,您需要正确安装OpenCV。

这将有助于设置Netbeans以使用OpenCV。如果已经安装了OpenCV和Netbeans,请直接跳到页面底部。
注意目录路径,必须根据installat更改它们ion.

@a我不使用它,我太喜欢cmd行的东西了。但是现在你知道怎么回事了,你可以找到一个关于如何配置Netbeans和添加这些设置的教程。好的,谢谢你。我通常使用命令行,但我曾经努力使用ide。好的,我已经让它工作了。哦,好吧,我只是复制并粘贴ev任何新项目中的任何东西。谢谢。
g++ -c -g -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/  main.o main.cpp `pkg-config --cflags opencv` `pkg-config --libs opencv`
g++ funcam.cpp -o funcam `pkg-config --cflags opencv` `pkg-config --libs opencv`