mateus_guilherme
Posts: 20
Joined: Sat Feb 15, 2020 6:36 pm

usb camera vs PI camera with OpenCv and raspberry pi 4

Wed Feb 19, 2020 5:02 pm

Hello

I would like to know what is best to use with a raspberry pi 4, a Usb webcam with mjpeg support or a Camera Pi?
I will use the camera in a python project with opencv.

Which would give me more frames per second?

Here is an example of a USB camera that I thought about purchasing:

https://www.aliexpress.com/item/4000452 ... 2e0evP62sC

...or if someone has a comparison using the raspberry pi 3, it is also valid

thanks

Eirikur
Posts: 68
Joined: Sun Sep 09, 2018 9:43 pm

Re: usb camera vs PI camera with OpenCv and raspberry pi 4

Thu Feb 20, 2020 7:54 pm

I don't have a direct comparison, but I can point out some things to be aware of USB2 will limit frame rate at larger image sizes. That might not be important to you, but check the specs if the camera is USB2 only, or if you are using a Pi3, which only has USB2. If you are using a Pi Camera, the ribbon cable goes super fast, as fast as the camera can go, I think. Mounting the Pi camera is a challenge as is putting telephoto lenses on it.

mateus_guilherme
Posts: 20
Joined: Sat Feb 15, 2020 6:36 pm

Re: usb camera vs PI camera with OpenCv and raspberry pi 4

Fri Feb 21, 2020 2:04 pm

thanks for your reply.

I read something about high FPS using raspividYuv and python, capturing the video in gray scale. However, I didn't find very good examples to try to implement.

mateus_guilherme
Posts: 20
Joined: Sat Feb 15, 2020 6:36 pm

Re: usb camera vs PI camera with OpenCv and raspberry pi 4

Fri Feb 21, 2020 2:04 pm

Eirikur wrote:
Thu Feb 20, 2020 7:54 pm
I don't have a direct comparison, but I can point out some things to be aware of USB2 will limit frame rate at larger image sizes. That might not be important to you, but check the specs if the camera is USB2 only, or if you are using a Pi3, which only has USB2. If you are using a Pi Camera, the ribbon cable goes super fast, as fast as the camera can go, I think. Mounting the Pi camera is a challenge as is putting telephoto lenses on it.
thanks for your reply.

I read something about high FPS using raspividYuv and python, capturing the video in gray scale. However, I didn't find very good examples to try to implement.

ElEscalador
Posts: 840
Joined: Tue Dec 15, 2015 4:55 pm
Location: Detroit, MI USA
Contact: Website

Re: usb camera vs PI camera with OpenCv and raspberry pi 4

Fri Feb 21, 2020 2:15 pm

I don't know how fast you need, but it's far more likely the processing of the frames is going to be the choke-point, not the camera. Do you need more than 30 fps if you can only process 3-10?
Robotics tips, hacks, book extras https://youtube.com/practicalrobotics

mateus_guilherme
Posts: 20
Joined: Sat Feb 15, 2020 6:36 pm

Re: usb camera vs PI camera with OpenCv and raspberry pi 4

Fri Feb 21, 2020 2:29 pm

ElEscalador wrote:
Fri Feb 21, 2020 2:15 pm
I don't know how fast you need, but it's far more likely the processing of the frames is going to be the choke-point, not the camera. Do you need more than 30 fps if you can only process 3-10?
hello, I would like 30fps 1280x720.
Testing with a PI 5mp camera and without any image processing the opencv command "cv2.imshow" does not display in real time, the display is slow.

maybe "cv2.imshow" is the problem ...

ElEscalador
Posts: 840
Joined: Tue Dec 15, 2015 4:55 pm
Location: Detroit, MI USA
Contact: Website

Re: usb camera vs PI camera with OpenCv and raspberry pi 4

Fri Feb 21, 2020 3:04 pm

I'm not sure..I know rendering that way would be slower than playing directly since imshow is not a free process. Maybe for the testing of cameras you'd be better to try a program like cheese and avoid any opencv-related slowdowns. If it's fast enough in cheese than I'd guess the opencv processes of turning the raw image into a Mat image and then rendering is whats slowing you down.
Robotics tips, hacks, book extras https://youtube.com/practicalrobotics

mateus_guilherme
Posts: 20
Joined: Sat Feb 15, 2020 6:36 pm

Re: usb camera vs PI camera with OpenCv and raspberry pi 4

Sat Feb 22, 2020 9:35 pm

Hello

For all those who are experiencing problems with low FPS on the Raspberry PI using OpenCv and Python use this script (author CarlosGS). I got very good results, but it will only work with the PI Camera. The python script uses the raspibian native raspividYUV command and obtains the gray scale image with high FPS. If anyone knows a similar way to test with a USB webcam it would be interesting.

Script: https://gist.github.com/CarlosGS/b8462a ... bb0f3a4d63

Return to “General discussion”