2424"""
2525
2626import pytest
27- import os , glob
28- import math
27+
2928import micasense .image as image
3029import micasense .panel as panel
3130
31+
3232def test_qr_corners (panel_image_name ):
3333 img = image .Image (panel_image_name )
3434 pan = panel .Panel (img )
@@ -42,6 +42,7 @@ def test_qr_corners(panel_image_name):
4242 assert pt [0 ] == pytest .approx (good_qr_corners [i ][0 ], abs = 3 )
4343 assert pt [1 ] == pytest .approx (good_qr_corners [i ][1 ], abs = 3 )
4444
45+
4546def test_panel_corners (panel_image_name ):
4647 img = image .Image (panel_image_name )
4748 pan = panel .Panel (img )
@@ -55,26 +56,29 @@ def test_panel_corners(panel_image_name):
5556 assert pt [0 ] == pytest .approx (good_pts [i ][0 ], abs = 3 )
5657 assert pt [1 ] == pytest .approx (good_pts [i ][1 ], abs = 3 )
5758
59+
5860# test manually providing bad corners - in this case the corners of the qr code itself
5961def test_raw_panel_bad_corners (panel_image_name ):
6062 img = image .Image (panel_image_name )
61- pan = panel .Panel (img ,panelCorners = [[460 , 599 ], [583 , 599 ], [584 , 478 ], [462 , 477 ]])
63+ pan = panel .Panel (img , panelCorners = [[460 , 599 ], [583 , 599 ], [584 , 478 ], [462 , 477 ]])
6264 mean , std , num , sat = pan .raw ()
6365 assert mean == pytest .approx (26965 , rel = 0.01 )
6466 assert std == pytest .approx (15396.0 , rel = 0.05 )
6567 assert num == pytest .approx (14824 , rel = 0.01 )
6668 assert sat == pytest .approx (0 , abs = 2 )
6769
70+
6871# test manually providing good corners
6972def test_raw_panel_manual (panel_image_name ):
7073 img = image .Image (panel_image_name )
71- pan = panel .Panel (img ,panelCorners = [[809 , 613 ], [648 , 615 ], [646 , 454 ], [808 , 452 ]])
74+ pan = panel .Panel (img , panelCorners = [[809 , 613 ], [648 , 615 ], [646 , 454 ], [808 , 452 ]])
7275 mean , std , num , sat = pan .raw ()
7376 assert mean == pytest .approx (45406 , rel = 0.01 )
7477 assert std == pytest .approx (738.0 , rel = 0.05 )
7578 assert num == pytest .approx (26005 , rel = 0.001 )
7679 assert sat == pytest .approx (0 , abs = 2 )
7780
81+
7882def test_raw_panel (panel_image_name ):
7983 img = image .Image (panel_image_name )
8084 pan = panel .Panel (img )
@@ -84,6 +88,7 @@ def test_raw_panel(panel_image_name):
8488 assert num == pytest .approx (26005 , rel = 0.02 )
8589 assert sat == pytest .approx (0 , abs = 2 )
8690
91+
8792def test_intensity_panel (panel_image_name ):
8893 img = image .Image (panel_image_name )
8994 pan = panel .Panel (img )
@@ -93,6 +98,7 @@ def test_intensity_panel(panel_image_name):
9398 assert num == pytest .approx (26005 , rel = 0.02 )
9499 assert sat == pytest .approx (0 , abs = 2 )
95100
101+
96102def test_radiance_panel (panel_image_name ):
97103 img = image .Image (panel_image_name )
98104 pan = panel .Panel (img )
@@ -102,23 +108,27 @@ def test_radiance_panel(panel_image_name):
102108 assert num == pytest .approx (26005 , rel = 0.02 )
103109 assert sat == pytest .approx (0 , abs = 2 )
104110
111+
105112def test_irradiance_mean (panel_image_name ):
106113 img = image .Image (panel_image_name )
107114 pan = panel .Panel (img )
108115 panel_reflectance = 0.67
109116 mean = pan .irradiance_mean (panel_reflectance )
110117 assert mean == pytest .approx (0.7984 , rel = 0.001 )
111-
118+
119+
112120def test_panel_detected (panel_image_name ):
113121 img = image .Image (panel_image_name )
114122 pan = panel .Panel (img )
115123 assert pan .panel_detected () == True
116124
125+
117126def test_panel_not_detected (flight_image_name ):
118127 img = image .Image (flight_image_name )
119128 pan = panel .Panel (img )
120129 assert pan .panel_detected () == False
121130
131+
122132def test_altum_panel (altum_panel_image_name ):
123133 img = image .Image (altum_panel_image_name )
124134 assert img .auto_calibration_image == True
@@ -135,8 +145,27 @@ def test_altum_panel(altum_panel_image_name):
135145 assert pt [1 ] == pytest .approx (good_pts [i ][1 ], abs = 3 )
136146 assert pan .qr_corners () == None
137147
148+
138149def test_altum_lwir (altum_lwir_image_name ):
139150 img = image .Image (altum_lwir_image_name )
140151 assert img .auto_calibration_image == False
141152 pan = panel .Panel (img )
142- assert pan .panel_detected () == False
153+ assert pan .panel_detected () == False
154+
155+
156+ def test_ordered_coordinates (panel_image_name ):
157+ img = image .Image (panel_image_name )
158+ if img .panel_region is not None :
159+ ordered_corners = img .panel_region
160+ else :
161+ ordered_corners = [(809 , 613 ), (648 , 615 ), (646 , 454 ), (808 , 452 )]
162+ pan = panel .Panel (img , panelCorners = ordered_corners )
163+ assert pan .ordered_panel_coordinates () == ordered_corners
164+
165+
166+ def test_unordered_coordinates (panel_image_name ):
167+ img = image .Image (panel_image_name )
168+ ordered_corners = [(809 , 613 ), (648 , 615 ), (646 , 454 ), (808 , 452 )]
169+ unordered_corners = [(648 , 615 ), (809 , 613 ), (808 , 452 ), (646 , 454 )]
170+ pan = panel .Panel (img , panelCorners = unordered_corners )
171+ assert pan .ordered_panel_coordinates () == ordered_corners
0 commit comments