• 大小: 2.4MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-10-28
  • 语言: 其他
  • 标签: Ocr  文字识别  OpenCv  

资源简介

使用Qt + Opencv 实现的文字识别的示例,带有文字库,学习一下没毛病

资源截图

代码片段和文件信息

//#include “stdafx.h“
#include “bwlabel.h“

#define MIN_AREA   4*4//标记函数的参数

#define LABELMODE_1  1
#define LABELMODE_2  2

#if 0
#define MAXSlink     (256*4)   /* 0 --- 255  */
#define MAXlink      (1024*4)  /* 0 --- 1023 */
#define MAXSUBBLOCK  (1023*4)  /* 1 --- 1023 */
#define MAXBLOCK     (255*4)   /* 1 --- 255  */
#define MAXGREYLEVEL (255*4)   /* 0 --- 255  */
#else
#define MAXSlink     (1024)
#define MAXlink      (100000)
#define MAXSUBBLOCK  (8192)  /* 1 --- 1023 */
#define MAXBLOCK     (8192)
#endif

s32 Gray[MAXSlink];
u16 stack[MAXSlink];
u16 TmpArea[MAXBLOCK+1];
u16 TemArray[2000*2000];
u16 mapArr[MAXSUBBLOCK+1];
u16 neighbor[2*MAXlink];


/***********************************************
* 函数:GetNeighborTable
* 功能:
*
***********************************************/
u16 GetNeighborTable(u8 *array
                     s32 RowLen
                     s32 ColLen
                     u16 *neighbor
                     u16 *TemArray
                     s32 *TabLen
                     u16 *area)
{
    s32 StartPos EndPos GrayNoLastLine;
    s32 i j k;
    s32 *pGray;
    u16 GrayNo = 0;

    pGray = Gray;
    memset(pGray 0 MAXSlink*sizeof(s32));
    *TabLen = 0;

    for(i=0; i    {
        for(j=0; j        {
            if(array[i*ColLen+j] != 0)
            {
                StartPos = j;

                do
                {
                    j++;
                    if(j==ColLen)
                    {
                        break;
                    }
                }while(array[i*ColLen+j]!=0);

                EndPos = j-1;
                GrayNoLastLine = 0;

                for(k=StartPos-1; k<=EndPos+1; k++)
                {
                    //  第一行
                    if(i-1<0)
                    {
                        break;
                    }

                    // 第一列或最后一列
                    if((k<0) || (k>=ColLen))
                    {
                        continue;
                    }

                    if(TemArray[(i-1)*ColLen+k]!=0)
                    {
                        if(GrayNoLastLine>=MAXSlink)
                        {
                            return 0;
                        }

                        pGray[GrayNoLastLine] = TemArray[(i-1)*ColLen+k];
                        GrayNoLastLine++;

                        while(TemArray[(i-1)*ColLen+k]!=0)
                        {
                            k++;
                        }
                    }
                }


                if(GrayNoLastLine==0)
                {
                    GrayNo++;
                    if(GrayNo > MAXBLOCK)
                    {
                        return 0;
                    }

                    if(*TabLen >= MAXlink)
                    {
                        return 0;
                    }

                    neighbor[*TabLen] = GrayNo;
                    neighbor[*TabLen+MAXlink] = GrayNo;
                    (*TabLen)++;

    

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      26442  2017-12-18 16:59  OpenCv+Ocr\bwlabel.cpp

     文件       3653  2017-12-18 17:03  OpenCv+Ocr\bwlabel.h

     文件     802112  2017-12-19 23:18  OpenCv+Ocr\bwlabel.o

     文件      15109  2017-12-18 17:00  OpenCv+Ocr\CommonInterface.cpp

     文件       9644  2017-12-18 17:04  OpenCv+Ocr\CommonInterface.h

     文件     687648  2017-12-19 23:18  OpenCv+Ocr\CommonInterface.o

     文件       2605  2017-12-18 17:04  OpenCv+Ocr\CommonStruct.h

     文件     152577  2017-12-14 18:30  OpenCv+Ocr\Data\Image\1.jpg

     文件     153401  2017-12-14 18:30  OpenCv+Ocr\Data\Image\2.jpg

     文件      36711  2017-12-14 18:30  OpenCv+Ocr\Data\Image\3.jpg

     文件      36358  2017-12-14 18:30  OpenCv+Ocr\Data\Image\4.jpg

     文件     162645  2017-12-14 18:30  OpenCv+Ocr\Data\Image\5.jpg

     文件      49740  2017-12-14 18:30  OpenCv+Ocr\Data\Image\6.jpg

     文件      58063  2017-12-14 18:30  OpenCv+Ocr\Data\Image\7.jpg

     文件      53564  2017-12-14 18:30  OpenCv+Ocr\Data\Image\8.jpg

     文件       1302  2017-12-25 12:16  OpenCv+Ocr\Data\Output\1.bmp

     文件       1286  2017-12-25 12:16  OpenCv+Ocr\Data\Output\10.bmp

     文件       1198  2017-12-25 12:16  OpenCv+Ocr\Data\Output\100.bmp

     文件       1158  2017-12-25 12:16  OpenCv+Ocr\Data\Output\101.bmp

     文件       1094  2017-12-25 12:16  OpenCv+Ocr\Data\Output\102.bmp

     文件       1142  2017-12-25 12:16  OpenCv+Ocr\Data\Output\103.bmp

     文件       1094  2017-12-25 12:16  OpenCv+Ocr\Data\Output\104.bmp

     文件       1238  2017-12-25 12:16  OpenCv+Ocr\Data\Output\105.bmp

     文件       1094  2017-12-25 12:16  OpenCv+Ocr\Data\Output\106.bmp

     文件       1234  2017-12-25 12:16  OpenCv+Ocr\Data\Output\107.bmp

     文件       1158  2017-12-25 12:16  OpenCv+Ocr\Data\Output\108.bmp

     文件       1286  2017-12-25 12:16  OpenCv+Ocr\Data\Output\109.bmp

     文件       1286  2017-12-25 12:16  OpenCv+Ocr\Data\Output\11.bmp

     文件       1302  2017-12-25 12:16  OpenCv+Ocr\Data\Output\110.bmp

     文件       1158  2017-12-25 12:16  OpenCv+Ocr\Data\Output\111.bmp

............此处省略190个文件信息

评论

共有 条评论