-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
43 lines (36 loc) · 1.51 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import time
from os import path
from pydm import Display
from scipy.ndimage.measurements import maximum_position
class BeamPositioning(Display):
def __init__(self, parent=None, args=None):
super(BeamPositioning, self).__init__(parent=parent, args=args)
# Attach our custom process_image method
self.ui.imageView.process_image = self.process_image
# Hook up to the newImageSignal so we can update
# our widgets after the new image is done
self.ui.imageView.newImageSignal.connect(self.show_blob)
# Store blob coordinate
self.blob = (0, 0)
def ui_filename(self):
# Point to our UI file
return 'main.ui'
def ui_filepath(self):
# Return the full path to the UI file
return path.join(path.dirname(path.realpath(__file__)), self.ui_filename())
def show_blob(self, *args, **kwargs):
# If we have a blob, present the coordinates at label
if self.blob != (0, 0):
blob_txt = "Blob Found:"
blob_txt += " ({}, {})".format(self.blob[1], self.blob[0])
else:
# If no blob was found, present the "Not Found" message
blob_txt = "Blob Not Found"
# Update the label text
self.ui.lbl_blobs.setText(blob_txt)
def process_image(self, new_image):
# Consider the maximum as the Blob since we have only
# one blob.
self.blob = maximum_position(new_image)
# Send the original image data to the image widget
return new_image