OpenCV无法识别BeagleBone中的相机

OpenCV does not recognize a camera in BeagleBone

本文关键字:相机 BeagleBone 识别 OpenCV      更新时间:2023-10-16

我编写了以下代码,通过BeagleBone使用相机PlayStation Eye:

#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;
void inputSetup(int setup);
int main(int argc, char *argv[])
{
    CvCapture *capture;
    Mat img;
    capture = cvCaptureFromCAM(-1);
    if (capture){
        printf("mmm...n");
        inputSetup(1);
        img = cvQueryFrame(capture);
    }
    while (1);
    return 0;
}
void inputSetup(int setup)
{
    static struct termios oldt, newt;
    if (setup) {
        tcgetattr(STDIN_FILENO, &oldt);
        newt = oldt;
        newt.c_lflag &= ~(ICANON);
        tcsetattr( STDIN_FILENO, TCSANOW, &newt);
    }
    else {
        tcsetattr( STDIN_FILENO, TCSANOW, &oldt);
    }
}

问题是它无法识别相机,因为代码不会进入第一个"if"(打印"mmm..."的那个)。我已经尝试过使用"capture = cvCaptureFromCAM(0);",但它也不起作用。

我正在使用以下命令编译代码:

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

如何解决此问题?

使用最新的 OpenCV Git 存储库。相机驱动程序中存在问题,但其中大多数已经修复。