11import sys
22from typing import List , Union
33
4+
45from je_auto_control .utils .exception .exception_tag import cant_find_image
56from je_auto_control .utils .exception .exception_tag import find_image_error_variable
67from je_auto_control .utils .exception .exceptions import ImageNotFoundException
@@ -24,12 +25,12 @@ def locate_all_image(image, detect_threshold: [float, int] = 1,
2425 try :
2526 image_data_array = template_detection .find_image_multi (image , detect_threshold , draw_image )
2627 except ImageNotFoundException as error :
27- raise ImageNotFoundException (find_image_error_variable + " " + repr (error ))
28+ raise ImageNotFoundException (find_image_error_variable + " " + repr (error ) + " " + str ( image ) )
2829 if image_data_array [0 ] is True :
2930 record_action_to_list ("locate_all_image" , param )
3031 return image_data_array [1 ]
3132 else :
32- raise ImageNotFoundException (cant_find_image )
33+ raise ImageNotFoundException (cant_find_image + " / " + repr ( image ) )
3334 except Exception as error :
3435 record_action_to_list ("locate_all_image" , param , repr (error ))
3536 print (repr (error ), file = sys .stderr )
@@ -47,15 +48,15 @@ def locate_image_center(image, detect_threshold: [float, int] = 1, draw_image: b
4748 try :
4849 image_data_array = template_detection .find_image (image , detect_threshold , draw_image )
4950 except ImageNotFoundException as error :
50- raise ImageNotFoundException (find_image_error_variable + " " + repr (error ))
51+ raise ImageNotFoundException (find_image_error_variable + " " + repr (error ) + " " + str ( image ) )
5152 if image_data_array [0 ] is True :
5253 height = image_data_array [1 ][2 ] - image_data_array [1 ][0 ]
5354 width = image_data_array [1 ][3 ] - image_data_array [1 ][1 ]
5455 center = [int (height / 2 ), int (width / 2 )]
5556 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 ]) ]
5758 else :
58- raise ImageNotFoundException (cant_find_image )
59+ raise ImageNotFoundException (cant_find_image + " / " + repr ( image ) )
5960 except Exception as error :
6061 record_action_to_list ("locate_image_center" , param , repr (error ))
6162 print (repr (error ), file = sys .stderr )
@@ -87,9 +88,9 @@ def locate_and_click(
8788 set_position (int (image_center_x ), int (image_center_y ))
8889 click_mouse (mouse_keycode )
8990 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 ) ]
9192 else :
92- raise ImageNotFoundException (cant_find_image )
93+ raise ImageNotFoundException (cant_find_image + " / " + repr ( image ) )
9394 except Exception as error :
9495 record_action_to_list ("locate_and_click" , param , repr (error ))
9596 print (repr (error ), file = sys .stderr )
0 commit comments