Reputation: 1646
I am trying to set the camera parameters(Exposure and Gain) for two cameras simultaneously using Gstreamer(Python3). I have created two separate pipelines using the camera serial IDs and followed the method used for single (unique)camera pipelines thereafter. However, upon execution of my script, parameters get set only for one of the cameras. Is there anything in the code below that I should amend? TIA.
#!/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()
Upvotes: 1
Views: 707
Reputation: 2743
Your problem is here:
camera1 = Gst.ElementFactory.make("tcambin")
camera2 = Gst.ElementFactory.make("tcambin")
Why are you creating 2 new elements that are completely separate from your pipeline and putting them on ready? You should just use (like you correctly did earlier)
camera1 = pipeline1.get_by_name("source1")
camera2 = pipeline1.get_by_name("source2")
to get a reference to the actual elements in the pipeline.
Upvotes: 2