简体   繁体   English

OpenCV Python:从图像中检索矩形主区域然后裁剪图像

[英]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.我想在 Python 中使用 OpenCV 来完成任务。 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?提取主区域并保存仅主区域的png文件需要哪些步骤?

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.如果感兴趣的区域总是包含在一个有点对比的准矩形框架内,您可以试试 Hough 变换的运气,保留长的水平和垂直边缘(单独获得)并尝试重建该框架。

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...首先,处理少量卡片并观察 Hough 的结果,并找出可以使用哪些系统规则通过长度/位置/对齐/嵌入更大的框架来选择正确的段......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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