Jacek Dylak wrote: > > I use simple AverMedia card with BT878 chip. > > I need to capture frame by frame and process each. I try to do this with the > following code, but I get only 12 frames per second. I need at least 20 fps, > but I don't what is wrong with my code, or what needs to be change, to get > frames more frequently. > > Is it a matter of coding or the chipset? > > I would be very thankful if somebody could help me. > Jacek > > /////////////////// > //capture code > > dev.Open("/dev/video0"); > > //get memory buffer size > dev.GetMemoryBuffer(&stMemBuf); > > //map memory for frame buffer > szFrame = (char*) mmap(0,stMemBuf.size,PROT_READ|PROT_WRITE,MAP_SHARED,dev,0); > > //set channel to COMPOSITE and mode to PAL > dev.SetSource(1,VIDEO_MODE_PAL); > > //set capture image size and pixel format > stMemMap.width = IMAGE_WIDTH; > stMemMap.height = IMAGE_HEIGHT; > stMemMap.format = VIDEO_PALETTE_GREY; > > //capture frame 0 > stMemMap.frame = nFrame; > ioctl(dev,VIDIOCMCAPTURE,&stMemMap); > > while (m_bProcessing) > { > stMemMap.frame = nFrame; > ioctl(dev,VIDIOCSYNC,&stMemMap.frame); > > stMemMap.frame = 1 - nFrame; > ioctl(dev,VIDIOCMCAPTURE,&stMemMap); > > ProcessFrame(..); //actually do nothing, simply count up frames > > nFrame = 1 - nFrame; > } >From the look of that loop you can probably blame that on me! (my example code) Try swapping the order of the SYNC(nFrame) and CAPTURE(1-nFrame) pairs of lines - that way there'll always be a "queued" capture, and you shouldn't lose any frames assuming your processing isn't taking too long. Ben