0

i have a haar detection and it produces me some nearby detections:

[[ 31  85 232 116]
 [141  55  66  33]
 [112  41 104  52]]

each list have the following values: x,y,w,h id like to get the most left top X,Y and the most right bottom x,y of all detections.

i tryed to use min() and max() but ot produces a error. and after that i tryed to use Numpy and i canot make what i need

import numpy as np
l = [10, 22, 8, 8, 11]
print(np.argmax(l))
print(np.argmin(l))

in my problen the list should be the list of lists and i want to get only lesser x,y and higer x,y

1 Answer 1

1
x = [ [ 31,85,232,116],
 [141,55,66,33],
 [112,41,104,52]
]

You can use a custom key with the values of first 2 elements to get max and min value. Since you need to draw a bounding box around all boundingboxes, you need to find min of x,y pair and max of x+w,y+h pair

This assumes x,y values are always positive which is fine in a image scenario.

min(x,key=lambda x:(x[0],x[1]))[:2]
max([(e[0]+e[2],e[1]+e[3]) for e in x ])

Out:

[31, 85]
(263, 201)
Sign up to request clarification or add additional context in comments.

5 Comments

i need the following output: (x1: 31,y1:41, x2:141, y2:85)
So it's like min of 1st value, min of 2nd value and max of 1st ,max of 2nd ?
i need to draw a bounding box arround all boundingboxes returned in my detection
then shouldn't the answer be 31,85 and (263, 201)? the lowest x y and the highest x+w,y+h
Updated my answer let me know if that is what you are looking for

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.