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, 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")) 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")) helptext="Array of triggers that will use all cameras"))
array.add_def('hour', shconf.StringDef()) array.add_def('hour', shconf.StringDef())
array.add_def('minute', 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 # Seconds to wait for exposure and white balance auto-adjust to stabilise
self.stabilise_delay = 3 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") self.save_directory = os.path.join(self.root_dir, "picamera")
else: else:
self.save_directory = self.config["save_directory"] self.save_directory = self.config["save_directory"]
@ -130,7 +130,6 @@ class PiCamPlugin(shepherd.plugin.Plugin):
overlay.putalpha(128) overlay.putalpha(128)
return overlay return overlay
def camera_job(self): def camera_job(self):
self.hooks.pre_cam() self.hooks.pre_cam()

@ -161,7 +161,7 @@ class Bucket():
class UploaderPlugin(shepherd.plugin.Plugin): class UploaderPlugin(shepherd.plugin.Plugin):
@staticmethod @staticmethod
def define_config(confdef): 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('name', shconf.StringDef())
dests.add_def('protocol', shconf.StringDef()) dests.add_def('protocol', shconf.StringDef())
dests.add_def('address', shconf.StringDef(optional=True)) 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( dests.add_def('add_id_to_path', shconf.BoolDef(
default=True, optional=True)) 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('name', shconf.StringDef())
buckets.add_def('open_link_on_new', shconf.BoolDef()) buckets.add_def('open_link_on_new', shconf.BoolDef())
buckets.add_def('opportunistic', shconf.BoolDef( buckets.add_def('opportunistic', shconf.BoolDef(

@ -29,11 +29,15 @@ CameraPort = namedtuple(
'CameraPort', ['usbPath', 'devicePath']) 'CameraPort', ['usbPath', 'devicePath'])
# Short wrapper to allow use in a ``with`` context # Short wrapper to allow use in a ``with`` context
class VideoCaptureCtx(): class VideoCaptureCtx():
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.capture_dev = cv2.VideoCapture(*args, **kwargs) self.capture_dev = cv2.VideoCapture(*args, **kwargs)
def __enter__(self): def __enter__(self):
return self.capture_dev return self.capture_dev
def __exit__(self, *args): def __exit__(self, *args):
self.capture_dev.release() 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, 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")) 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")) helptext="Array of triggers that will use all cameras"))
array.add_def('hour', shconf.StringDef()) array.add_def('hour', shconf.StringDef())
array.add_def('minute', shconf.StringDef()) array.add_def('minute', shconf.StringDef())
array.add_def('second', shconf.StringDef(default="0", optional=True)) 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.")) 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, camarray.add_def('name', shconf.StringDef(default="", optional=False,
helptext="Name of camera, appended to filename and added to overlay")) helptext="Name of camera, appended to filename and added to overlay"))
@ -150,7 +154,7 @@ class USBCamPlugin(shepherd.plugin.Plugin):
self.gstlock = threading.Lock() 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") self.save_directory = os.path.join(self.root_dir, "usbcamera")
else: else:
self.save_directory = self.config["save_directory"] self.save_directory = self.config["save_directory"]
@ -237,7 +241,7 @@ class USBCamPlugin(shepherd.plugin.Plugin):
if self.config["append_id"]: if self.config["append_id"]:
image_filename = image_filename + " " + self.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+" "+camera_name
image_filename = image_filename + ".jpg" image_filename = image_filename + ".jpg"
image_filename = os.path.join(self.save_directory, image_filename) 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"]) size = get_largest_resolution(fmts["MJPG"])
set_camera_format_opencv(vidcap, "MJPG", size[0], size[1]) set_camera_format_opencv(vidcap, "MJPG", size[0], size[1])
# stream only starts after first grab # stream only starts after first grab
print("Starting cam") print("Starting cam")
@ -285,7 +288,6 @@ class USBCamPlugin(shepherd.plugin.Plugin):
# print("Reading again") # print("Reading again")
# read_flag, frame2 = vidcap.read() # read_flag, frame2 = vidcap.read()
if read_flag: if read_flag:
self._process_image(frame, camera_name) self._process_image(frame, camera_name)
# self._process_image(frame2, camera_name+"(2)") # self._process_image(frame2, camera_name+"(2)")

Loading…
Cancel
Save