-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGUI_0.1.py
55 lines (37 loc) · 1.46 KB
/
GUI_0.1.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
44
45
46
47
48
49
50
51
52
53
54
55
import Tkinter as tk
import numpy as np
import cv2
import MMCorePy
import PIL.Image, PIL.ImageTk
# Initializing the microscope. --------------------
DEVICE = ['Camera', 'DemoCamera', 'DCam']
mmc = MMCorePy.CMMCore()
mmc.enableStderrLog(False)
mmc.enableDebugLog(False)
mmc.loadDevice(*DEVICE)
mmc.initializeDevice(DEVICE[0])
mmc.setCameraDevice(DEVICE[0])
mmc.setProperty(DEVICE[0], 'PixelType', '32bitRGB')
mmc.startContinuousSequenceAcquisition(1)
# ----------------------------------------
class App:
def __init__(self, root, title):
self.root = root
self.root.title(title)
self.canvas = tk.Canvas(self.root, width = 512, height = 512)
self.canvas.pack()
self.update()
def update(self):
if mmc.getRemainingImageCount() > 0:
rgb32 = mmc.getLastImage()
bgr = rgb32.view(dtype=np.uint8).reshape(
rgb32.shape[0], rgb32.shape[1], 4)[..., :3]
prephoto = bgr
else:
prephoto = cv2.imread('blank.png')
photo = PIL.ImageTk.PhotoImage(image = PIL.Image.fromarray(prephoto))
self.canvas.photo = photo
self.canvas.create_image(0, 0, image = photo, anchor = tk.NW)
self.root.after(1, self.update)
pba = App(tk.Tk(), "The Optical Tweezer Program")
pba.root.mainloop()