在Beaglebone中使用openCV编译C ++代码 [英] Compiling C++ code using openCV in Beaglebone

查看:224
本文介绍了在Beaglebone中使用openCV编译C ++代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C ++中使用openCV在Beaglebone中编写了以下代码:

I have written the following code in C++ which use openCV to be run in 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 ...

I have tried compiling the code using: "g++ -o CamaraTest CamaraTest.cpp", but it does not work, and all the errors I get are something like: "undefined reference to: cv... "

我已经检查过这些文件cv.h和highgui.h位于目录/ usr / include / opencv中。

I have already checked that the files "cv.h" and "highgui.h" are in the directory "/usr/include/opencv".

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

How can I compile this code? Any suggestion would help a lot.

预先感谢。

gus。

推荐答案

这些未定义的引用:cv ...消息是由于缺少库而导致的 linker 错误 - 需要与g ++命令行中的OpenCV库链接,例如:

These "undefined reference to: cv... " messages are linker errors due to missing libraries - you need to link with the OpenCV libraries in your g++ command line, e.g.:

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

这篇关于在Beaglebone中使用openCV编译C ++代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆