CubieBoard中文论坛

 找回密码
 立即注册
搜索
热搜: unable
查看: 5532|回复: 2

点阵字库提取与字符串识别

[复制链接]
发表于 2014-3-3 16:34:43 | 显示全部楼层 |阅读模式
#include "stdafx.h"
#include "MyOcr.h"
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include "HextoBinary.h"
#include "GobalStruct.h"
#include <atlfile.h>
MyOcr::MyOcr()
{
        HexText.Empty();
        BinText.Empty();
        this->pExocr=new OCREx[10240];
        memset(this->pExocr,0,sizeof(OCREx)*10240);


}
/************************************************************************/
/* 把指定图像的颜色二值化,并返回2进制字符串                               */
/************************************************************************/
bool MyOcr::ToDIC1_Iplimage(IplImage* mat,byte R,byte G,byte B,CAtlString& RetHexBinay)
{
        //cols行  Rows列
        //计算图像一行需要被赋值的个数
        //int rowLength = mat->cols*mat->channels();
         int MaxW, MaxH;
         MaxW=mat->width;
         MaxH=mat->height;
         RetHexBinay.Empty();
         for (int y=0;y<MaxH;y++)
         {
                 byte* DATA=(byte*)((DWORD)mat->imageData+mat->widthStep*y);
                 for(int x=0;x<MaxW;x++)
                 {
                         if (DATA[0]==B &&  DATA[1]==G  &&DATA[2]==R)
                         {
                                 DATA[0]=255;
                                 DATA[1]=255;
                                 DATA[2]=255;
                                 RetHexBinay.Append("1");
                         }else{
                                       
                                 DATA[0]=0;
                                 DATA[1]=0;
                                 DATA[2]=0;
                                 RetHexBinay.Append("0");

                         
                         }
                 }
         }

return 1;
}


//头文件
#ifndef STURCT_OCR1
#define STURCT_OCR1






typedef struct _OCR
{

        char name[256];
        bool HasData;
        int x;
        int y;
        int findMcout;
        int MinX;
        int MinY;
        int MaxX;
        int MaxY;

}OCR,*POCR;




typedef struct _OCREx
{
OCR* pocr;
int OcrNumber;

}OCREx;

///////////////////////字典工具里的变量///////////////////////////////////////////////////

#endif
回复

使用道具 举报

发表于 2014-3-3 17:59:29 | 显示全部楼层
典型的windows MFC程序,多年没玩过了。。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-3-4 00:12:01 来自手机 | 显示全部楼层
语言具有相通性
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|粤ICP备13051116号|cubie.cc---深刻的嵌入式技术讨论社区

GMT+8, 2024-4-19 17:30 , Processed in 0.021744 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2012 Comsenz Inc. | Style by Coxxs

返回顶部