Issue using cv.puttext() with width and height of cv.minAreaRect()

Hi
im quite new to Python and learned all by myself so far. Thats why i dont have much knowledge about data types yet

I wrote a code that finds contours in a picture and draws a minAreaRect() around them. Important for me is the width and height of these rectangles which are return values of minAreaRect(). I am able to print width and height in terminal but i cant manage to use them in puttext function to display them in image. I think the values width and heigth have a “false” data type, but im too new to fully understand the documentation of functions.

My current loop code:

Error:
Traceback (most recent call last):
File “d:\content_Main”, line 77, in
print(‘Funktion contour_areas vor sortieren:’, contour_areas(contours))
File “d:\content_Main”, line 74, in contour_areas
cv.putText(imgcontours_min_area, “w={},h={}”.format(w, h), (x,y - 10), cv.FONT_HERSHEY_SIMPLEX, 0.7, (0,0,255), 2)
cv2.error: OpenCV(4.5.5) :-1: error: (-5:Bad argument) in function ‘putText’

Overload resolution failed:

  • Can’t parse ‘org’. Sequence item with index 0 has a wrong type
  • Can’t parse ‘org’. Sequence item with index 0 has a wrong type

please, no screenshots of code or errors here. remove & replace with TEXT, thank you

OK, sorry!!

Is there a guide how to create embedded text for code? The text i embedded was NOT extra.

Nevertheless i just found my own fault, it’s not the data types of width and height that were wrong but the ones of x and y so i changed these to integer and now it works! Thanks!

2 Likes

I also want to know how to create embedded text for code. I am just a beginner.

In this forum u can use the “preformatted text” function!

Seems to be “```” before and after the code

or mark the text, and press ctrl+e