2

I have created a class in python as below

class Member:
    def __init__(self, kalmanBoxTracker):
        self.member_id = kalmanBoxTracker.id
        self.member_area = kalmanBoxTracker.kf.x[2]

Then I have created an array of this object like this:

for trk in trackers:
   ret_mem.append(Member(trk))

How I can get the member_area attribute of ret_mem array as an array?

1
  • Try list comprehension. Commented Apr 16, 2020 at 8:32

1 Answer 1

2

Try this:

member_areas = [m.member_area for m in ret_mem]
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your reply. The output of above line is a list, but I need a numpy array. I could convert the output list of this command to a numpy array by numpy.asarray(member_areas)
Happy to help :)

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.