Answer the question
In order to leave comments, you need to log in
How to keep the crop from going beyond the image?
Hello everyone, there are x, y, h, w, with them I can crop images, they are always within the image, but I need to add 20% to each side, but sometimes this 20% is outside the image, and I get an error, how to do cropping so that it crops, but does not go beyond?
x, y, w, h = cv2.boundingRect(cnt)
portrait_image = image[y:y+h, x:x+w]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question