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
|
void captureImage(void (*ptrfonction) (unsigned char*, int, int, int), int rep)
{
int i, nbcapture=0;
int image=0;
if(ioctl(descrpFichier, VIDIOCGMBUF, &mbuf)<0)
{
perror("VIDIOCGMBUF");
exit(-1);
}
ptr = (unsigned char*)mmap(0, mbuf.size, PROT_READ|PROT_WRITE, MAP_SHARED,descrpFichier,0);
if(ptr==(unsigned char*) -1){
perror("mmap");
exit(1);
}
/*Les demandes de captures sont mises dans la file d'attente du buffer*/
mapbuf.height = HEIGHT ;
mapbuf.width = WIDTH;
mapbuf.format = PALETTE;
while(nbcapture<1500){
printf("Début de traitement\n");
/* Obtenir l'image */
if (ioctl(descrpFichier, VIDIOCMCAPTURE, &mapbuf) < 0) {
perror ("VIDIOCMCAPTURE");
exit (1);
}
/* Pour vérifier qu'elle est bien acquise */
if (ioctl(descrpFichier, VIDIOCSYNC, &mapbuf.frame) < 0) {
perror ("VIDIOCSYNC");
exit (1);
}
ptrfonction(ptr,HEIGHT, WIDTH, nbcapture);
nbcapture++;
}
printf("Traitement achevé\n");
} |