Extremal Region(极值区域)文本定位与识别法-代码分析(一)

本文介绍了Jiri Matas的实时场景文本定位和识别方法,该方法已被纳入OpenCV 3.0的contrib模块。通过分析ERFilter源码,探讨ERStat结构体、CV_EXPORTS、Algorithm接口规范以及ERClassifier和ERFilter类。文章提供了一个使用VC2012的Demo工程,并详细解释了computeNMChannels函数生成的通道选择,包括HIS、HSV、HLS等颜色空间的讨论。
摘要由CSDN通过智能技术生成

很惊喜地发现Jiri Matas的方法:Real-Time Scene TextLocalization and Recognition CVPR 2012 在OpenCV 3.0 的contrib中有实现,也许未来就会出现在OpenCV的正式版本中,太赞了,照源代码学习之!(四千多行代码,也是醉了~)

ERFilter源码地址:https://github.com/Itseez/opencv_contrib/tree/master/modules/text

  我用VC2012创建的可以直接运行的Demo工程,CSDN下载:http://download.csdn.net/detail/liveintoday/8447045 (要用OpenCV 3.0,不过稍加修改2.4也能运行)

1.structCV_EXPORTSERStat      代码中用一个ERStat结构体来代表一个分类的极值区域

struct CV_EXPORTS ERStat
{
public:
    //! Constructor
	//explicit构造函数必须显式调用,将构造函数声明为explicit(显式)的方式可以抑制隐式转换。隐式转换常常带来程序逻辑的错误,而且这种错误一旦发生是很难察觉的。
    explicit ERStat(int level = 256, int pixel = 0, int x = 0, int y = 0);
    //! Destructor
    ~ERStat() { }

    //! seed point and the threshold (max grey-level value)
    int pixel;
    int level;

	// 这些特征的详细描述参加我学习笔记(三)中的图解
    //! incrementally computable features
    int area;
    int perimeter;
    int euler;                 //!< euler number
    Rect rect;
    double raw_moments[2];     //!< order 1 raw moments to derive the centroid
    double central_moments[3]; //!< order 2 central moments to construct the covariance matrix
    std::deque<int> *crossings;//!< horizontal crossings
    float med_crossings;       //!< median of the crossings at three different height levels

    //! 2nd stage features
    float hole_area_ratio;
    float convex_hull_ratio;
    float num_inflexion_points;

    // TODO Other features can be added (average color, standard deviation, and such)


    // TODO shall we include the pixel list whenever available (i.e. after 2nd stage) ?
    std::vector<int> *pixels;

    //! probability that the ER belongs to the class we are looking for
    double probability;
	//程序中用一个广搜删除ERStat区域树
	//static void deleteERStatTree(ERStat* root) {
	//	queue<ERStat*> to_delete;
	//	to_delete.push(root);
	//	while (!to_delete.empty()) {
	//		ERStat* n = to_delete.front();
	//		to_delete.pop();
	//		ERStat* c = n->child;
	//		if (c != NULL) {
	//			to_delete.push(c);
  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 18
    评论
评论 18
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值