|
发表于 2022-10-24 18:18:12
只看该作者
8#
另外我改用gstreamer+MPP 来读rtsp 脚本连接:https://pan.baidu.com/s/1m15-u6HLiIv2HJLK58rCQg
提取码:om5f
可以正常显示画面 但是在程序中获取图像数据同样也是获取不到
def on_new_sample(app_sink):
sample = app_sink.pull_sample()
caps = sample.get_caps()
# Extract the width and height info from the sample's caps
height = caps.get_structure(0).get_value("height")
width = caps.get_structure(0).get_value("width")
print(height, width , 3)-------这里和用opencv结果一样1084*1920 实际应该是1080*1920
# Get the actual data
buffer = sample.get_buffer()
print(caps,"buffer size ",buffer.get_size())
# Get read access to the buffer data
success, map_info = buffer.map(Gst.MapFlags.READ)
print(success) #-------这里返回的是false,无法完成后面的numpy转换
print(map_info)
if not success:
raise RuntimeError("Could not map buffer data!")
numpy_frame = np.ndarray(
shape=(height, width, 3),
dtype=np.uint8,
buffer=map_info.data)
print(numpy_frame)
buffer.unmap(map_info)
|
|