Sto usando OpenCV 2.4.6 su Ubuntu 13.04 (su un Chromebook Acer C7), e sto usando un semplice programma di test per vedere se la mia webcam funzionerà con OpenCV. Funziona bene con Cheese e Skype, quindi so che la webcam non è il problema.OpenCV VideoCapture non può leggere affatto dalla mia webcam
Ecco il mio codice (che compila senza errori):
#include "opencv2/opencv.hpp"
#include <stdio.h>
#include <stdlib.h>
using namespace std;
using namespace cv;
int main(int argc, char *argv[])
{
cv::VideoCapture cap;
if(argc > 1)
{
cap.open(string(argv[1]));
}
else
{
cap.open(CV_CAP_ANY);
}
if(!cap.isOpened())
{
printf("Error: could not load a camera or video.\n");
}
Mat frame;
namedWindow("video", 1);
for(;;)
{
waitKey(20);
cap >> frame;
if(!frame.data)
{
printf("Error: no frame data.\n");
break;
}
imshow("video", frame);
}
}
Se faccio funzionare il programma senza alcun argomento (in quanto lo voglio usare CV_CAP_ANY), ottengo
Error: could not load a camera or video.
init done
opengl support available
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
Error: no frame data.
Se mi specificare/dev/video0 (la mia unica telecamera) come argomento, ho
demux_wavpack: (open_wv_file:127) open_wv_file: non-seekable inputs aren't supported yet.
(ERROR)icvOpenAVI_XINE(): Unable to open source '/dev/video0'
init done
opengl support available
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
libpng warning: Application built with libpng-1.2.49 but running with 1.5.12
GStreamer Plugin: Embedded video playback halted; module source reported: Could not read from resource.
Error: no frame data.
Se specifico il percorso un file video come argomento, riproduce il video bene.
Apprezzerei qualsiasi aiuto. Grazie in anticipo!
Wow. Questo mi ha bloccato per la scorsa settimana, quindi sono contento che l'abbiano rimediato oggi. Grazie mille! – Jragon
prego;) – Poko
Ho appena finito di rimuovere 2.4.6 e installare 2.4.6.1, e il mio codice funziona perfettamente! – Jragon