@@ -338,73 +338,6 @@ def compute_angle(ang_name, person_X_flipped, person_Y, angle_dict, keypoints_id
338338 return ang
339339
340340
341- def min_with_single_indices (L , T ):
342- '''
343- Let L be a list (size s) with T associated tuple indices (size s).
344- Select the smallest values of L, considering that
345- the next smallest value cannot have the same numbers
346- in the associated tuple as any of the previous ones.
347-
348- Example:
349- L = [ 20, 27, 51, 33, 43, 23, 37, 24, 4, 68, 84, 3 ]
350- T = list(it.product(range(2),range(3)))
351- = [(0,0),(0,1),(0,2),(0,3),(1,0),(1,1),(1,2),(1,3),(2,0),(2,1),(2,2),(2,3)]
352-
353- - 1st smallest value: 3 with tuple (2,3), index 11
354- - 2nd smallest value when excluding indices (2,.) and (.,3), i.e. [(0,0),(0,1),(0,2),X,(1,0),(1,1),(1,2),X,X,X,X,X]:
355- 20 with tuple (0,0), index 0
356- - 3rd smallest value when excluding [X,X,X,X,X,(1,1),(1,2),X,X,X,X,X]:
357- 23 with tuple (1,1), index 5
358-
359- INPUTS:
360- - L: list (size s)
361- - T: T associated tuple indices (size s)
362-
363- OUTPUTS:
364- - minL: list of smallest values of L, considering constraints on tuple indices
365- - argminL: list of indices of smallest values of L (indices of best combinations)
366- - T_minL: list of tuples associated with smallest values of L
367- '''
368-
369- minL = [np .nanmin (L )]
370- argminL = [np .nanargmin (L )]
371- T_minL = [T [argminL [0 ]]]
372-
373- mask_tokeep = np .array ([True for t in T ])
374- i = 0
375- while mask_tokeep .any ()== True :
376- mask_tokeep = mask_tokeep & np .array ([t [0 ]!= T_minL [i ][0 ] and t [1 ]!= T_minL [i ][1 ] for t in T ])
377- if mask_tokeep .any ()== True :
378- indicesL_tokeep = np .where (mask_tokeep )[0 ]
379- minL += [np .nanmin (np .array (L )[indicesL_tokeep ]) if not np .isnan (np .array (L )[indicesL_tokeep ]).all () else np .nan ]
380- argminL += [indicesL_tokeep [np .nanargmin (np .array (L )[indicesL_tokeep ])] if not np .isnan (minL [- 1 ]) else indicesL_tokeep [0 ]]
381- T_minL += (T [argminL [i + 1 ]],)
382- i += 1
383-
384- return np .array (minL ), np .array (argminL ), np .array (T_minL )
385-
386-
387- def pad_shape (arr , target_len , fill_value = np .nan ):
388- '''
389- Pads an array to the target length with specified fill values
390-
391- INPUTS:
392- - arr: Input array to be padded.
393- - target_len: The target length of the first dimension after padding.
394- - fill_value: The value to use for padding (default: np.nan).
395-
396- OUTPUTS:
397- - Padded array with shape (target_len, ...) matching the input dimensions.
398- '''
399-
400- if len (arr ) < target_len :
401- pad_shape = (target_len - len (arr ),) + arr .shape [1 :]
402- padding = np .full (pad_shape , fill_value )
403- return np .concatenate ((arr , padding ))
404-
405- return arr
406-
407-
408341def draw_dotted_line (img , start , direction , length , color = (0 , 255 , 0 ), gap = 7 , dot_length = 3 , thickness = thickness ):
409342 '''
410343 Draw a dotted line with on a cv2 image
0 commit comments