@@ -225,7 +225,7 @@ def init_signals(self):
225
225
226
226
def set_image_size (self , width , height ):
227
227
HWR .beamline .sample_view .camera .restart_streaming ((width , height ))
228
- return self .app . beamline . get_viewport_info ()
228
+ return self .get_viewport_info ()
229
229
230
230
def move_to_centred_position (self , point_id ):
231
231
point = HWR .beamline .sample_view .get_shape (point_id )
@@ -447,3 +447,48 @@ def set_centring_method(self, method):
447
447
HWR .beamline .queue_manager .centring_method = CENTRING_METHOD .MANUAL
448
448
449
449
logging .getLogger ("user_level_log" ).info (msg )
450
+
451
+ def get_viewport_info (self ):
452
+ """
453
+ Get information about current "view port" video dimension, beam position,
454
+ pixels per mm, returns a dictionary with the format:
455
+
456
+ data = {"pixelsPerMm": pixelsPerMm,
457
+ "imageWidth": width,
458
+ "imageHeight": height,
459
+ "format": fmt,
460
+ "sourceIsScalable": source_is_scalable,
461
+ "scale": scale,
462
+ "videoSizes": video_sizes,
463
+ "position": position,
464
+ "shape": shape,
465
+ "size_x": sx, "size_y": sy}
466
+
467
+ :returns: Dictionary with view port data, with format described above
468
+ :rtype: dict
469
+ """
470
+ fmt , source_is_scalable = "MJPEG" , False
471
+
472
+ if self .app .CONFIG .app .VIDEO_FORMAT == "MPEG1" :
473
+ fmt , source_is_scalable = "MPEG1" , True
474
+ video_sizes = HWR .beamline .sample_view .camera .get_available_stream_sizes ()
475
+ (width , height , scale ) = HWR .beamline .sample_view .camera .get_stream_size ()
476
+ else :
477
+ scale = 1
478
+ width = HWR .beamline .sample_view .camera .get_width ()
479
+ height = HWR .beamline .sample_view .camera .get_height ()
480
+ video_sizes = [(width , height )]
481
+
482
+ pixels_per_mm = HWR .beamline .diffractometer .get_pixels_per_mm ()
483
+
484
+ return {
485
+ "pixelsPerMm" : pixels_per_mm ,
486
+ "imageWidth" : width ,
487
+ "imageHeight" : height ,
488
+ "format" : fmt ,
489
+ "sourceIsScalable" : source_is_scalable ,
490
+ "scale" : scale ,
491
+ "videoSizes" : video_sizes ,
492
+ "videoHash" : HWR .beamline .sample_view .camera .stream_hash ,
493
+ "videoURL" : self .app .CONFIG .app .VIDEO_STREAM_URL ,
494
+ }
0 commit comments