Welcome new user! You can search existing questions and answers without registering, but please register to post new questions and receive answers.
Welcome to JeVois Tech Zone, where you can ask questions and receive answers from other members of the community.

Tuple has no attribute

0 votes
I'm running python code on the Jevois to identify rectangular areas and pass them over USB to a raspberry pi. All the open CV code seems to work fine and I obtain my RotatedRect using minAreaRect. I encounter a problem when I try to access attributes of the rectangle. For example, if I try to access rect.center.x, I'm told that the 'tuple' has no attribute 'center'. If I try to dump the RotatedRect structure using json.dump, all of the data is there, but there are no tuple names.

I'm a python newbie, so hopefully this is something dumb I'm doing and easy to fix.

Any and all assistance is appreciated.
asked Feb 15, 2019 in Programmer Questions by kinahawi (220 points)

1 Answer

+1 vote
 
Best answer

How about this hit from googling "python minAreaRect":

https://www.programcreek.com/python/example/89463/cv2.minAreaRect

example 4 tells you:

  # help(cv2.minAreaRect)
  (x, y), (width, height), rect_angle = rectangle
so you could try that code. Or, if you just want to extract the fields from your rectangle, I guess rect[0] is (x, y) and rect[0][0] is x
and rect[1] is (width, height) and rect[1][0] is width
and so on, the other examples should help you.
answered Feb 20, 2019 by JeVois (45,800 points)
selected Feb 20, 2019 by kinahawi
...