opencv - 在Beaglebone中使用openCV编译C++代码

标签 opencv g++ beagleboard

我用C++编写了以下代码,这些代码使用openCV在Beaglebone中运行:

    #include <unistd.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <string.h>
    #include <errno.h>
    #include <fcntl.h>
    #include <termios.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <netinet/in.h>
    #include "opencv/cv.h"
    #include "opencv/highgui.h" 

    using namespace cv;
    using namespace std;

    int main(int argc, char *argv[])
    {
         CvCapture *capture = 0;
         Mat img3;
         Mat src;

         capture = cvCaptureFromCAM(0);

         vector<int> p;
         p.push_back(CV_IMWRITE_PNG_COMPRESSION);
         p.push_back(9);

         while (1) {
              img3 = cvQueryFrame(capture);
              cvtColor(img3, img3, CV_BGR2GRAY);
              pyrDown(img3, src, Size( img3.cols/2, img3.rows/2 ) );
              if (!imwrite("/home/root/Desktop/website/fig3bmp.bmp",src,p)) {
                  printf("mat not saved!!!\n"); 
              }
         }

         return 0; 
    }

我尝试使用以下代码编译代码:“g++ -o CamaraTest CamaraTest.cpp”,但是它不起作用,并且我得到的所有错误都类似于:“ undefined reference :cv ...”

我已经检查过文件“cv.h”和“highgui.h”是否在目录“/ usr / include / opencv”中。

如何编译此代码?
任何建议都会有很大帮助。

提前致谢。

gus。

最佳答案

这些“ undefined reference :cv ...”消息是由于缺少库而导致的链接器错误-您需要在g++命令行中与OpenCV库进行链接,例如:

$ g++ -Wall -g -o CamaraTest CamaraTest.cpp `pkg-config --cflags --libs opencv` 

关于opencv - 在Beaglebone中使用openCV编译C++代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14565876/

相关文章:

opencv - 从 recoverPose 得到的翻译的范数总是 1 是多少?

java - G++编译的DLL有不同的函数名称

c++ - "Bad"GCC优化性能

cross-compiling - 如何使用 bitbake 为 beagleboard 交叉编译这个简单的程序?

c - 通过 mmap 配置焊盘

c++ - 为模块化 OpenCV 应用程序确定语言/框架

c++ - OpenCv 将圆转换为多边形

python - 如何使用 image_proc 发布/流式传输校正图像的 roi?

c++ - 将 int64_t 转换为 int 时,如何让 g++ 发出警告?

c - Linux C 串行程序卡住