Skip to content

Instantly share code, notes, and snippets.

@TIS-Edgar
Created June 23, 2020 05:39
Show Gist options
  • Save TIS-Edgar/5b7f27bfd369082144d6d3a767f7bf17 to your computer and use it in GitHub Desktop.
Save TIS-Edgar/5b7f27bfd369082144d6d3a767f7bf17 to your computer and use it in GitHub Desktop.
TCAM_LOG=DEBUG ./test-script.py --gst-debug=tcambin:5
#!/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
serial = None
pipeline = Gst.parse_launch("tcambin name=bin state={\"Tonemapping\":\ true}"
" ! videoconvert"
" ! ximagesink")
# retrieve the bin element from the pipeline
camera = pipeline.get_by_name("bin")
# serial is defined, thus make the source open that device
if serial is not None:
camera.set_property("serial", serial)
pipeline.set_state(Gst.State.PLAYING)
# sleep is here to ensure tcamdutils is playing
# and tonemapping is readable
time.sleep(2)
(ret, value,
min_value, max_value,
default_value, step_size,
value_type, flags,
category, group) = camera.get_tcam_property("Tonemapping")
print("Tonemapping is {}".format(value))
print("Press Ctrl-C to stop.")
# We wait with this thread until a
# KeyboardInterrupt in the form of a Ctrl-C
# arrives. This will cause the pipline
# to be set to state NULL
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
pass
finally:
pipeline.set_state(Gst.State.NULL)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment