Bonjour,
Je voudrais utilisé OpenCV pour capturer le flux video d'une webcam, et soustraire les images deux a deux.
Seulement pour commencer, quand je capture une frame et que je l'affiche, ça me donne une image noire avec une bande en haut faite de plein de petits traits de couleurs.
J'ai vu quelqu'un qui avait le meme probleme sur un autre forum mais il a pas eu de reponses >< .
Et ensuite, j'ai voulu utilisé cvsub pour faire la soustraction des images, ça compile bien, mais quand je lance le programme ça me dis ça :
Ah, et quand meme, voila mon code actuel ^^ :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 OpenCV ERROR: Null pointer (NULL array pointer is passed) in function cvGetMat, cxarray.cpp(2780) Terminating the application... called from cvUnregisterType, cxpersistence.cpp(4933) Terminating the application... called from cvUnregisterType, cxpersistence.cpp(4933) Terminating the application... called from cvUnregisterType, cxpersistence.cpp(4933) Terminating the application... called from cvUnregisterType, cxpersistence.cpp(4933) Terminating the application... called from cvUnregisterType, cxpersistence.cpp(4933) Terminating the application... called from cvUnregisterType, cxpersistence.cpp(4933) Terminating the application... called from cvUnregisterType, cxpersistence.cpp(4933) Terminating the application... called from cvUnregisterType, cxpersistence.cpp(4933) Terminating the application... called from cvUnregisterType, cxpersistence.cpp(4933) Terminating the application...
Je revien demain, merci d'avance !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68 #include <stdlib.h> #include <stdio.h> #include <math.h> #include <cv.h> #include <highgui.h> int main(int argc, char *argv[]) { IplImage *img = 0, *img2 = 0, *img3 = 0; int height,width,step,channels; uchar *data; int i,j,k; //char buf[32]; //CvFont font; //double hScale=1.0; //double vScale=1.0; //int lineWidth=1; // Initialise la capture CvCapture* capture = cvCaptureFromCAM(-1); if(capture) { if(!cvGrabFrame(capture)) { // capture a frame printf("Could not grab a frame\n\7"); exit(0); } } else { printf("Could not open video device\n"); exit(0); } img=cvRetrieveFrame(capture); // retrieve the captured frame cvGrabFrame(capture); img2=cvRetrieveFrame(capture); cvSub( img, img2, img3); // get the image data height = img->height; width = img->width; step = img->widthStep; channels = img->nChannels; data = (uchar *)img->imageData; printf("Processing a %dx%d image with %d channels\n",height,width,channels); // create a window cvNamedWindow("Fenetre_test", CV_WINDOW_AUTOSIZE); cvMoveWindow("Fenetre_test", 100, 100); // invert the image /*for(i=0;i<height;i++) for(j=0;j<width;j++) for(k=0;k<channels;k++) data[i*step+j*channels+k]=255-data[i*step+j*channels+k];*/ // show the image //sprintf(buf, "%d", i); //cvPutText (img,buf,cvPoint(200,400), &font, cvScalar(255,255,0)); cvShowImage("Fenetre_test", img3 ); // wait for a key cvWaitKey(0); // release the image cvReleaseImage(&img ); cvReleaseCapture(&capture); return 0; }
EDIT : inutile de dire que ma cam marche tres bien avec les autres programmes ^^
Partager