-
Hello! How can I crop an image using a polygon shape? Needed in order to detect an object only in a specific area in the image. Example code: eg, I think here to crop the image https://github.com/akuzyagin/video-detection-example/blob/2a92fe0a17c8c499f348fb1db8ace465c4d1e3b2/src/main/java/DetectionService.java#L45C1-L47C72:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
An image must be a rectangle, what you can do is the cut the image to closet rectangle. |
Beta Was this translation helpful? Give feedback.
-
I found the answer to my question, the following code allows you to cut out a polygon from an image:
Full code: https://github.com/akuzyagin/video-detection-example/ |
Beta Was this translation helpful? Give feedback.
-
This not really crop the image, it just mask the image. The whole image is still rectangle. There are multiple ways to mask the image: see: https://pub.towardsai.net/how-to-identify-objects-at-pixel-level-using-deep-learning-in-java-907dc482835e |
Beta Was this translation helpful? Give feedback.
I found the answer to my question, the following code allows you to cut out a polygon from an image: