Sorry, I senr the message and there was no source code in it.. I repeat i think it is
too slow..
please take a look and tell me what do I have to fix....here you have it...
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <signal.h>
#include <linux/types.h>
#include <linux/videodev.h>
#include <errno.h>
#include <time.h>
#define ROWS 240
#define COLS 320
int cam,size,i,frame,q;
struct video_capability cap;
struct video_picture pic;
struct video_window win;
struct video_capture vicap;
struct video_channel vidcan;
struct video_mbuf vidbuf;
struct video_buffer buffer;
struct video_mmap mapbuf;
char *bigbuf;
char *buf;
time_t t, t2;
main (){
//-------------------------------------------------------------------
/* OPEN VIDEO DEVICE */
//-------------------------------------------------------------------
cam = open("/dev/video", O_RDWR );
if (cam<0){printf("ERROR: NO SE DETECTA CAMARA\n");
exit(-1);}
//--------------------------------------------------------------------
/* VIDEO CAPABILITIES*/
//---------------------------------------------------------------------
if (-1==ioctl(cam,VIDIOCGCAP,&cap)){perror("ioctl VIDIOCGCAP");
exit(-1);}
printf("name -> %s\n", cap.name);
printf("type -> %d\n", cap.type);
printf("channels -> %d\n", cap.channels);
printf("audios -> %d\n", cap.audios );
printf("maxwidth -> %d\n", cap.maxwidth );
printf("maxheight -> %d\n", cap.maxheight);
printf("minwidth -> %d\n", cap.minwidth );
printf("minheight -> %d\n", cap.minheight );
//---------------------------------------------------------------------
/* FRAME GRABBERS DETECTION*/
//---------------------------------------------------------------------
if (-1==ioctl(cam,VIDIOCSFBUF,&buffer))printf ("No se dectecto frame grabber\n");
else {
if (-1==ioctl(cam,VIDIOCGFBUF,&buffer)) {perror ("ioctl VIDIOCGFBUF");
exit(-1);}
printf ("add -> %d\n", buffer.base);
printf ("height -> %d\n", buffer.height);
printf ("width -> %d\n", buffer.width);
printf ("depth -> %d\n", buffer.depth);
printf ("BPL -> %d\n", buffer.bytesperline);}
//-----------------------------------------------------------------------
/* CAPTURE WINDOW */
//-----------------------------------------------------------------------
win.x = 0;
win.y = 0;
win.width = COLS;
win.height = ROWS;
win.clipcount = 0;
win.chromakey = 1;
win.flags = VIDEO_CLIPMAP_SIZE;
if (-1== ioctl(cam, VIDIOCSWIN,&win)){perror ("ioctl VIDIOCSWIN");
exit (-1);}
//---------------------------------------------------------------------
/* IMAGE PROPERTIES*/
//---------------------------------------------------------------------
pic.depth = 24;
pic.palette = VIDEO_PALETTE_RGB24;
pic.brightness = 100;
pic.contrast = 30;
pic.whiteness = 0;
pic.colour = 0;
pic.hue = 0;
if (-1==ioctl( cam, VIDIOCSPICT, &pic )){perror("ioctl VIDIOCSPICT");
exit(-1);}
ioctl( cam, VIDIOCGPICT, &pic );
printf("brightness -> %d \n", pic.brightness/256 );
printf("hue -> %d\n", pic.hue/256);
printf("colour -> %d\n", pic.colour/256 );
printf("contrast -> %d \n", pic.contrast/256 );
printf("whiteness -> %d\n", pic.whiteness/256 );
printf("depth -> %d\n", pic.depth );
printf("palette -> %d \n", pic.palette );
//-----------------------------------------------------------------------
/* MAPPING BUFFER */
//------------------------------------------------------------------------
if (-1==ioctl(cam,VIDIOCGMBUF,&vidbuf)){perror("ioctl VIDIOCGMBUF");
exit(-1);}
printf("size -> %d\n",vidbuf.size);
printf("frames -> %d\n",vidbuf.frames);
printf("offsets -> %d\n",vidbuf.offsets);
bigbuf = (char *)mmap(0,vidbuf.size, PROT_READ | PROT_WRITE, MAP_SHARED, cam, 0);
mapbuf.width = COLS;
mapbuf.height = ROWS;
mapbuf.format = VIDEO_PALETTE_RGB24;
for(frame=0; frame<vidbuf.frames;frame++){
mapbuf.frame = frame;
if (ioctl(cam,VIDIOCMCAPTURE, &mapbuf)<0){
perror("VIDIOCMCAPTURE");
exit(-1);}
printf ("p\n");
}
frame = 0;
q=0;
time(&t);
while (1){
i = -1;
while(i<0){
i= ioctl(cam,VIDIOCSYNC, &frame);
if(i < 0 && errno == EINTR) continue;
if (i < 0) {
perror ("VIDIOCSYNC");
exit(-1);
}
break;
}
buf = bigbuf + vidbuf.offsets[frame];
mapbuf.frame = frame;
if (ioctl(cam,VIDIOCMCAPTURE, &mapbuf)<0) {perror("VIDIOCMCAPTURE");
exit(-1);}
frame++;
q++;
if (frame>=vidbuf.frames) frame=0;
if (q==29){time(&t2);
fprintf (stderr,"Time: initial: %d \nfinal: %d\nelapsed: %d \n", (time_t)t,
(time_t)t2,
(time_t)t2-t);
}
}}
_______________________________________________
Video4linux-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/video4linux-list