opencv及相机相关3

经过测试,第一opencv装完用来测试相机的示例,打不开,和下面的例子出现一样的效果。

example1:
<span style="font-size:18px;">#include <cv.h> #include <cxcore.h> #include <highgui.h> int main(int argc,char **argv) { CvCapture* capture = NULL; IplImage* pImg = NULL; fprintf(stderr, "123"); pImg = cvLoadImage("1.jpg",1); fprintf(stderr, "456"); cvNamedWindow("video", 1); fprintf(stderr, "789"); cvShowImage("video", pImg); fprintf(stderr, "109"); cvWaitKey(-1); cvDestroyWindow("video"); cvReleaseImage( &pImg ); return 0; }
运行错误如此:OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow,file/usr/local/opencv/OpenCV-2.0.0/src/highgui/window.cpp, line 100 

terminate called after throwing an instance of 'cv::Exception' Aborted

后来确定此种错误:这个问题是由于开发板中没有可以用于图像显示界面的库,比如GTK等等。可以通过安装GTK或者使用QT来显示图像解决这个问题。(PS:目前不知道该怎么在开发板上安装,或者说开发板上班装的是linux+qt系统,我还需不需要在做qt移植,只需要在Ubuntu下编译qt程序直接交叉编译放到开发板上就可以)
 
 
example2 :
<span style="font-size:14px;">#include <cv.h> #include <cxcore.h> #include <highgui.h> int main(int argc,char **argv) { CvCapture* capture = NULL; IplImage* pImg = NULL; IplImage* pImg1 = NULL; fprintf(stderr, "123"); pImg = cvLoadImage("1.jpg",1); fprintf(stderr, "456"); pImg1 = cvCreateImage(cvSize(pImg->width,pImg->height),IPL_DEPTH_8U,1); fprintf(stderr, "456"); cvCvtColor(pImg,pImg1,CV_RGB2GRAY); fprintf(stderr, "789"); cvSaveImage("1_1.jpg",pImg1); fprintf(stderr, "109"); cvReleaseImage( &pImg ); cvReleaseImage( &pImg1 ); return 0; }
运行没有问题,说明opencv移植是成功的,但是开发板上没有支持图形库的东西,以及不知道相机如何打开。

 

posted @ 2018-12-27 16:15  小辉爱吃素  阅读(234)  评论(0编辑  收藏  举报