@@ -146,7 +146,7 @@ def init_signals(self):
146
146
147
147
def set_image_size (self , width , height ):
148
148
HWR .beamline .sample_view .camera .restart_streaming ((width , height ))
149
- return self .app . beamline . get_viewport_info ()
149
+ return self .get_viewport_info ()
150
150
151
151
def move_to_centred_position (self , point_id ):
152
152
point = HWR .beamline .sample_view .get_shape (point_id )
@@ -368,3 +368,48 @@ def set_centring_method(self, method):
368
368
HWR .beamline .queue_manager .centring_method = CENTRING_METHOD .MANUAL
369
369
370
370
logging .getLogger ("user_level_log" ).info (msg )
371
+
372
+ def get_viewport_info (self ):
373
+ """
374
+ Get information about current "view port" video dimension, beam position,
375
+ pixels per mm, returns a dictionary with the format:
376
+
377
+ data = {"pixelsPerMm": pixelsPerMm,
378
+ "imageWidth": width,
379
+ "imageHeight": height,
380
+ "format": fmt,
381
+ "sourceIsScalable": source_is_scalable,
382
+ "scale": scale,
383
+ "videoSizes": video_sizes,
384
+ "position": position,
385
+ "shape": shape,
386
+ "size_x": sx, "size_y": sy}
387
+
388
+ :returns: Dictionary with view port data, with format described above
389
+ :rtype: dict
390
+ """
391
+ fmt , source_is_scalable = "MJPEG" , False
392
+
393
+ if self .app .CONFIG .app .VIDEO_FORMAT == "MPEG1" :
394
+ fmt , source_is_scalable = "MPEG1" , True
395
+ video_sizes = HWR .beamline .sample_view .camera .get_available_stream_sizes ()
396
+ (width , height , scale ) = HWR .beamline .sample_view .camera .get_stream_size ()
397
+ else :
398
+ scale = 1
399
+ width = HWR .beamline .sample_view .camera .get_width ()
400
+ height = HWR .beamline .sample_view .camera .get_height ()
401
+ video_sizes = [(width , height )]
402
+
403
+ pixels_per_mm = HWR .beamline .diffractometer .get_pixels_per_mm ()
404
+
405
+ return {
406
+ "pixelsPerMm" : pixels_per_mm ,
407
+ "imageWidth" : width ,
408
+ "imageHeight" : height ,
409
+ "format" : fmt ,
410
+ "sourceIsScalable" : source_is_scalable ,
411
+ "scale" : scale ,
412
+ "videoSizes" : video_sizes ,
413
+ "videoHash" : HWR .beamline .sample_view .camera .stream_hash ,
414
+ "videoURL" : self .app .CONFIG .app .VIDEO_STREAM_URL ,
415
+ }
0 commit comments