summaryrefslogtreecommitdiff
path: root/utils/raspberrypi
diff options
context:
space:
mode:
Diffstat (limited to 'utils/raspberrypi')
-rwxr-xr-xutils/raspberrypi/ctt/ctt.py17
-rw-r--r--utils/raspberrypi/ctt/ctt_alsc.py12
-rw-r--r--utils/raspberrypi/ctt/ctt_awb.py14
-rw-r--r--utils/raspberrypi/ctt/ctt_ccm.py8
-rw-r--r--utils/raspberrypi/ctt/ctt_macbeth_locator.py12
-rw-r--r--utils/raspberrypi/ctt/ctt_ransac.py4
6 files changed, 34 insertions, 33 deletions
diff --git a/utils/raspberrypi/ctt/ctt.py b/utils/raspberrypi/ctt/ctt.py
index 46cf92cd..07230fe3 100755
--- a/utils/raspberrypi/ctt/ctt.py
+++ b/utils/raspberrypi/ctt/ctt.py
@@ -71,7 +71,7 @@ class Camera:
self.path = ''
self.imgs = []
self.imgs_alsc = []
- self.log = 'Log created : '+ time.asctime(time.localtime(time.time()))
+ self.log = 'Log created : ' + time.asctime(time.localtime(time.time()))
self.log_separator = '\n'+'-'*70+'\n'
self.jf = jfile
"""
@@ -227,7 +227,7 @@ class Camera:
cal_cb_list = self.json['rpi.alsc']['calibrations_Cb']
self.log += '\nALSC tables found successfully'
except KeyError:
- cal_cr_list, cal_cb_list=None, None
+ cal_cr_list, cal_cb_list = None, None
print('WARNING! No ALSC tables found for CCM!')
print('Performing CCM calibrations without ALSC correction...')
self.log += '\nWARNING: No ALSC tables found.\nCCM calibration '
@@ -236,7 +236,7 @@ class Camera:
"""
case where config options result in CCM done without ALSC colour tables
"""
- cal_cr_list, cal_cb_list=None, None
+ cal_cr_list, cal_cb_list = None, None
self.log += '\nWARNING: No ALSC tables found.\nCCM calibration '
self.log += 'performed without ALSC correction...'
@@ -292,13 +292,13 @@ class Camera:
cal_cb_list = self.json['rpi.alsc']['calibrations_Cb']
self.log += '\nALSC tables found successfully'
except KeyError:
- cal_cr_list, cal_cb_list=None, None
+ cal_cr_list, cal_cb_list = None, None
print('ERROR, no ALSC calibrations found for AWB')
print('Performing AWB without ALSC tables')
self.log += '\nWARNING: No ALSC tables found.\nAWB calibration '
self.log += 'performed without ALSC correction...'
else:
- cal_cr_list, cal_cb_list=None, None
+ cal_cr_list, cal_cb_list = None, None
self.log += '\nWARNING: No ALSC tables found.\nAWB calibration '
self.log += 'performed without ALSC correction...'
"""
@@ -502,9 +502,9 @@ class Camera:
for key in disable:
try:
del self.json[key]
- self.log += '\nDisabled: '+key
+ self.log += '\nDisabled: ' + key
except KeyError:
- self.log += '\nERROR: '+key +' not found!'
+ self.log += '\nERROR: ' + key + ' not found!'
"""
writes the json dictionary to the raw json file then make pretty
"""
@@ -685,7 +685,8 @@ class Camera:
blacklevels = list(set([Img.blacklevel_16 for Img in all_imgs]))
sizes = list(set([(Img.w, Img.h) for Img in all_imgs]))
- if len(camNames)==1 and len(patterns)==1 and len(sigbitss)==1 and len(blacklevels) ==1 and len(sizes)== 1:
+ if len(camNames) == 1 and len(patterns) == 1 and len(sigbitss) == 1 and \
+ len(blacklevels) == 1 and len(sizes) == 1:
self.grey = (patterns[0] == 128)
self.blacklevel_16 = blacklevels[0]
self.log += '\nName: {}'.format(camNames[0])
diff --git a/utils/raspberrypi/ctt/ctt_alsc.py b/utils/raspberrypi/ctt/ctt_alsc.py
index a006f7ff..d6e1020f 100644
--- a/utils/raspberrypi/ctt/ctt_alsc.py
+++ b/utils/raspberrypi/ctt/ctt_alsc.py
@@ -61,10 +61,10 @@ def alsc_all(Cam, do_alsc_colour, plot):
"""
force numbers to be stored to 3dp.... :(
"""
- t_r = np.where((100*t_r)%1<=0.05, t_r+0.001, t_r)
- t_b = np.where((100*t_b)%1<=0.05, t_b+0.001, t_b)
- t_r = np.where((100*t_r)%1>=0.95, t_r-0.001, t_r)
- t_b = np.where((100*t_b)%1>=0.95, t_b-0.001, t_b)
+ t_r = np.where((100*t_r)%1 <= 0.05, t_r+0.001, t_r)
+ t_b = np.where((100*t_b)%1 <= 0.05, t_b+0.001, t_b)
+ t_r = np.where((100*t_r)%1 >= 0.95, t_r-0.001, t_r)
+ t_b = np.where((100*t_b)%1 >= 0.95, t_b-0.001, t_b)
t_r = np.round(t_r, 3)
t_b = np.round(t_b, 3)
r_corners = (t_r[0], t_r[15], t_r[-1], t_r[-16])
@@ -95,8 +95,8 @@ def alsc_all(Cam, do_alsc_colour, plot):
average all values for luminance shading and return one table for all temperatures
"""
lum_lut = np.mean(list_cg, axis=0)
- lum_lut = np.where((100*lum_lut)%1<=0.05, lum_lut+0.001, lum_lut)
- lum_lut = np.where((100*lum_lut)%1>=0.95, lum_lut-0.001, lum_lut)
+ lum_lut = np.where((100*lum_lut)%1 <= 0.05, lum_lut+0.001, lum_lut)
+ lum_lut = np.where((100*lum_lut)%1 >= 0.95, lum_lut-0.001, lum_lut)
lum_lut = list(np.round(lum_lut, 3))
"""
diff --git a/utils/raspberrypi/ctt/ctt_awb.py b/utils/raspberrypi/ctt/ctt_awb.py
index 297ba178..3abafbf5 100644
--- a/utils/raspberrypi/ctt/ctt_awb.py
+++ b/utils/raspberrypi/ctt/ctt_awb.py
@@ -27,8 +27,8 @@ def awb(Cam, cal_cr_list, cal_cb_list, plot):
"""
normalise tables so min value is 1
"""
- cr_tab= cr_tab/np.min(cr_tab)
- cb_tab= cb_tab/np.min(cb_tab)
+ cr_tab = cr_tab/np.min(cr_tab)
+ cb_tab = cb_tab/np.min(cb_tab)
colour_cals[cr['ct']] = [cr_tab, cb_tab]
"""
obtain data from greyscale macbeth patches
@@ -183,10 +183,10 @@ def awb(Cam, cal_cr_list, cal_cb_list, plot):
"""
round to 4dp
"""
- r_fit = np.where((1000*r_fit)%1<=0.05, r_fit+0.0001, r_fit)
- r_fit = np.where((1000*r_fit)%1>=0.95, r_fit-0.0001, r_fit)
- b_fit = np.where((1000*b_fit)%1<=0.05, b_fit+0.0001, b_fit)
- b_fit = np.where((1000*b_fit)%1>=0.95, b_fit-0.0001, b_fit)
+ r_fit = np.where((1000*r_fit)%1 <= 0.05, r_fit+0.0001, r_fit)
+ r_fit = np.where((1000*r_fit)%1 >= 0.95, r_fit-0.0001, r_fit)
+ b_fit = np.where((1000*b_fit)%1 <= 0.05, b_fit+0.0001, b_fit)
+ b_fit = np.where((1000*b_fit)%1 >= 0.95, b_fit-0.0001, b_fit)
r_fit = np.round(r_fit, 4)
b_fit = np.round(b_fit, 4)
"""
@@ -215,7 +215,7 @@ def awb(Cam, cal_cr_list, cal_cb_list, plot):
find bad index
note that in python false = 0 and true = 1
"""
- bad = i - (error_1<error_2)
+ bad = i - (error_1 < error_2)
Cam.log += '\nPoint at {} K deleted as '.format(c_fit[bad])
Cam.log += 'it is furthest from fit'
"""
diff --git a/utils/raspberrypi/ctt/ctt_ccm.py b/utils/raspberrypi/ctt/ctt_ccm.py
index 769603b9..52fd9744 100644
--- a/utils/raspberrypi/ctt/ctt_ccm.py
+++ b/utils/raspberrypi/ctt/ctt_ccm.py
@@ -74,8 +74,8 @@ def ccm(Cam, cal_cr_list, cal_cb_list):
"""
normalise tables so min value is 1
"""
- cr_tab= cr_tab/np.min(cr_tab)
- cb_tab= cb_tab/np.min(cb_tab)
+ cr_tab = cr_tab/np.min(cr_tab)
+ cb_tab = cb_tab/np.min(cb_tab)
colour_cals[cr['ct']] = [cr_tab, cb_tab]
"""
@@ -135,8 +135,8 @@ def ccm(Cam, cal_cr_list, cal_cb_list):
"""
for k, v in ccm_tab.items():
tab = np.mean(v, axis=0)
- tab = np.where((10000*tab)%1<=0.05, tab+0.00001, tab)
- tab = np.where((10000*tab)%1>=0.95, tab-0.00001, tab)
+ tab = np.where((10000*tab)%1 <= 0.05, tab+0.00001, tab)
+ tab = np.where((10000*tab)%1 >= 0.95, tab-0.00001, tab)
ccm_tab[k] = list(np.round(tab, 5))
Cam.log += '\nMatrix calculated for colour temperature of {} K'.format(k)
diff --git a/utils/raspberrypi/ctt/ctt_macbeth_locator.py b/utils/raspberrypi/ctt/ctt_macbeth_locator.py
index 63dbc4a1..c3016f9a 100644
--- a/utils/raspberrypi/ctt/ctt_macbeth_locator.py
+++ b/utils/raspberrypi/ctt/ctt_macbeth_locator.py
@@ -40,7 +40,7 @@ def find_macbeth(Cam, img, mac_config=(0, 0)):
Reference macbeth chart is created that will be correlated with the located
macbeth chart guess to produce a confidence value for the match.
"""
- ref = cv2.imread(Cam.path +'ctt_ref.pgm', flags=cv2.IMREAD_GRAYSCALE)
+ ref = cv2.imread(Cam.path + 'ctt_ref.pgm', flags=cv2.IMREAD_GRAYSCALE)
ref_w = 120
ref_h = 80
rc1 = (0, 0)
@@ -328,7 +328,7 @@ def get_macbeth_chart(img, ref_data):
"""
src = img
src, factor = reshape(src, 200)
- original=src.copy()
+ original = src.copy()
a = 125/np.average(src)
src_norm = cv2.convertScaleAbs(src, alpha=a, beta=0)
"""
@@ -349,7 +349,7 @@ def get_macbeth_chart(img, ref_data):
"""
obtain image edges
"""
- sigma=2
+ sigma = 2
src_bw = cv2.GaussianBlur(src_bw, (0, 0), sigma)
t1, t2 = 50, 100
edges = cv2.Canny(src_bw, t1, t2)
@@ -490,7 +490,7 @@ def get_macbeth_chart(img, ref_data):
)
mac_mids_list = [x[0] for x in mac_mids]
- if len(mac_mids_list)==1:
+ if len(mac_mids_list) == 1:
"""
special case of only one valid centre found (probably not needed)
"""
@@ -508,7 +508,7 @@ def get_macbeth_chart(img, ref_data):
create list of all clusters
"""
clus_list = []
- if clustering.n_clusters_ >1:
+ if clustering.n_clusters_ > 1:
for i in range(clustering.labels_.max()+1):
indices = [j for j, x in enumerate(clustering.labels_) if x == i]
clus = []
@@ -535,7 +535,7 @@ def get_macbeth_chart(img, ref_data):
keep only clusters with enough votes
"""
clus_len_max = clus_list[0][1]
- clus_tol= 0.7
+ clus_tol = 0.7
for i in range(len(clus_list)):
if clus_list[i][1] < clus_len_max * clus_tol:
clus_list = clus_list[:i]
diff --git a/utils/raspberrypi/ctt/ctt_ransac.py b/utils/raspberrypi/ctt/ctt_ransac.py
index a1f5e8c9..39227544 100644
--- a/utils/raspberrypi/ctt/ctt_ransac.py
+++ b/utils/raspberrypi/ctt/ctt_ransac.py
@@ -42,8 +42,8 @@ def get_square_verts(c_err=0.05, scale=scale):
for i in range(6):
shift_i = np.array(((i*side, 0), (i*side, 0),
(i*side, 0), (i*side, 0)), np.float32)
- shift_bord =np.array(((i*s_bord, 0), (i*s_bord, 0),
- (i*s_bord, 0), (i*s_bord, 0)), np.float32)
+ shift_bord = np.array(((i*s_bord, 0), (i*s_bord, 0),
+ (i*s_bord, 0), (i*s_bord, 0)), np.float32)
square_i = square_0 + shift_i + shift_bord
for j in range(4):
shift_j = np.array(((0, j*side), (0, j*side),