小编Nat*_*ler的帖子

检测照片中纸张角落的算法

检测照片中发票/收据/纸张角落的最佳方法是什么?在OCR之前,这将用于后续的透视校正.

我目前的做法是:

RGB>灰色>带阈值的Canny边缘检测>扩张(1)>移除小物体(6)>清除边界物体>根据凸面区域挑选大型博客.> [角落检测 - 未实施]

我不禁想到必须有一种更强大的"智能"/统计方法来处理这种类型的细分.我没有很多训练样例,但我可能会得到100张图像.

更广泛的背景:

我正在使用matlab进行原型设计,并计划在OpenCV和Tesserect-OCR中实现该系统.这是我需要为此特定应用程序解决的许多图像处理问题中的第一个.因此,我希望推出自己的解决方案并重新熟悉图像处理算法.

以下是我想要算法处理的一些示例图像:如果您想接受挑战,那么大图像位于http://madteckhead.com/tmp

案例1 http://madteckhead.com/tmp/IMG_0773_sml.jpg 案例2 http://madteckhead.com/tmp/IMG_0774_sml.jpg 案例3 http://madteckhead.com/tmp/IMG_0775_sml.jpg 案例4 http:/ /madteckhead.com/tmp/IMG_0776_sml.jpg

在最好的情况下,这给出:

案例1 - canny http://madteckhead.com/tmp/IMG_0773_canny.jpg 案例1 - post canny http://madteckhead.com/tmp/IMG_0773_postcanny.jpg 案例1 - 最大的博客http://madteckhead.com/tmp/ IMG_0773_blob.jpg

但是在其他情况下很容易失败:

案例2 - canny http://madteckhead.com/tmp/IMG_0774_canny.jpg 案例2 - post canny http://madteckhead.com/tmp/IMG_0774_postcanny.jpg 案例2 - 最大的博客http://madteckhead.com/tmp/ IMG_0774_blob.jpg

提前感谢所有伟大的想法!我喜欢!

编辑:霍夫变换进展

问:什么算法会聚集霍夫线找到角落?根据答案的建议,我能够使用Hough变换,拾取线条并过滤它们.我目前的做法相当粗糙.我已经假设发票总是小于15度,与图像不对齐.如果是这种情况,我最终得到合理的线条结果(见下文).但我不完全确定一个合适的算法来聚集线(或投票)来推断角落.霍夫线不连续.并且在嘈杂的图像中,可以存在平行线,因此需要与线原点度量的某种形式或距离.有任何想法吗?

案例1 http://madteckhead.com/tmp/IMG_0773_hough.jpg 案例2 http://madteckhead.com/tmp/IMG_0774_hough.jpg 案例3 http://madteckhead.com/tmp/IMG_0775_hough.jpg 案例4 http:/ /madteckhead.com/tmp/IMG_0776_hough.jpg

opencv image-processing edge-detection image-segmentation hough-transform

91
推荐指数
5
解决办法
5万
查看次数

Django 按最新相关对象过滤

我已经设置了一个系统来跟踪数据库中各种对象的审核任务。它们通过通用外键关系链接。给定一个 ObjectModerationState 对象,我必须根据最新的 StateTransisition 对象确定其状态。

该解决方案必须能够在 SimpleListFilter 中使用,以便使用 list_filter 对 list_display 进行排序。

例如给定状态 - 排队 - 已完成 - 验证

我应该能够根据 StateTransisition 对象中的最新状态值过滤 ObjectModerationState 对象。

我一直倾向于在 ObjectModerationState 上进行某种注释。

这是我所拥有的不起作用的东西。

模型.py:

class ObjectModerationState(models.Model):
    job = models.ForeignKey(JobDescription)
    object_id = models.TextField(help_text="Primary key of the model under moderation.")
    content_type = models.ForeignKey(ContentType, help_text="Content type of the model under moderation.")
    object = generic.GenericForeignKey()

class StateTransisition(models.Model):
    state = models.ForeignKey(State)
    moderation_details = models.ForeignKey("ObjectModerationState", related_name='states')
    changed_by = models.ForeignKey("auth.User", related_name='+', null=False,
                                   help_text="If you create the task, then usually this will be …
Run Code Online (Sandbox Code Playgroud)

django foreign-keys filter django-admin django-queryset

3
推荐指数
2
解决办法
1941
查看次数