hi!
I am writing because there is something I do not understand in the process of using raspberry.
Before using Webos, I am trying to stream video using a webcam camera on a Raspberry Pi.
I tried to test it first using the Raspbian operating system, but the video frame was too slow to find the problem.
The first problem I thought was that I was using an SD card with a slow reading speed. So I replaced it with an SD card with a very fast reading speed, but the video frame is too slow.
I thought it was a problem with the webcam camera, so I connected the webcam to my laptop and tested it. The video output from the webcam is very smooth.
Is it slow to output video using a webcam on a Raspberry Pi?
I am asking if there is any way to solve it. help..
And the resolution of the webcam is 1980 x 1020.
The code was tested with the OpenCV example.
'''python code
import cv2
webcam = cv2.VideoCapture(0) # Score 0 is a laptop webcam, and the webcam number can be selected by looking at the connection number.
if not webcam.isOpened():
print("Could not open webcam")
exit()
while webcam.isOpened():
status, frame = webcam.read()
if status:
cv2.imshow("test", frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
webcam.release()
cv2.destroyAllWindows
'''
Long time no see ~
I don't know what's your whole Environment,
but i'm sure that RPI4 Board has enough performence for video streaming.
And! about 6 month ago, i had some project using webcam.
if you are just testing streaming, with "VNC", it might be Wi-Fi network issue or just VNC has low FPS.
give me an hour. ill check.
If you want Faster Storage, use USB booting with USB 3.0 supported.
(Micro SD Card Slot has limited speed) and you can use sata to usb adaptor.
like this.
1 Like
i tested following codes.
i used display using HDMI port.
import cv2
webcam = cv2.VideoCapture(0)
webcam.set(cv2.CAP_PROP_FRAME_WIDTH,1920)
webcam.set(cv2.CAP_PROP_FRAME_HEIGHT,1080)
if not webcam.isOpened():
print("Could not open webcam")
exit()
while webcam.isOpened():
status, frame = webcam.read()
if status:
cv2.imshow("test", frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
webcam.release()
cv2.destroyAllWindows
and 1920*1080 had low FPS.
1280*720 was okay... (Maybe FPS had doubled)
RPI4 's video performance is horrible.
2 Likes
Sorry for checking late!
As a result, it was a problem with the webcam codec.
If you change the codec to a supported webcam, it works well.
1 Like
There are several ways to smooth the frame...
GPU usage
Lightening the model
Reduce image size
Stop Streaming
I've tried 2 and 3 here. But still opencv with webcam is slow. No 4 times. The reason is real-time streaming.
Then I have to use 'no.1' to solve the problem.
When I researched the same data as number 1...There was a Jetson Nanoโข developer kit [B01 version], did you have any experience with it?
I don't have, because webOS doesn't support Jetson Nano now.
but i know a guy (my friend) who had project developing autonomous car with dual Jetson Nano boards. And he made device driver for IMU sensor himself.
I helped his project just a little,
IF YOU ARE PLANNING REAL TIME AI Model processing with NANO board, and expect that board can solve the problem,
I don't recommend for several reason.
Jetson Nanoโข board has GPU cores based on Maxwell architecture, which is used in GTX 7XX & 9XXs..
Plus, Jetson Nano designed to use low power. (~20W).
How about streaming with websocket and using GPU server?
Or, using high performance mobile device could be a solution. ( Smart Phones)
2 Likes
I've used well-tuned sample TFLite models with raspberrypi 4.
A tutorial showing how to train, convert, and run TensorFlow Lite object detection models on Android devices, the Raspberry Pi, and more! - GitHub - EdjeElectronics/TensorFlow-Lite-Object-Detection...
But, when i use webcam, the maximum FPS was about ~10. (maybe input frame was 720p).
If you can make code using multi-threading, how about just processing a few frames per a sec, not whole frames? You can still display all frames.
Or, if you can, try make algorithm to cropping sub frames images for processing. because objects have a tendency to move continuously.
it might be a hard task. Cuz that idea occurred to me just now.
(i dont know if it works well or not.)
https://pytorch.org/tutorials/intermediate/realtime_rpi.html
https://pyimagesearch.com/2017/10/09/optimizing-opencv-on-the-raspberry-pi/
https://da2so.tistory.com/10?category=1044817
2 Likes
oh my god! Thank you so mach.
It's an excuse, but the assignment was until yesterday,
So I'm only replying now.
Even if it's 10 fps, I'll give it a try. I'll try again tomorrow.
์ง์ง... ๊ฐ์ฌํฉ๋๋ค ใ
ใ
์์์ผ์ ๋ฆ์ ์ข
๊ฐ์ ํ์ง๋ง ๊ณผ์ ๋ง๊ฐ์ด ์ด์ ๊น์ง ์์ต๋๋คใ
ใ
๊ทธ๋์ ๋ฉ์ผ์ ์ง๊ธ ํ์ธ ํ๋ค์ฌ. 10ํ๋ ์์ด์ด๋ ํ๋ฒ ํด๋ด์ผ ๊ฒ ๋ค์ฌ ใ
ใ
์ฃผ์ ์๋ฃ ์ฐธ๊ณ ํด์ ๋ด์ผ ํ๋ฒ ํด๋ณผ๊ฒ์ฌ!
๋ค์ ํ๋ฒ ๊ฐ์ฌํฉ๋๋ค!
1 Like
I found a project that using AI features.
check this video!
1 Like
Oh! Thanks for finding the material.
I am trying to proceed with Jetson nano 4GB now, but a problem occurred while installing OpenCV.
In the process of installing OpenCV, a repetitive error occurs in the process of specifying the CMAKE option and executing make -j4.
I went through various solutions as follows, but Opencv does not install properly.
Install Ubuntu18.04, Jetpack4.6.1, OpenCV4.5.0 - Failed
Jetpack 4.5.1 installed and challenged - failed
In the process of cmake, it is not properly installed even if you follow the instructions on the 'Q-Engineering' site.
I don't know what's wrong.
์ง์ง ๋งค๋ฒ ์ฑ๊ฒจ์ฃผ์
์ ๊ฐ์ฌํฉ๋๋ค..ใ
ใ
ํน์ ์ ์จ๋๋
ธ ๋น๋์๋ฌ๊ฐ ๋ฐ์ํด์ ์ผ์ฃผ์ผ์งธ ์๋ฌ ๋ชป์ก๊ณ ์๋๋ฐ OpenCV๋ฅผ ์ค์นํ๋ ๊ณผ์ ์์ CMAKE ์ต์
์ ์ง์ ํ๊ณ make -j4๋ฅผ ํ๋ ๊ณผ์ ์์ ๋ฐ๋ณต์ ์ธ ์๋ฌ๊ฐ ๋ฐ์ํฉ๋๋ค.
๋ค์๊ณผ ๊ฐ์ด ์ฌ๋ฌ๊ฐ์ง ์๋ฃจ์
์ ์งํํ๋๋ฐ Opencv๊ฐ ์ ๋๋ก ์ค์น๊ฐ ์๋ฉ๋๋ค.
Ubuntu18.04, Jetpack4.6.1, OpenCV4.5.0 ์ค์น -์คํจ ใ
ใ
Jetpack4.5.1์ค์นํด์ ๋์ -์คํจ ใ
ใ
cmakeํ๋ ๊ณผ์ ์์ 'Q-์์ง๋์ด๋ง' ์ฌ์ดํธ์ ๋ช
๋ น์ด๋ฅผ ๋ฐ๋ผํด๋ ์ ๋๋ก ์ค์น๊ฐ ์๋ฉ๋๋ค..
๋ฌด์์ด ๋ฌธ์ ์ธ์ง ๋ชจ๋ฅด๊ฒ ์ต๋๋ค. ์ ฏ์จ๋๋
ธ ์ฌ์ฉํ๊ธฐ ์ด๋ ต๋ค์..ใ
ใ
ใ
ใ
I want to help you.. but ... I don't know either...
1 Like
I solved that problem.
Thank you for answering each question.
Have a good weekend!