2014-01-08 46 views
0

我想在Gumstix Arm板上使用OpenCV編譯videocapture代碼。下面的代碼在我的筆記本電腦上完美地工作,我能夠捕捉視頻,但是當我在手臂板上編譯相同的代碼時,它會給出未知的錯誤。OpenCV-C++ on armv71給出未知錯誤

我的代碼:

#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 

這適用於筆記本電腦罰款手臂設備上

回答

0

你有openCV com嗎?從源代碼或本地堆積 使用opkg?我不需要添加/ usr/include/... 我之前在Gumstix上使用過openCV,我會嘗試複製 您的示例和反饋。