python - GStreamer 动态更改图像大小
问题描述
首先:是的,我知道之前有人问过这个问题,但答案并没有真正帮助我,因为我对 Gstreamer 还不是很熟悉,我需要更多帮助。我正在尝试创建一个管道videocrop
并动态更改值。以下是我返回错误的代码:TypeError: object of type GstVideoCrop does not have property caps
. 所以我想这是不可能的,或者我做错了......谢谢你的帮助!
import gi
gi.require_version('Tcam', '0.1')
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst, Tcam
GObject.threads_init()
Gst.init(())
p = Gst.parse_launch("tcambin name=src ! video/x-raw, format=BGRx ! videocrop name=try top=0 left=300 right=150 bottom=0 ! videoconvert ! ximagesink")
p.set_state(Gst.State.PLAYING)
p.set_state(Gst.State.READY)
m = p.get_by_name("try")
caps = Gst.caps_from_string("videocrop name=try top=500 left=300 right=150 bottom=0")
m.set_property("caps", caps)
p.set_state(Gst.State.PLAYING)
GObject.MainLoop.run()
解决方案
我真的让它工作了!我以错误的方式尝试它。以下作品:
import gi
gi.require_version('Tcam', '0.1')
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst, Tcam
GObject.threads_init()
Gst.init(())
p = Gst.parse_launch("tcambin name=src ! video/x-raw, format=BGRx ! videocrop name=caps top=0 left=300 right=150 bottom=0 ! videoconvert ! ximagesink")
p.set_state(Gst.State.PLAYING)
p.set_state(Gst.State.READY)
m = p.get_by_name("caps")
m.set_property("top", 500)
p.set_state(Gst.State.PLAYING)
GObject.MainLoop.run()
推荐阅读
- tensorflow - 关键错误:logtostderr(python,tensorflow)
- css - 如何让第 n 个类型的模式像 1-2-2-1 一样工作?
- qlikview - Qlikview 使用 forloop 迭代临时表的结果集
- django - 为什么我不能在管理站点上注册我的 Django App 模型?
- python - 如何改进正则表达式以找到最合适的 URL 字符串?
- mariadb - 我应该在包含大量数据的表上使用 WITH 而不是 JOIN 吗?
- c# - 我想将形状添加到工具箱控件然后能够将它们放入图表控件
- swift - Alamofire 没有得到充分的回应
- sql-server - SQL Server 代理中的错误:“varchar 数据类型与 datetime 数据类型的对话导致超出范围。”
- gtk - NetworkManager 调度程序脚本打开窗口