OpenCV- C++ on armv71 gives unknown errors

394 views Asked by At

I am trying to compile videocapture code using OpenCV on Gumstix Arm board. The following code works flawlessly on my Laptop and I am able to capture video, but when I compile the same on arm board, it gives unknown errors.

My code:

#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;
}

I wrote a makefile for this:

#!/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

Errors:

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

This works fine on Laptop but not on arm device

1

There are 1 answers

0
bhamadicharef On

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.