I recently began studying image processing and took a task where I need to crop an image from mobile Instagram screenshot via use of OpenCV. I need to find edges of the image with contours and crop, but I'm not sure how to do this correctly.
I've tried to look up some examples like these:
How to crop biggest rectangle out of an image
How to detect edge and crop an image in Python
How to crop rectangular shapes in an image using Python
But I'm still don't understand how to do it in my case.
Basically I have images like these:
https://i.stack.imgur.com/hie3V.jpg and https://i.stack.imgur.com/PksBc.jpg
And the result should be like this:
https://i.stack.imgur.com/fkQhW.jpg
https://i.stack.imgur.com/Nnn21.jpg
Screenshots used need to be only from mobile version of Instagram and it can be assumed that they are always of rectangular shape
And if there are more than one image like here:
https://i.stack.imgur.com/hj1Eh.jpg
Then only one of the two is cropped (which one doesn't matter). For example:
https://i.stack.imgur.com/jZN81.jpg
Thanks!