0

我正在尝试在 Gumstix Arm 板上使用 OpenCV 编译视频捕获代码。以下代码在我的笔记本电脑上完美运行,我能够捕获视频,但是当我在 arm 板上编译相同的代码时,它会给出未知错误。

我的代码:

#include "/usr/include/opencv2/opencv.hpp"
#include "/usr/include/opencv2/core/core_c.h"
#include "/usr/include/opencv2/core/core.hpp"
#include "/usr/include/opencv2/flann/miniflann.hpp"
#include "/usr/include/opencv2/imgproc/imgproc_c.h"
#include "/usr/include/opencv2/imgproc/imgproc.hpp"
#include "/usr/include/opencv2/video/video.hpp"
#include "/usr/include/opencv2/features2d/features2d.hpp"
#include "/usr/include/opencv2/objdetect/objdetect.hpp"
#include "/usr/include/opencv2/calib3d/calib3d.hpp"
#include "/usr/include/opencv2/ml/ml.hpp"
#include "/usr/include/opencv2/highgui/highgui_c.h"
#include "/usr/include/opencv2/highgui/highgui.hpp"
#include "/usr/include/opencv2/contrib/contrib.hpp"
#include <iostream>
#include <sys/time.h>
#include <signal.h>
#include <unistd.h>

using namespace std;
using namespace cv;

#define FPS 10

bool running;

float time_elapsed(timespec start, timespec end)
{
    return (end.tv_sec + end.tv_nsec/1000000000.0) - (start.tv_sec + start.tv_nsec/1000000000.0);
}
void end_signal(int a)
{
    cout << "Closing feed due to user input" << endl;
    running = false;
}

int main(int argc, char* argv[])
{


        cout<<"Videocapture "<<argv[0]<<" has "<<argc - 1<<" arguments\n";
            int devNum = atoi(argv[1]);

 VideoCapture camera(devNum);

    camera.set(CV_CAP_PROP_FRAME_WIDTH,640);
    camera.set(CV_CAP_PROP_FRAME_HEIGHT,480);

    int height = camera.get(CV_CAP_PROP_FRAME_HEIGHT);
    int width = camera.get(CV_CAP_PROP_FRAME_WIDTH);

    VideoWriter capture("./output.avi",CV_FOURCC('I','4','2','0'),FPS,Size(width,height),true);

    running = true;
    signal(SIGINT,end_signal);

    Mat raw_frame;

    cout << "begin recording..." << endl;

    timespec current_frame, last_frame;

    clock_gettime(CLOCK_MONOTONIC,&last_frame);

    float spf = 1/FPS;


    while(running)
    {
        clock_gettime(CLOCK_MONOTONIC,&current_frame);
        if(spf < time_elapsed(last_frame,current_frame))
        {
            camera >> raw_frame;
            capture << raw_frame;
            clock_gettime(CLOCK_MONOTONIC,&last_frame);
            cout << "FRAME!" << endl;
        }
    }
    camera.release();
    capture.release();
    cout << "All done!" << endl;
    return 0;
}

我为此写了一个makefile:

#!/bin/sh
export LD_LIBRARY_PATH=/root/usr/lib
echo `pkg-config --cflags opencv`
echo `pkg-config --libs opencv`
g++  `pkg-config --cflags opencv` -g -g -o $3 $2 $1 `pkg-config --libs opencv`

$ chmod +x makefile.sh
$ ./makefile
$ ./makefile.sh videorecording.cpp videorecording

$ export LD_LIBRARY_PATH=/root/usr/lib

错误:

videorecording.cpp:42:60: warning: missing terminating " character [enabled by default]
videorecording.cpp:42:9: error: missing terminating " character
videorecording.cpp:43:1: error: stray '\' in program
videorecording.cpp:43:12: warning: missing terminating " character [enabled by default]
videorecording.cpp:43:1: error: missing terminating " character
videorecording.cpp: In function 'int main(int, char**)':
videorecording.cpp:43:1: error: 'arguments' was not declared in this scope
videorecording.cpp:43:11: error: expected ';' before 'n'
videorecording.cpp:46:22: error: 'devNum' was not declared in this scope

这在笔记本电脑上运行良好,但在 arm 设备上运行良好

4

1 回答 1

0

Do you have openCV compiled natively from source or installed Using opkg ? I dont need to add the /usr/include/ ... I used openCV before on Gumstix and I will try to Replicate your example and feedback.

于 2014-01-13T23:59:29.710 回答