pull/26948/head
ZwX1616 2 years ago
parent d7acbd3313
commit a57924be36
  1. 12
      system/camerad/test/test_exposure.py

@ -18,9 +18,9 @@ class TestCamerad(unittest.TestCase):
ret = np.clip(im[:,:,2] * 0.114 + im[:,:,1] * 0.587 + im[:,:,0] * 0.299, 0, 255).astype(np.uint8)
return ret
def _is_exposure_okay(self, i, med_mean=np.array([[0.2,0.4],[0.2,0.6]])):
h, w = i.shape[:2]
i = i[h//10:9*h//10,w//10:9*w//10]
def _is_exposure_okay(self, i, roi=None, med_mean=np.array([[0.2,0.4],[0.2,0.6]])):
xmin, xmax, ymin, ymax = roi
i = i[ymin:ymax,xmin:xmax]
med_ex, mean_ex = med_mean
i = self._numpy_rgb2gray(i)
i_median = np.median(i) / 255.
@ -36,9 +36,9 @@ class TestCamerad(unittest.TestCase):
rpic, dpic = get_snapshots(frame="roadCameraState", front_frame="driverCameraState")
wpic, _ = get_snapshots(frame="wideRoadCameraState")
res = self._is_exposure_okay(rpic)
res = res and self._is_exposure_okay(dpic)
res = res and self._is_exposure_okay(wpic)
res = self._is_exposure_okay(rpic, roi=[96, 1832, 604, 1112])
res = res and self._is_exposure_okay(dpic, roi=[642, 1284, 96, 604])
res = res and self._is_exposure_okay(wpic, roi=[642, 1284, 604, 1112])
if passed > 0 and not res:
passed = -passed # fails test if any failure after first sus

Loading…
Cancel
Save