Hi, I’m seeing a strange behavior with 4.4.0.46 and 4.5.3.56 (maybe others)
As a new user I can add only one image, so please run the example to see the output.
Here is the code:
import cv2
import numpy as np
base_image = cv2.imread("so_sample.png", 0)
thresh = cv2.threshold(base_image, 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1]
coords = np.column_stack(np.where(thresh > 0))
rect = cv2.minAreaRect(coords)
print("RECT", rect)
box = np.int0(cv2.boxPoints(rect))
drawImg = cv2.cvtColor(thresh, cv2.COLOR_GRAY2BGR)
drawImg = cv2.copyMakeBorder(drawImg, 0, 100, 0, 100, cv2.BORDER_REPLICATE) # only to see the whole box
cv2.drawContours(drawImg, [box], 0,(0,0,255), 2)
cv2.imshow("base_image", base_image)
cv2.imshow("thresh", thresh)
cv2.imshow("drawImg", drawImg)
cv2.waitKey(0)
Input image:
This code works fine with the thunder sample.
What am I missing?
Thanks