Re: Slow Frame Rate (approx. 4 fps)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



I've implemented a simple capture program for my Webcam, however, my frame
rate is very slow (around 4 fps).  Under Windows XP, my system achieves a
frame rate of 30 fps (I have a Dell Inspiron 8200 with Pentium 4 at 1.4
GHz and a Creative WebCam III).

I first implemented the capture program without multi-threading with about
the same 4 fps frame rate.

Recently, I tried using pthreads.  In particular, I have a thread that
continuously requests a capture and then syncs with the device.  Each time
the sync completes, the frame is captured to a mutex-protected buffer.  
Below is the critical code:

fd = open("/dev/video0", O_RDWR);
ioctl(fd, VIDIOCGCAP, &Capability);
memset(&Picture, 0, sizeof(struct video_picture));
ioctl(fd, VIDIOCGPICT, &Picture);
info.format = VIDEO_PALETTE_RGB24;
info.frame = 0;
info.width = w
info.height = h;
buffer = (unsigned char *)mmap(0, Capability.maxwidth *
  Capability.maxheight * 3, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
buffer2 = (unsigned char *)malloc(Capability.maxwidth *
  Capability.maxheight * 3 * sizeof(unsigned char));
ioctl(fd, VIDIOCMCAPTURE, &info);
while (capturing) {
  ioctl(fd, VIDIOCSYNC, &info);
  pthread_mutex_lock(&mutex);
  memcpy(buffer2, buffer, info.width * info.height * 3);
  pthread_mutex_unlock(&mutex);
  ioctl(fd, VIDIOCMCAPTURE, &info);
}

I notice from the API that you can have the camera dump frames directly to
the video card's frame buffer.  However, I want to be able to manipulate
the images in real time in my code, so I need it in main memory.

Any suggestions?

Thanks,
Stephen






[Index of Archives]     [Linux DVB]     [Video Disk Recorder]     [Asterisk]     [Photo]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Free Photo Albums]     [Fedora Users]     [Fedora Women]     [ALSA Users]     [ALSA Devel]     [Linux USB]

Powered by Linux