简体   繁体   中英

OpenCV Python: retrieve rectangle main area from image then crop image

I'm trying to isolate the main area art from Pokemon cards and crop them. For example,

口袋妖怪卡

I want to extract the main area, as seen in the bounding box below.

突出显示主要区域的卡片

I want to use the OpenCV in Python for the task. I've tried out shape detection and corner detection, but I can't seem to make them work as intended, and they seem to pick up anything but the main area that I want to extract.

I can't hard-code the bounding box because I want to process many cards and the position of the main area is different per card.

What are the steps needed to extract the main area and save a png file of just the main area?

If the area of interest is always contained inside a somewhat contrasted quasi-rectangular frame you can try your luck with a Hough transform, keep the long horizontal and vertical edges (obtained separately) and try to reconstitute that frame.

To begin, process a small number of cards and observe the results of Hough and figure out which systematic rules you could use to select the right segments by length/position/alignment/embedding in a larger frame...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM