On Sat, Jan 3, 2009 at 1:52 AM, niamathullah sharief <shariefbe@xxxxxxxxxxx> wrote: > Hello > > I am looking for a very basic "c" example that will connect to a V4L2 webcam > and capture a frame. I am basically looking to write a class which I can use > to create a new Webcam object. which will grab a frame from the camera,.... for a start, u should search for a userspace C program that can read from webcam object, try: 1. www.google.com/codesearch 2. www.sourceforge.net and enter "webcam". for example, from codesearch I found the following fragments: http://www.google.com/codesearch/p?hl=en#3g4bv2F2LZQ/xvcam/xvcam.c&q=webcam%20drivers init() { struct video_capability grab_cap; struct video_channel grab_chan; struct video_mbuf vid_mbuf; atexit(deinit); if ((grab_fd = open("/dev/video0", O_RDWR)) == -1) { fprintf(stderr, "Couldn't open /dev/video0: %s\n", strerror(errno)); exit(-1); } if (ioctl(grab_fd, VIDIOCGCAP, &grab_cap) == -1) { perror("ioctl VIDIOCGCAP"); exit(-1); } grab_chan.channel = 0; if (ioctl(grab_fd, VIDIOCGCHAN, &grab_chan) == -1) { perror("ioctl VIDOCGCHAN"); exit(-1); } grab_chan.norm = 0; if (ioctl(grab_fd, VIDIOCSCHAN, &grab_chan) == -1) { perror("ioctl VIDIOCSCHAN"); exit(-1); } grab_buf.format = VIDEO_PALETTE_YUV420P; grab_buf.frame = 0; grab_buf.width = yuv_width; grab_buf.height = yuv_height; ioctl(grab_fd, VIDIOCGMBUF, &vid_mbuf); grab_size = vid_mbuf.size; grab_data_tmp = mmap(0, grab_size, PROT_READ | PROT_WRITE, MAP_SHARED, grab_fd, 0); if ((grab_data_tmp == NULL) || (-1 == (int) grab_data_tmp)) { fprintf(stderr, "Couldn't mmap\n"); exit(1); } /* Useless? probably. */ setpriority(PRIO_PROCESS, 0, 20); nice(20); } -- Regards, Peter Teoh -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ