diff --git a/devices/Beam phase.properties b/devices/Beam phase.properties index a4e6d44..737c016 100644 --- a/devices/Beam phase.properties +++ b/devices/Beam phase.properties @@ -1,9 +1,9 @@ -#Mon Nov 13 08:29:32 CET 2017 +#Tue Nov 14 09:09:44 CET 2017 maxValue=360.0 minValue=-360.0 offset=0.0 precision=3 resolution=0.1 -rotation=true +rotation=false scale=1.0 unit=deg diff --git a/devices/CurrentCamera.properties b/devices/CurrentCamera.properties index f673ed5..966ba43 100644 --- a/devices/CurrentCamera.properties +++ b/devices/CurrentCamera.properties @@ -1,11 +1,11 @@ -#Mon Nov 13 09:48:57 CET 2017 +#Wed Nov 15 08:34:00 CET 2017 \u0000\u0000\u0000\u0000= \u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000= \u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000= colormap=Flame -colormapAutomatic=true -colormapMax=1792.0 -colormapMin=50.0 +colormapAutomatic=false +colormapMax=10239.0 +colormapMin=86.0 flipHorizontally=false flipVertically=false grayscale=false @@ -24,9 +24,9 @@ rotation=0.0 rotationCrop=false scale=1.0 serverURL=localhost\:10000 -spatialCalOffsetX=-341.5066993679644 -spatialCalOffsetY=-480.6332485949483 -spatialCalScaleX=-8.737659471350296 -spatialCalScaleY=-8.834897808789577 +spatialCalOffsetX=-145.62499649229636 +spatialCalOffsetY=-440.5890253136218 +spatialCalScaleX=-8.737659322804419 +spatialCalScaleY=-8.834898186495984 spatialCalUnits= transpose=false diff --git a/devices/cam2.properties b/devices/cam2.properties index 9ebefe1..d91eabd 100644 --- a/devices/cam2.properties +++ b/devices/cam2.properties @@ -1,4 +1,4 @@ -#Thu Nov 09 09:40:25 CET 2017 +#Tue Nov 14 18:25:46 CET 2017 colormap=Flame colormapAutomatic=true colormapMax=255.0 @@ -6,13 +6,13 @@ colormapMin=0.0 flipHorizontally=false flipVertically=false grayscale=false -imageHeight=1024 -imageWidth=1280 +imageHeight=-1 +imageWidth=-1 invert=false offsetX=0.0 offsetY=0.0 -regionStartX=1 -regionStartY=1 +regionStartX=0 +regionStartY=0 rescaleFactor=1.0 rescaleOffset=0.0 roiHeight=-1 diff --git a/devices/cam3.properties b/devices/cam3.properties index 0910499..0643247 100644 --- a/devices/cam3.properties +++ b/devices/cam3.properties @@ -1,4 +1,4 @@ -#Thu Nov 09 10:18:08 CET 2017 +#Tue Nov 14 18:25:47 CET 2017 colormap=Flame colormapAutomatic=true colormapMax=255.0 @@ -6,11 +6,11 @@ colormapMin=0.0 flipHorizontally=false flipVertically=false grayscale=false -imageHeight=1024 -imageWidth=1280 +imageHeight=-1 +imageWidth=-1 invert=false -regionStartX=1 -regionStartY=1 +regionStartX=0 +regionStartY=0 rescaleFactor=1.0 rescaleOffset=0.0 roiHeight=-1 diff --git a/script/Tools/save_snapshot_mult.py b/script/Tools/save_snapshot_mult.py index 82db8d8..ebf75d2 100644 --- a/script/Tools/save_snapshot_mult.py +++ b/script/Tools/save_snapshot_mult.py @@ -12,12 +12,15 @@ if get_exec_pars().source == CommandSource.ui: camera_name = "SLG-LCAM-C041_sp" shared = False images = 10 - interval = 1000 + interval = -1 + roi = "" #"[540, 200, 430,100]" else: camera_name = args[0] shared = args[1].lower() == "true" images = int(args[2]) interval = int(args[3]) + roi = args[4] + set_exec_pars(name="camera_snapshot") path_image = "/image" @@ -25,16 +28,55 @@ path_pid = "/pulse_id" path_timestamp_str = "/timestamp_str" snapshotFile = None -if shared: - cam_server.start(camera_name + "_sp1", shared) + +cam_server.start(camera_name, shared) + + + +if roi is not None and len(roi.strip())>0: + roi = json.loads(roi) + cam_server.setRoi(roi[0], roi[2], roi[1], roi[3]) + while True: + cam_server.waitNext(10000) + r = json.loads(cam_server.stream.take()["processing_parameters"]) + if roi == r["image_region_of_interest"]: + break; else: - cam_server.start(camera_name) + cam_server.waitNext(10000) + +width = cam_server.data.width +height = cam_server.data.height +type_image = 'f' + +def create_tables(stream_value): + global width, height, type_image + create_dataset(path_image, type_image, dimensions = [images, height, width]) + create_dataset(path_pid, 'l', dimensions = [images]) + create_dataset(path_timestamp_str, 's', dimensions = [images]) + for id in stream_value.identifiers: + val = stream_value.getValue(id) + if id == "image": + pass + elif id == "processing_parameters": + val = json.loads(val) + for key in val.keys(): + set_attribute(path_image, key, "" if val[key] is None else val[key] ) + elif isinstance(val, PyArray): + create_dataset("/"+id, 'd', dimensions = [images, len(val)]) + elif isinstance(val, PyLong): + create_dataset("/"+id, 'l', dimensions = [images]) + elif isinstance(val, PyFloat): + create_dataset("/"+id, 'd', dimensions = [images]) + else: + print "Unmanaged stream type: ", val, type(val) + pass def append_frame(data, stream_value, index): - global path_image + global path_image, width, height, type_image print "Saving frame :", index - append_dataset(path_image, data, index) + #append_dataset(path_image, data, index, type = type_image) + append_dataset(path_image, stream_value.getValue("image"),[index,0,0], type = type_image, shape=[1, height, width]) append_dataset(path_pid, stream_value.getPulseId(), index) append_dataset(path_timestamp_str, datetime.datetime.fromtimestamp(stream_value.timestampNanos/1e9).strftime('%Y-%m-%d %H:%M:%S'), index) @@ -56,53 +98,33 @@ def append_frame(data, stream_value, index): traceback.print_exc() print "Saved frame :", index + tasks = [] +cam_server.paused = True -cam_server.waitNext(10000) -for i in range(images): - if i==0: - stream_value = cam_server.stream.take() - width = cam_server.data.width - height = cam_server.data.height - create_dataset(path_image, 'd', dimensions = [height, width, images]) - create_dataset(path_pid, 'l', dimensions = [images]) - create_dataset(path_timestamp_str, 's', dimensions = [images]) - for id in stream_value.identifiers: - val = stream_value.getValue(id) - if id == "image": - pass - elif id == "processing_parameters": - val = json.loads(val) - for key in val.keys(): - set_attribute(path_image, key, "" if val[key] is None else val[key] ) - elif isinstance(val, PyArray): - create_dataset("/"+id, 'd', dimensions = [images, len(val)]) - elif isinstance(val, PyLong): - create_dataset("/"+id, 'l', dimensions = [images]) - elif isinstance(val, PyFloat): - create_dataset("/"+id, 'd', dimensions = [images]) - else: - print "Unmanaged stream type: ", val, type(val) - pass - - - start = time.time() - stream_value = cam_server.stream.take() - if PARALLELIZE: - tasks.extend( fork((append_frame,(cam_server.data.matrix,stream_value, i)),) ) - else: - append_frame(cam_server.data.matrix, stream_value, i) - - if i< (images-1): - if interval<=0: - cam_server.waitNext(10000) +try: + for i in range(images): + if i==0: + create_tables(cam_server.stream.take()) + + start = time.time() + stream_value = cam_server.stream.take() + if PARALLELIZE: + tasks.extend( fork((append_frame,(cam_server.data.matrix,stream_value, i)),) ) else: - sleep_time = float(interval)/1000.0 - (time.time()-start) - if (sleep_time>0): - print "Sleeping ", sleep_time - time.sleep(sleep_time) - + append_frame(cam_server.data.matrix, stream_value, i) + + if i< (images-1): + if interval<=0: + cam_server.stream.waitCacheChange(10000) + else: + sleep_time = float(interval)/1000.0 - (time.time()-start) + time.sleep(max(sleep_time,0)) +finally: + cam_server.paused = False + pass + print "Waiting finish persisting..." join(tasks) print "Done"