- l)3wilKßZ ►☻◄ ƒøяυλ⁄(-мємвєя
- samir shrilimkar
POSTS : 17
REPUTATION : 3
KBZ TEAM POINTS : 35
JOIN DATE : 2015-09-17
How To Recognise Captcha In C# With OCR Testract Engine
Sun Dec 27, 2015 7:19 am
1. Step Creat A form And Drop Down A pictureBox on Form And Two TextBox One For Captcha Image Url And Another For Captcha Recognise Answer
2. Step Fisrt Of all Add tessnet2_32.dll in Your Refrance Library With Project.
3. Step Copy All Code Below Than Paste It on Your Project.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using tessnet2;
namespace Captch_Recogniser
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string session = string.Empty;
Tesseract ocr = new Tesseract();
private void loadcaptcha() // Add Fuction For Get Captcha Image and Reply In A textBox
{
try
{
session = string.Empty;
Random r = new Random();
for (int i = 0; i < 9; i++)
{
session += "abcdefghijklmnopqrstuvwxyz"[r.Next(10)];
}
pictureBox1.ImageLocation = "http://siteAddress.com/captcha" + session;
pictureBox1.Load();
var image = new Bitmap(pictureBox1.Image);
Tesseract ocr = new Tesseract();
ocr.SetVariable("tessedit_char_whitelist", "abcdefghijklmnopqrstuvwxyz");// Here tessedit_char_whitelist Use For Recognise Only Alphabates wich is Followed by "...
" After Comma , //
ocr.Init(@"C:\Users\Admin\Desktop\Captcha_Recognise\tessdata", "eng", false); //Testract Engine Address wich is save in tessdata Folder Andd tessdata Folder must be add in Your Project Folder Without Rename It //
var result = ocr.DoOCR(image, Rectangle.Empty);
string ad = "";
foreach (Word word in result)
ad += word.Text;
txtcap.Text = ad;// txtcap.Text is Captcha Reply TextBox
System.Threading.Thread.Sleep(2000);
}
catch { }
}
}
}
Download Link For tessdata Captcha Recognisation Engine : https://www.mediafire.com/?4z21z4rs6ataf4n
Download tessnet2_32.dll From Here : https://www.mediafire.com/?9jcn1a2mkm5jwk6
For More Add Me At [You must be registered and logged in to see this link.]
2. Step Fisrt Of all Add tessnet2_32.dll in Your Refrance Library With Project.
3. Step Copy All Code Below Than Paste It on Your Project.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using tessnet2;
namespace Captch_Recogniser
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string session = string.Empty;
Tesseract ocr = new Tesseract();
private void loadcaptcha() // Add Fuction For Get Captcha Image and Reply In A textBox
{
try
{
session = string.Empty;
Random r = new Random();
for (int i = 0; i < 9; i++)
{
session += "abcdefghijklmnopqrstuvwxyz"[r.Next(10)];
}
pictureBox1.ImageLocation = "http://siteAddress.com/captcha" + session;
pictureBox1.Load();
var image = new Bitmap(pictureBox1.Image);
Tesseract ocr = new Tesseract();
ocr.SetVariable("tessedit_char_whitelist", "abcdefghijklmnopqrstuvwxyz");// Here tessedit_char_whitelist Use For Recognise Only Alphabates wich is Followed by "...
" After Comma , //
ocr.Init(@"C:\Users\Admin\Desktop\Captcha_Recognise\tessdata", "eng", false); //Testract Engine Address wich is save in tessdata Folder Andd tessdata Folder must be add in Your Project Folder Without Rename It //
var result = ocr.DoOCR(image, Rectangle.Empty);
string ad = "";
foreach (Word word in result)
ad += word.Text;
txtcap.Text = ad;// txtcap.Text is Captcha Reply TextBox
System.Threading.Thread.Sleep(2000);
}
catch { }
}
}
}
Download Link For tessdata Captcha Recognisation Engine : https://www.mediafire.com/?4z21z4rs6ataf4n
Download tessnet2_32.dll From Here : https://www.mediafire.com/?9jcn1a2mkm5jwk6
For More Add Me At [You must be registered and logged in to see this link.]
Permissions in this forum:
You cannot reply to topics in this forum