-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace opencv with gstreamer #5
Comments
Same question :D |
Decoding the H.264 (or other format) stream using CPU can cost much. Here is a GPU decoding example using ffmpeg with Nvidia-P40, (20 cameras are piece of cakes, open 20 scripts or what you like) import os
import cv2
import numpy as np
import subprocess as sp
import time
import sys
V_W, V_H, V_C = 1920, 1080, 3
BUFFER_SIZE = V_W * V_H * V_C
cmd_in = ['ffmpeg', '-hwaccel_device', '0', '-hwaccel', 'cuvid',
'-c:v', 'h264_cuvid', '-resize', f'{V_W}x{V_H}', '-vsync', '1',
'-i', f'RSTP ADDRESS',
'-vf', 'scale_npp=format=yuv420p,hwdownload,format=yuv420p',
'-f', 'image2pipe', '-pix_fmt', 'bgr24', '-vcodec', 'rawvideo', '-']
pipe_in = sp.Popen(cmd_in, stdout=sp.PIPE)
# cmd_out = ['ffmpeg', '-y', '-f', 'rawvideo', '-vcodec', 'rawvideo',
# '-pix_fmt', 'bgr24', '-s', f'{V_W}x{V_H}', '-i', '-', '-c:v',
# 'h264_nvenc', '-pix_fmt', 'yuv420p', '-preset', 'fast',
# '-f', 'flv', f'rtmp://127.0.0.1:1935/hk{index}/livestream']
# pipe_out = sp.Popen(cmd_out, stdin=sp.PIPE)
while True:
src = pipe_in.stdout.read(BUFFER_SIZE)
frame = np.frombuffer(src[:BUFFER_SIZE], dtype=np.uint8)
frame = frame_22.reshape(V_H, V_W, V_C)
# pipe_out.stdin.write(frame.tostring())
cv2.imshow('res', frame)
if cv2.waitKey(10) == ord('q'):
break |
lol, I removed the landmark branch. |
Thank you |
@roiksail Did you successfully run this repo with opencv? And if yes, how about the fps when comparing with gstreamer? Plz shared your work with me if you already done it. |
Great work for sharing. |
How to change this code with opencv instead of gstreamer?
Whats difference of between gstreamer and opencv in cpu usage and speed?
My goal for this project is to have a large number of cameras for high fps processing.
For example 20 cameras
But the problem is that more than 7 cameras,my cpu usage reaches over 98% and it is not possible to add a new one.
How can I do this project on 20 cameras at a time?
490mb is model loaded by gpu for simgle camera and I probably won't get down to the gpu resource source. I think my problem is the cpu resource
gpu: 1080ti(11gb), cpu: core i7 9700k
Or at least how to choose the system I need for this project?
The text was updated successfully, but these errors were encountered: