USB Camera Feed not Working properly

Our logitech camera is giving terrible framerate. Is there any way to fix that? We cant seem to locate the problem.

We heavily lowered the resolution for our cameras to get 30 fps

ya but we also need to use that camera for vision

So you’re running it through an opencv pipeline and finding contours?

we’re not using java for the opencv, we’re using python through a raspberry pi and finding contours through that

Are you able to make your pipeline more efficient?

You have not said the most important thing: what resolution are you running the camera?

It seems to be as efficient as we can make it. Would you like to look at the code? We are running the camera at 320x240

Yea, post it. I’m not experience in python, but I can give it a shot. Another person who is more fluent may be able to help as well.

AngleFinder11.py (4.6 KB)

I know blurring is quite cpu intensive. Are you able to run it without the blur?

we can try to run it without blur however dimming the noise from higher frequency light is why we added the blur.

Note that the RPi is not the greatest processor. With just cvtColor(), inRange() and findContours(), you can only expect about 20 FPS, with the RPi running flat out.

I see a few things you should try:

  • you are doing some things inside your main loop that are unnecessary; eg creating cut arrays for inRange(). Move everything you can out of the main loop.
  • gaussianBlur() is expensive. Try without.
  • you are using contourArea() right away, which is not cheap. Consider using boundingRect(). It is not accurate, but very fast.

we can try to run it without blur however dimming the noise from higher frequency light is why we added the blur.

Assuming you are using LED rings around your camera, I notice that you are not setting the exposure on the camera. Turn the exposure way down so that the image is essential dark, and the retro-reflective tape will stand out like anything.

Yea, blur can help, but most of the time isn’t necessary, especially since it looks like you’re already filtering out smaller objects.

My comments were assuming you are looking at the Retro-reflective target, but I guess you are trying for the white line-following tape.

You are doing a whole bunch of stuff after the area cut which you never use. Make sure to comment that out (but that was probably obvious).

If you still can’t get the speed up, I suggest you try 2 things:

  • go to 160x120 You will get 4x the speed
  • try using grayscale instead of color. That might get you ~3x in speed.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.