int main(void) { v4l_device *vd; char *dev="/dev/video0"; v4l_open(dev,vd); v4l_grab_picture(vd,1024); printf("Hello World!\n"); return 0; }
// ref effetv video.c function video_init() int SwV4LDevice::VDopen(char * device, tBoxSize *newSize) { int maxc; fprintf(stderr, "[V4L]::VDopen device '%s'\n", device); if(device == NULL){ videodevice = new char [ strlen(DEFAULT_VIDEO_DEVICE) +1]; strcpy(videodevice, DEFAULT_VIDEO_DEVICE); } else { videodevice = new char [ strlen(device) +1]; strcpy(videodevice, device); } if(v4l_open(videodevice)) { return -1; } v4l_setdefaultnorm(norm); // moved after getcapabilities to get the channel number v4l_getcapability(); // v4lsetdefaultnorm(norm); // Read channel ... if(!(vd.capability.type & VID_TYPE_CAPTURE)) { fprintf(stderr, "[V4L]::VDOpen: This device seems not to support video capturing.\n"); return -1; } hastuner = 0; if((vd.capability.type & VID_TYPE_TUNER)) { hastuner = 1; frequency_table = 0; // CSE : didn't undestand ... = freq; TVchannel = 0; } // set acquisition size changeSize(newSize); getcurrentchannel(); maxc = vd.capability.channels; if((maxc) && (channel <= maxc)) { if(setchannel(channel)) return -1; } if(channel >= maxc) { channel = maxc; if(setchannel(channel)) return -1; } if(v4l_mmap()) { fprintf(stderr, "[V4L]::VDopen: mmap interface is not supported by this driver.\n"); return -1; } /* quick hack for v4l driver that does not support double buffer capturing */ if(vd.mbuf.frames < 2) { fprintf(stderr, "[V4L]::VDopen: double buffer capturing with mmap is not supported.\n"); return -1; } /* OLD COMMENT detecting a pixel format supported by the v4l driver. * video_set_grabformat() overwrites both 'converter' and 'converter_hflip'. * If 'converter' is non-NULL, palette converter must be initialized. */ if(setGrabFormat(palette)) { fprintf(stderr, "[V4L]::VDopen: ERROR : Can't find a supported pixel format.\n"); return -1; } v4l_getpicture(); picture_brightness = vd.picture.brightness; picture_hue = vd.picture.hue; picture_colour = vd.picture.colour; /*** END COPY ****/ if(StartGrab()) { fprintf(stderr, "[V4L]::VDopen: Can't start grab.\n"); //normal at beginning or when capture has been stopped } initialised = true; // echo(); return 0; }