-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjust_measure.py
127 lines (117 loc) · 5.18 KB
/
just_measure.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# ./just_measure.py
#
# (c) 2010 Konstantin Sering, Nora Umbach, Dominik Wabersich
# <colorlab[at]psycho.uni-tuebingen.de>
#
# GPL 3.0+ or (cc) by-sa (http://creativecommons.org/licenses/by-sa/3.0/)
#
# content: Script for measuring monitor or tubes; define how many measurements,
# if you want to recalibrate i1, etc.
#
# input: --
# output: --
#
# created 2011-10-14
# last mod 2012-05-29, NU
import time
from ctypes import c_float
from achrolab.eyeone import eyeone, constants
#############################
# Measurement values ####
#############################
# measurement: how many measurements should one measurement process include
# imi: inter measurement intervall
measurement = 150000 ####
imi = 0.5 ####
#############################
# Repeat Measure-Process ####
#############################
# times: times variable repeats the whole measurement process 'times' times
# and asks to press the eyeone button before every new time.
# recalibrate: if times > 1, you can set 'recalibrate' to true, to recalibrate
# for every measurement process
times = 30 ####
recalibrate = True ####
#############################
# Measuring Information ####
#############################
# info: short information about what exactly you are measuring
# prefix: file prefix (in the filename)
info = "Measuring screen 30 times with different calibrations"
prefix = "30calib"
#############################
# make measurements to a list for iterations
measurements = range(measurement)
EyeOne = eyeone.EyeOne() # EyeOne Object
# set EyeOne Pro variables
if(EyeOne.I1_SetOption(constants.I1_MEASUREMENT_MODE,
constants.I1_SINGLE_EMISSION) ==
constants.eNoError):
print("Measurement mode set to single emission.")
else:
print("Failed to set measurement mode.")
if(EyeOne.I1_SetOption(constants.COLOR_SPACE_KEY,
constants.COLOR_SPACE_CIExyY) == constants.eNoError):
print("Color space set to CIExyY.")
else:
print("Failed to set color space.")
# Initialization of spectrum and colorspace
colorspace = (c_float * constants.TRISTIMULUS_SIZE)()
spectrum = (c_float * constants.SPECTRUM_SIZE)()
spec_list = []
color_list = []
# Start measurement
with open("calibdata/measurements/justmeasure_" + str(prefix) + "_spec_" +
time.strftime("%Y%m%d_%H%M") + ".txt", "w") as f1:
f1.write("Spectrum for " + str(measurement) + " measurements with "
+ str(imi) + " intervall\n" + str(times) + " times with" +
"recalibration set " + str(recalibrate) + "\n")
f1.write("Information: " + str(info) + "\n\n")
with open("calibdata/measurements/justmeasure_" + str(prefix) +
"_color_" + time.strftime("%Y%m%d_%H%from achrolab.eyeone.eyeone import EyeOneM") + ".txt", "w") as f2:
f2.write("Spectrum for " + str(meeyeone = EyeOne(dummy=True)asurement) + " measurements with "
+ str(imi) + " intervall\caltub = CalibTubes(eyeone)n" + str(times) + " times with " +
"recalibration set " + stcaltub.calibrate(imi=0.5, n=100, each=5)r(recalibrate) + "\n")
f2.write("Information: " + str(incaltub.saveParameter("example_tube_calibration.pkl")fo) + "\n\n")
for n in range(times):
if (recalibrate or (EyeOne.I1_TriggerMeasurement() ==
constants.eDeviceNotCalibrated)):
# Calibration of EyeOne
print("\nPlease put EyeOne Pro on calibration plate and press \n key to start calibration.")
while(EyeOne.I1_KeyPressed() != constants.eNoError):
time.sleep(0.1)
if (EyeOne.I1_Calibrate() == constants.eNoError):
print("Calibration done.")
else:
print("Calibration failed.")
print("\nPlease put EyeOne Pro in measurement position and press \n key to start measurement.")
while(EyeOne.I1_KeyPressed() != constants.eNoError):
time.sleep(0.1)
print("Starting measurement...")
for i in measurements:
# Trigger measurement
if(EyeOne.I1_TriggerMeasurement() != constants.eNoError):
print("Measurement failed.")
# retrieve Color Space
if(EyeOne.I1_GetTriStimulus(colorspace, 0) !=
constants.eNoError):
print("Failed to get color space.")
else:
print("Color Space " + str(colorspace[:]) + "\n")
color_list.append(colorspace[:])
# Write justmeasure color file containing the data
f2.write(str(colorspace[:])[1:-1])
f2.write("\n")
# retrieve spectrum
if(EyeOne.I1_GetSpectrum(spectrum, 0) !=
constants.eNoError):
print("Failed to get spectrum.")
else:
print("Spectrum: " + str(spectrum[:]) + "\n")
spec_list.append(spectrum[:])
# Write justmeasure spectrum file containing the data
f1.write(str(spectrum[:])[1:-1] + "\n")
f1.write("\n")
time.sleep(imi)