-
Notifications
You must be signed in to change notification settings - Fork 0
/
calibrate.py
63 lines (49 loc) · 1.9 KB
/
calibrate.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
56
57
import sys
if sys.version_info[0] == 2: # Just checking your Python version to import Tkinter properly.
from Tkinter import *
else:
from tkinter import *
import pypylon
import cv2
#
# asus P3b : 1280x800
#
class Fullscreen_Window:
def __init__(self):
self.tk = Tk()
self.init_cameras()
self.tk.attributes('-zoomed', True) # maximize so we can see window
self.imagepanel = Label(self.tk, text="calibrate")
self.imagepanel.pack()
self.tk.bind("<Escape>", self.end_acquire)
self.tk.bind("<Key>", self.snap)
self.imgnum = 0;
def init_cameras(self):
available_cameras = pypylon.factory.find_devices()
print('Available cameras are', available_cameras)
self.cam0 = pypylon.factory.create_device(available_cameras[0])
self.cam1 = pypylon.factory.create_device(available_cameras[1])
print('Camera info of camera object:', self.cam0.device_info)
print('Camera info of camera object:', self.cam1.device_info)
self.cam0.open()
self.cam1.open()
# Hard code exposure time
self.cam0.properties['ExposureTime'] = 200000.0
self.cam0.properties['Gain'] = 0.0
self.cam1.properties['ExposureTime'] = 200000.0
self.cam1.properties['Gain'] = 0.0
def end_acquire(self, event=None):
exit()
def snap(self, event=None):
print("capture %d" % self.imgnum)
for image in self.cam0.grab_images(1):
image = cv2.cvtColor(image, cv2.COLOR_BAYER_RG2RGB_EA)
cv2.imwrite("calib/frame_C0_%02d.png" % self.imgnum, image)
for image in self.cam1.grab_images(1):
image = cv2.cvtColor(image, cv2.COLOR_BAYER_RG2RGB_EA)
cv2.imwrite("calib/frame_C1_%02d.png" % self.imgnum, image)
self.imgnum += 1
if __name__ == '__main__':
w = Fullscreen_Window()
w.tk.update()
w.tk.mainloop()