我正在尝试使用Gstreamer(Python3)同时为两个相机设置相机参数(曝光和增益)。我已经使用摄像机序列ID创建了两个单独的管道,并遵循了此后用于单个(唯一)摄像机管道的方法。但是,在执行我的脚本时,只为其中一个摄像头设置了参数。下面的代码中有没有我需要修改的地方?蒂娅。
#!/usr/bin/env python3
import time
import sys
import gi
gi.require_version("Tcam", "0.1")
gi.require_version("Gst", "1.0")
from gi.repository import Tcam, Gst
def main():
Gst.init(sys.argv) # init gstreamer
serial1='05020863'
serial2='05020864'
pipeline1 = Gst.parse_launch("tcambin name=source1"
" ! video/x-raw,format=BGRx,width=720,height=540,framerate=30/1"
" ! tee name=t"
" ! queue"
" ! videoconvert"
" ! ximagesink"
" t."
" ! queue"
" ! videoconvert"
" ! avimux"
" ! filesink name=fsink1")
pipeline2 = Gst.parse_launch("tcambin name=source2"
" ! video/x-raw,format=BGRx,width=720,height=540,framerate=30/1"
" ! tee name=t"
" ! queue"
" ! videoconvert"
" ! ximagesink"
" t."
" ! queue"
" ! videoconvert"
" ! avimux"
" ! filesink name=fsink2")
if serial1 is not None:
camera1 = pipeline1.get_by_name("source1")
camera1.set_property("serial", serial1)
if serial2 is not None:
camera2 = pipeline2.get_by_name("source2")
camera2.set_property("serial",serial2)
file_location1 = "/home/pandey/TIS/tiscamera/examples/python/tiscamera-save-stream-1.avi"
file_location2 = "/home/pandey/TIS/tiscamera/examples/python/tiscamera-save-stream-2.avi"
camera1 = Gst.ElementFactory.make("tcambin")
camera2 = Gst.ElementFactory.make("tcambin")
camera1.set_state(Gst.State.READY)
camera1.set_tcam_property("Exposure Auto", False)
camera1.set_tcam_property("Gain Auto", False)
camera2.set_state(Gst.State.READY)
camera2.set_tcam_property("Exposure Auto", False)
camera2.set_tcam_property("Gain Auto", False)
camera1.set_tcam_property("Exposure Time",10)
camera1.set_tcam_property("Gain",450)
camera2.set_tcam_property("Exposure Time",10)
camera2.set_tcam_property("Gain",450)
fsink1 = pipeline1.get_by_name("fsink1")
fsink1.set_property("location", file_location1)
fsink2 = pipeline2.get_by_name("fsink2")
fsink2.set_property("location", file_location2)
pipeline1.set_state(Gst.State.PLAYING)
pipeline2.set_state(Gst.State.PLAYING)
print("Press Ctrl-C to stop.")
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
pass
finally:
pipeline1.set_state(Gst.State.NULL)
pipeline2.set_state(Gst.State.NULL)
if __name__ == "__main__":
main()发布于 2020-06-30 13:14:41
你的问题在这里:
camera1 = Gst.ElementFactory.make("tcambin")
camera2 = Gst.ElementFactory.make("tcambin")为什么你要创建两个与你的流水线完全分离的新元素,并将它们放在ready上?你应该直接使用(就像你之前正确做的那样)
camera1 = pipeline1.get_by_name("source1")
camera2 = pipeline1.get_by_name("source2")以获取对管道中实际元素的引用。
https://stackoverflow.com/questions/62646026
复制相似问题