EMO Style ForumPro - Hos Geldiniz
Simple Optical Character Recognition (OCR) in C++ Uyeols10

Join the forum, it's quick and easy

EMO Style ForumPro - Hos Geldiniz
Simple Optical Character Recognition (OCR) in C++ Uyeols10
EMO Style ForumPro - Hos Geldiniz
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Giriş yap

Şifremi unuttum

Istatistikler
Toplam 203 kayıtlı kullanıcımız var
Son kaydolan kullanıcımız: crayzboy76

Kullanıcılarımız toplam 1186 mesaj attılar bunda 862 konu
Tarıyıcı
 Kapı
 Indeks
 Üye Listesi
 Profil
 SSS
 Arama
Arama
 
 

Sonuç :
 


Rechercher çıkıntı araştırma

RSS akısı


Yahoo! 
MSN 
AOL 
Netvibes 
Bloglines 


Anahtar-kelime

kutu  pointer  loot  

Kimler hatta?
Toplam 2 kullanıcı online :: 0 Kayıtlı, 0 Gizli ve 2 Misafir :: 1 Arama motorları

Yok

[ Bütün listeye bak ]


Sitede bugüne kadar en çok 217 kişi C.tesi Tem. 29, 2017 1:46 am tarihinde online oldu.
En son konular
» İnternetten Para Kazandıran Oyun ! Ödeme Alt Limiti Yok ! DEV KONU
Simple Optical Character Recognition (OCR) in C++ I_icon_minitimeCuma Ağus. 29, 2014 8:33 am tarafından Hello EMO

» goldenchase.net maden yaparak para kazanma
Simple Optical Character Recognition (OCR) in C++ I_icon_minitimeCuma Ağus. 29, 2014 8:18 am tarafından Hello EMO

» etichal hacker görsel egitim seti
Simple Optical Character Recognition (OCR) in C++ I_icon_minitimeÇarş. Ağus. 06, 2014 4:57 am tarafından Hello EMO

» KO TBL Source C#
Simple Optical Character Recognition (OCR) in C++ I_icon_minitimePtsi Ara. 09, 2013 6:36 am tarafından Hello EMO

» x86 Registers
Simple Optical Character Recognition (OCR) in C++ I_icon_minitimeC.tesi Ağus. 24, 2013 5:02 am tarafından Hello EMO

» [Tutorial] Pegando Address, Pointers de WYD
Simple Optical Character Recognition (OCR) in C++ I_icon_minitimeÇarş. Tem. 10, 2013 7:25 am tarafından Hello EMO

» [Tutorial] Pegando Address, Pointers de CS Metodo²
Simple Optical Character Recognition (OCR) in C++ I_icon_minitimeÇarş. Tem. 10, 2013 7:23 am tarafından Hello EMO

» [Tutorial] Aprendendo basico deASM OLLYDBG
Simple Optical Character Recognition (OCR) in C++ I_icon_minitimeÇarş. Tem. 10, 2013 7:22 am tarafından Hello EMO

» Basic C# DLL injector
Simple Optical Character Recognition (OCR) in C++ I_icon_minitimePtsi Tem. 08, 2013 7:48 am tarafından Hello EMO

Reklam

Simple Optical Character Recognition (OCR) in C++

Aşağa gitmek

Simple Optical Character Recognition (OCR) in C++ Empty Simple Optical Character Recognition (OCR) in C++

Mesaj tarafından Hello EMO Ptsi Haz. 27, 2011 4:01 am

[quote name='Flam' timestamp='1296428763' post='287']
I found this snippet lying around my external drive today. I forgot where I got it from, but it's an OCR

It needs devIL, an image library: http://openil.sourceforge.net/about.php

Here's the code, maybe you can learn from it.

Kod:
#include <iostream>
#include <vector>
#include <IL/il.h>
#include <IL/ilu.h>

typedef unsigned int uint32;

struct pixeldata
{
   ILubyte r;
   ILubyte g;
   ILubyte b;

   pixeldata() : r(0), g(0), b(0) {};

} black;

struct coords
{
   uint32 x;
   uint32 y;

   coords() : x(0), y(0) {};
};

/* Returns true if given coordinate has a white pixel. */
bool IsWhite(uint32 x, uint32 y)
{
   pixeldata p;
   ilCopyPixels(x, y, 0, 1, 1, 1, IL_RGB, IL_UNSIGNED_BYTE, &p);

   if(
      p.r >= 0xc0 &&
      p.g >= 0xc0 &&
      p.b >= 0xc0) return true;

   return false;
}

/* Will find number of whites in all nodes around given coordinate. */
uint32 FriendCount(uint32 x, uint32 y)
{
   uint32 count = 0;

   if(IsWhite(x-1, y-1)) count++;
   if(IsWhite(x-1, y-0)) count++;
   if(IsWhite(x-1, y+1)) count++;
   if(IsWhite(x+1, y-1)) count++;
   if(IsWhite(x+1, y-0)) count++;
   if(IsWhite(x+1, y+1)) count++;
   if(IsWhite(x+0, y-1)) count++;
   if(IsWhite(x+0, y+1)) count++;

   return count;
}

/* Removes any white pixel with less than 3 neighbouring white nodes. */
void CleanDots(uint32 imWidth, uint32 imHeight)
{
   for(uint32 x = 0; x < imWidth; x++) {
      for(uint32 y = 0; y < imHeight; y++) {
         if(IsWhite(x, y) && FriendCount(x, y) <= 2) {
            ilSetPixels(x, y, 0, 1, 1, 1, IL_RGB, IL_UNSIGNED_BYTE, &black);
         }
      }
   }
}

/* Cleans up remaining pixels at edges of image. */
void CleanEdges(uint32 imWidth, uint32 imHeight)
{
   for(uint32 x = 0; x < imWidth; x++) {
      ilSetPixels(x, 0, 0, 1, 1, 1, IL_RGB, IL_UNSIGNED_BYTE, &black);
      ilSetPixels(x, (imHeight-1), 0, 1, 1, 1, IL_RGB, IL_UNSIGNED_BYTE, &black);
   }
   for(uint32 y = 0; y < imHeight; y++) {
      ilSetPixels(0, y, 0, 1, 1, 1, IL_RGB, IL_UNSIGNED_BYTE, &black);
      ilSetPixels((imWidth-1), y, 0, 1, 1, 1, IL_RGB, IL_UNSIGNED_BYTE, &black);
   }
}

/* Uses the floodfill algorithm to build our coordinate vector. */
void FloodFill(uint32 x, uint32 y, std::vector<coords>& coordinates, uint32& nodecount)
{
   if(!IsWhite(x, y)) return;
   ilSetPixels(x, y, 0, 1, 1, 1, IL_RGB, IL_UNSIGNED_BYTE, &black);

   coords coord;
   coord.x = x; coord.y = y;
   coordinates.push_back(coord);

   nodecount++;

   /* Execute FloodFill for neighbouring nodes. */
   FloodFill(x-1, y-1, coordinates, nodecount);
   FloodFill(x-1, y-0, coordinates, nodecount);
   FloodFill(x-1, y+1, coordinates, nodecount);
   FloodFill(x+1, y-1, coordinates, nodecount);
   FloodFill(x+1, y+0, coordinates, nodecount);
   FloodFill(x+1, y+1, coordinates, nodecount);
   FloodFill(x+0, y-1, coordinates, nodecount);
   FloodFill(x+0, y+1, coordinates, nodecount);
}

/* Builds our character vector and more. */
void FindLow(uint32 imWidth, uint32 imHeight)
{
   pixeldata white;
   white.r = 0xff; white.g = 0xff; white.b = 0xff;

   /* Build our character vector. */
   std::vector< std::vector<coords> > characters;
   for(uint32 x = 0; x < imWidth; x++) {
      for(uint32 y = 0; y < imHeight; y++) {
         if(IsWhite(x, y)) {
            uint32 nodecount = 0;
            std::vector<coords> coordinates;
            FloodFill(x, y, coordinates, nodecount);
            if(nodecount > 30) {
               characters.push_back(coordinates);
            }
         }
      }
   }

   std::vector< std::vector<coords> >::iterator iter;
   for(iter = characters.begin(); iter != characters.end(); iter++)
   {
      std::vector<coords>* character = &*iter;
      std::vector<coords>::iterator chariter = (*character).begin();

      /* find our lowest x and highest y value */
      coords corner, bounds; corner.x = imWidth; corner.y = imHeight;
      for(; chariter != (*character).end(); chariter++) {
         if(chariter->x < corner.x) corner.x = chariter->x;
         if(chariter->y < corner.y) corner.y = chariter->y;
      }
      /* now position our character to the far bottom left: */
      for(chariter = (*character).begin(); chariter != (*character).end(); chariter++) {
         chariter->x -= corner.x;
         chariter->y -= corner.y;
      }
   }

   /* Copy back a character to analyze. */
   std::vector<coords>* character = &characters.at(5);
   std::vector<coords>::iterator chariter = (*character).begin();
   for(; chariter != (*character).end(); chariter++)
   {
      // dump our table
      printf("%d, %d\n", chariter->x, chariter->y);
      ilSetPixels(chariter->x, chariter->y, 0, 1, 1, 1, IL_RGB, IL_UNSIGNED_BYTE, &white);
   }
}

int main()
{
   /* Initialize DevIL and load our image. */
   ilInit();

   system("del C:\\out.bmp");

   if(!ilLoad(IL_BMP, "C:\\captcha\\test1.bmp")) {
      printf("Could not load image: %d\n", ilGetError());
      std::cin.get();
      return 0;
   }

   /* Grab some information... */
   uint32 imWidth  = ilGetInteger(IL_IMAGE_WIDTH);
   uint32 imHeight = ilGetInteger(IL_IMAGE_HEIGHT);
   uint32 imPixCnt = imWidth * imHeight * 3;

   /* Convert raw image data to RGB. */
   if(!ilConvertImage(IL_RGB, ilGetInteger(IL_IMAGE_TYPE))) {
      printf("Could not convert image: %d\n", ilGetError());
      std::cin.get();
      return 0;
   }

   /* Clean up. */
   CleanEdges(imWidth, imHeight);
   CleanDots (imWidth, imHeight);

   FindLow(imWidth, imHeight);

   /* Save resulting image. */
   if(!ilSave(IL_BMP, "C:\\out.bmp")) {
      printf("Could not save image: %d\n", ilGetError());
      std::cin.get();
      return 0;
   }

   system("pause");
   return 0;
}
[/quote]
Hello EMO
Hello EMO
EMO Team
EMO Team

Cinsiyet : Erkek
Burçlar : Yay
Yılan
Mesaj Sayısı : 935
Puan : 372443
Rep Puanı : 18
Doğum tarihi : 28/11/89
Kayıt tarihi : 21/07/09
Yaş : 34
Nerden : EMO WorlD
İş/Hobiler : RCE Student / Game Hacking / Learn Beginner C#,C++,Delphi
Lakap : EMO

https://emostyle.yetkinforum.com

Sayfa başına dön Aşağa gitmek

Sayfa başına dön

- Similar topics

 
Bu forumun müsaadesi var:
Bu forumdaki mesajlara cevap veremezsiniz