编译在Beaglebone使用OpenCV的C ++代码(Compiling C++ code us

2019-08-08 13:48发布

我已用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”,但它不工作,我得到的错误是这样的:“未定义参考:简历...”

我已经检查了文件“cv.h”和“highgui.h”在目录“/ usr / include目录/ OpenCV的”。

我如何才能编译这段代码? 任何建议将有很大的帮助。

提前致谢。

GUS。

Answer 1:

这些“未定义参考:简历......”消息链接错误由于缺少图书馆-你需要在你的G ++命令行,如OpenCV的库链接:

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


文章来源: Compiling C++ code using openCV in Beaglebone