|
|
|
|
@ -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)")
|
|
|
|
|
|