我使用 Python3.6 与GStreamer-1.0和PyGObject (用于 python 访问)从相机( tiscamera )读取视频帧。
这些帧是通过 python 代码获取的,最终我得到了一个 GstBuffer:
import gi
gi.require_version("Gst", "1.0")
from gi.repository import
# Set up
Gst.init([])
pipeline = Gst.parse_launch("tcambin serial=12345678 name=source ! video/x-raw,format=GRAY8,width=1920,height=1080,framerate=18/1 ! appsink name=sink")
sink = pipeline.get_by_name("sink")
sink.set_property("max-buffers", 10)
sink.set_property("drop", 1)
sink.set_property("emit-signals", 1)
pipeline.set_state(Gst.State.PLAYING)
# Get sample
sample = sink.emit("pull-sample")
buffer = sample.get_buffer()
meta = buffer.get_meta("TcamStatisticsMetaApi")
Run Code Online (Sandbox Code Playgroud)
元的类型是 gi.repository.Gst.Meta,但在 C 中它实际上是 TcamStatisticsMeta*,可以通过查看 tiscamera 的 c 代码示例10-metadata.c来理解。那里的C代码是:
GstBuffer* buffer = gst_sample_get_buffer(sample);
GstMeta* meta = gst_buffer_get_meta(buffer, g_type_from_name("TcamStatisticsMetaApi"));
GstStructure* struc …Run Code Online (Sandbox Code Playgroud)