Update plugins with new config

fix-v0.2
Tom Wilson 5 years ago
parent 0c4184d692
commit 82cc667cbb

@ -43,7 +43,7 @@ class PiCamPlugin(shepherd.plugin.Plugin):
confdef.add_def('jpeg_quality', shconf.IntDef(default=80, minval=60, maxval=95, optional=True,
helptext="JPEG quality to save with. Max of 95, passed directly to Pillow"))
array = confdef.add_def('trigger', shconf.TableArrayDef(
array = confdef.add_def('trigger', shconf.DictListDef(
helptext="Array of triggers that will use all cameras"))
array.add_def('hour', shconf.StringDef())
array.add_def('minute', shconf.StringDef())
@ -70,7 +70,7 @@ class PiCamPlugin(shepherd.plugin.Plugin):
# Seconds to wait for exposure and white balance auto-adjust to stabilise
self.stabilise_delay = 3
if self.config["save_directory"] is "":
if self.config["save_directory"] == "":
self.save_directory = os.path.join(self.root_dir, "picamera")
else:
self.save_directory = self.config["save_directory"]
@ -130,7 +130,6 @@ class PiCamPlugin(shepherd.plugin.Plugin):
overlay.putalpha(128)
return overlay
def camera_job(self):
self.hooks.pre_cam()

@ -161,7 +161,7 @@ class Bucket():
class UploaderPlugin(shepherd.plugin.Plugin):
@staticmethod
def define_config(confdef):
dests = confdef.add_def('destination', shconf.TableArrayDef())
dests = confdef.add_def('destination', shconf.DictListDef())
dests.add_def('name', shconf.StringDef())
dests.add_def('protocol', shconf.StringDef())
dests.add_def('address', shconf.StringDef(optional=True))
@ -174,7 +174,7 @@ class UploaderPlugin(shepherd.plugin.Plugin):
dests.add_def('add_id_to_path', shconf.BoolDef(
default=True, optional=True))
buckets = confdef.add_def('bucket', shconf.TableArrayDef())
buckets = confdef.add_def('bucket', shconf.DictListDef())
buckets.add_def('name', shconf.StringDef())
buckets.add_def('open_link_on_new', shconf.BoolDef())
buckets.add_def('opportunistic', shconf.BoolDef(

@ -29,11 +29,15 @@ CameraPort = namedtuple(
'CameraPort', ['usbPath', 'devicePath'])
# Short wrapper to allow use in a ``with`` context
class VideoCaptureCtx():
def __init__(self, *args, **kwargs):
self.capture_dev = cv2.VideoCapture(*args, **kwargs)
def __enter__(self):
return self.capture_dev
def __exit__(self, *args):
self.capture_dev.release()
@ -116,13 +120,13 @@ class USBCamPlugin(shepherd.plugin.Plugin):
confdef.add_def('stabilise_delay', shconf.IntDef(default=5, minval=1, maxval=30, optional=True,
helptext="Number of seconds to wait after starting each camera for exposure and white balance to settle"))
array = confdef.add_def('trigger', shconf.TableArrayDef(
array = confdef.add_def('trigger', shconf.DictListDef(
helptext="Array of triggers that will use all cameras"))
array.add_def('hour', shconf.StringDef())
array.add_def('minute', shconf.StringDef())
array.add_def('second', shconf.StringDef(default="0", optional=True))
camarray = confdef.add_def('camera', shconf.TableArrayDef(
camarray = confdef.add_def('camera', shconf.DictListDef(
helptext="List of cameras to try and connect to. Multiple ports may be listed, and any not connected will be skipped on each trigger."))
camarray.add_def('name', shconf.StringDef(default="", optional=False,
helptext="Name of camera, appended to filename and added to overlay"))
@ -150,7 +154,7 @@ class USBCamPlugin(shepherd.plugin.Plugin):
self.gstlock = threading.Lock()
if self.config["save_directory"] is "":
if self.config["save_directory"] == "":
self.save_directory = os.path.join(self.root_dir, "usbcamera")
else:
self.save_directory = self.config["save_directory"]
@ -237,7 +241,7 @@ class USBCamPlugin(shepherd.plugin.Plugin):
if self.config["append_id"]:
image_filename = image_filename + " " + self.id
if camera_name is not "":
if camera_name != "":
image_filename = image_filename+" "+camera_name
image_filename = image_filename + ".jpg"
image_filename = os.path.join(self.save_directory, image_filename)
@ -264,7 +268,6 @@ class USBCamPlugin(shepherd.plugin.Plugin):
size = get_largest_resolution(fmts["MJPG"])
set_camera_format_opencv(vidcap, "MJPG", size[0], size[1])
# stream only starts after first grab
print("Starting cam")
@ -285,7 +288,6 @@ class USBCamPlugin(shepherd.plugin.Plugin):
# print("Reading again")
# read_flag, frame2 = vidcap.read()
if read_flag:
self._process_image(frame, camera_name)
# self._process_image(frame2, camera_name+"(2)")

Loading…
Cancel
Save