I read following threads
https://github.com/opencv/opencv/issues/15465
https://github.com/opencv/opencv/issues/16432
It appears that startX
, startY
, endX
, endY
must be integers. In my case they were fractions bewteen 0
and 1
. I multiplied startX
, endX
with image width and startY
, endY
with image height and converted them to int.
(startX, startY, endX, endY) = rect
startX = int(startX * W)
startY = int(startY * H)
endX = int(endX * W)
endY = int(endY * H)
cv2.rectangle(frame, (startX, startY), (endX, endY), (155, 255, 0), 2)
This solved the issue for me.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…