0

I have a below python code which detect person in frame. Once detected, it get the bounding box of the person which is person_box. From person_box I can get the startX, startY and width height of the bounding box. But in below code, in for loop, I am getting error as numpy.int32 object is not iterable

person_box = person_detections[0, 0, i, 3:7] * np.array([W, H, W, H])
person_box = person_box.astype(int)
print(person_box)
(startX, startY, endX, endY) = person_box.astype("int")
width = endX - startX
height = endY - startY

for (startX, startY, width, height) in person_box:
    person_box = np.array([startX, startY, startX + width, startY + height])

output

[159 156 451 431]

I am not able to understand the error much as I am not much experienced with numpy arrays. Please help. Thanks.

1
  • Show a traceback Commented Nov 12, 2019 at 13:22

1 Answer 1

1

for loop will iterate person_box and pass parameter by parameter. You are trying to split the parameter and assign to startX, startY, width, height in for (startX, startY, width, height) in person_box: you can just try:

person_box = np.array([person_box [0], person_box[1] , person_box[0] + person_box[2] , person_box[1] + person_box[3] ])

or

startX = person_box[0]
startY = person_box[1]
width = person_box[2]
height = person_box[3]
person_box = np.array([startX, startY, startX + width, startY + height])
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.