Low FPS when using WebCamVideo

Hi there. I was trying to get the webcam video for some work with ARToolkit, but when I place the texture feed on my card my FPS go to 10~15

from direct.showbase.ShowBase import ShowBase
from panda3d.core import *
from panda3d.vision import WebcamVideo

loadPrcFileData("", "textures-power-2 none") #the webcam feed can not be made into a power of two texture
loadPrcFileData("", "show-frame-rate-meter 1") #show fps
loadPrcFileData("", "sync-video 0") #turn off v-sync


 
class MyApp(ShowBase):
    def __init__(self, webCamFeed=-1):
        ShowBase.__init__(self)
        self.disableMouse()
        
        option = WebcamVideo.getOption(0)
        
        self.tex = MovieTexture(option) 
        self.tex.setKeepRamImage(True)
        cm = CardMaker("card") 
        #cm.setUvRange(Point2(0, 0), Point2(1, 1)) 
        cm.setFrame(-1, 1, -1, 1) 
        card = render2d.attachNewNode(cm.generate()) 
        card.setTexture(self.tex)
        
app = MyApp(-1)
app.run()

This is a simpler code than what I’m using but it still presents the problem. If I comment the line
card.setTexture(self.tex)
I get normal FPS (200+) but only a white image on my card. The webcam led is still on when I comment that line so it seems the problem is in the placement of the webcam feed on the card. Commenting the loadPrcFileData doesn’t change the FPS.

Anyone have any idea why? I have tested with 2 different webcam with various resolutions (ranging from (160x120 to 1024x768) and refresh rates (from 5 Hz to 30 Hz). All of them give me the same FPS (10~15).

If no solution can be found anyone know how I can at least pause the webcam feed to get the FPS back? self.tex.stop() does not do anything. Maybe copy the current frame to another texture? How would I go about doing that? The MovieTexture class does not have any methods that do that directly it seems.

The system is Linux 32 bits Ubuntu. I’m using an A4tech PK-810 G webcam and the built-in webcam from my laptop (dell XPS15 LX502). Both give me bad FPS.

despite the chosen webcam refresh rate, the webcam can slow down if it has to. a common reason for this would be low-light conditions where the webcam has increased exposure time. so good and bright lighting might at least get you to your webcam’s refresh rate.

if that wont help, we need to investigate further

Using the camera in direct sunlight increased my FPS to 30 like you said. But I want my application to be able to be used in doors with normal lightning (which it does, except for the FPS problem).

Is there any way to make the camera asynchronous from the rendering?

So no one knows anything that can help me out?