@@ -47,7 +47,7 @@ def __init__(self, threshold: float
4747
4848 :param str interaction_type: Type of interaction ('proximity' or 'distance'). Proximity is checking for distances lower than threshold,
4949 while distance is checking for distances higher than threshold. Default: 'proximity'
50- :param debug: Not used in this trigger
50+ :param debug: will add another reporting to reponse that is shown in the stream
5151 """
5252
5353 self ._threshold = threshold
@@ -74,15 +74,19 @@ def check_skeleton(self, skeletons: dict):
7474 active_coords = skeletons [self ._active_animal ][active_bp ]
7575 for passive_bp in self ._identification_dict ['passive' ]['bp' ]:
7676 passive_coords = skeletons [self ._passive_animal ][passive_bp ]
77- #calculate distance for all combinations
78- distance = calculate_distance (active_coords , passive_coords )
7977 temp_result = False
80- if distance >= self ._threshold and self ._interaction_type == 'distance' :
81- temp_result = True
82- elif distance < self ._threshold and self ._interaction_type == 'proximity' :
83- temp_result = True
78+ #calculate distance for all combinations if none of the coordinates are NaN
79+ if not any (np .isnan ([* active_coords , * passive_coords ])):
80+ distance = calculate_distance (active_coords , passive_coords )
81+ if distance >= self ._threshold and self ._interaction_type == 'distance' :
82+ temp_result = True
83+ elif distance < self ._threshold and self ._interaction_type == 'proximity' :
84+ temp_result = True
85+ else :
86+ pass
8487 else :
8588 pass
89+
8690 results .append (temp_result )
8791
8892 result = any (results )
@@ -92,15 +96,22 @@ def check_skeleton(self, skeletons: dict):
9296 if self ._debug :
9397 active_point_x , active_point_y = skeletons [self ._active_animal ][self ._active_bp [0 ]]
9498 passive_point_x , passive_point_y = skeletons [self ._passive_animal ][self ._passive_bp [0 ]]
99+ if not any (np .isnan ([active_point_x , active_point_y ,passive_point_x , passive_point_y ])):
100+ response_body = {'plot' : {'text' : dict (text = f'{ self ._interaction_type } : { result } ' ,
101+ org = (20 , 20 ),
102+ color = color ),
103+ 'line' : dict (pt1 = (int (active_point_x ), int (active_point_y )),
104+ pt2 = (int (passive_point_x ), int (passive_point_y )),
105+ color = color ),
106+ }
107+ }
108+ else :
109+ response_body = {'plot' : {'text' : dict (text = f'{ self ._interaction_type } : { result } ' ,
110+ org = (20 ,20 ),
111+ color = color )
112+ }
113+ }
95114
96- response_body = {'plot' : {'text' : dict (text = f'{ self ._interaction_type } : { result } ' ,
97- org = (20 , 20 ),
98- color = color ),
99- 'line' : dict (pt1 = (int (active_point_x ), int (active_point_y )),
100- pt2 = (int (passive_point_x ), int (passive_point_y )),
101- color = color ),
102- }
103- }
104115 else :
105116 response_body = {'plot' : {'text' : dict (text = f'{ self ._interaction_type } : { result } ' ,
106117 org = (20 , 20 ),
0 commit comments