1
1
import sys
2
2
from typing import List , Union
3
3
4
+
4
5
from je_auto_control .utils .exception .exception_tag import cant_find_image
5
6
from je_auto_control .utils .exception .exception_tag import find_image_error_variable
6
7
from je_auto_control .utils .exception .exceptions import ImageNotFoundException
@@ -24,12 +25,12 @@ def locate_all_image(image, detect_threshold: [float, int] = 1,
24
25
try :
25
26
image_data_array = template_detection .find_image_multi (image , detect_threshold , draw_image )
26
27
except ImageNotFoundException as error :
27
- raise ImageNotFoundException (find_image_error_variable + " " + repr (error ))
28
+ raise ImageNotFoundException (find_image_error_variable + " " + repr (error ) + " " + str ( image ) )
28
29
if image_data_array [0 ] is True :
29
30
record_action_to_list ("locate_all_image" , param )
30
31
return image_data_array [1 ]
31
32
else :
32
- raise ImageNotFoundException (cant_find_image )
33
+ raise ImageNotFoundException (cant_find_image + " / " + repr ( image ) )
33
34
except Exception as error :
34
35
record_action_to_list ("locate_all_image" , param , repr (error ))
35
36
print (repr (error ), file = sys .stderr )
@@ -47,15 +48,15 @@ def locate_image_center(image, detect_threshold: [float, int] = 1, draw_image: b
47
48
try :
48
49
image_data_array = template_detection .find_image (image , detect_threshold , draw_image )
49
50
except ImageNotFoundException as error :
50
- raise ImageNotFoundException (find_image_error_variable + " " + repr (error ))
51
+ raise ImageNotFoundException (find_image_error_variable + " " + repr (error ) + " " + str ( image ) )
51
52
if image_data_array [0 ] is True :
52
53
height = image_data_array [1 ][2 ] - image_data_array [1 ][0 ]
53
54
width = image_data_array [1 ][3 ] - image_data_array [1 ][1 ]
54
55
center = [int (height / 2 ), int (width / 2 )]
55
56
record_action_to_list ("locate_image_center" , param )
56
- return [image_data_array [1 ][0 ] + center [0 ], image_data_array [1 ][1 ] + center [1 ]]
57
+ return [int ( image_data_array [1 ][0 ] + center [0 ]), int ( image_data_array [1 ][1 ] + center [1 ]) ]
57
58
else :
58
- raise ImageNotFoundException (cant_find_image )
59
+ raise ImageNotFoundException (cant_find_image + " / " + repr ( image ) )
59
60
except Exception as error :
60
61
record_action_to_list ("locate_image_center" , param , repr (error ))
61
62
print (repr (error ), file = sys .stderr )
@@ -87,9 +88,9 @@ def locate_and_click(
87
88
set_position (int (image_center_x ), int (image_center_y ))
88
89
click_mouse (mouse_keycode )
89
90
record_action_to_list ("locate_and_click" , param )
90
- return [image_center_x , image_center_y ]
91
+ return [int ( image_center_x ), int ( image_center_y ) ]
91
92
else :
92
- raise ImageNotFoundException (cant_find_image )
93
+ raise ImageNotFoundException (cant_find_image + " / " + repr ( image ) )
93
94
except Exception as error :
94
95
record_action_to_list ("locate_and_click" , param , repr (error ))
95
96
print (repr (error ), file = sys .stderr )
0 commit comments