Advertisement
Guest User

ma-ta e obeza

a guest
Jan 25th, 2015
266
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports Emgu.CV
  2. Imports Emgu.Util
  3. Imports Emgu.CV.OCR
  4. Imports Emgu.CV.Structure
  5. Imports System.Net
  6. Imports System.Text
  7. Imports System.IO
  8.  
  9.  
  10. Public Class Form1
  11.  
  12.  
  13.  
  14.  
  15.  
  16. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  17.  
  18. End Sub
  19.  
  20. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  21. PictureBox1.ImageLocation = "http://ratati.org/chall/image.php"
  22.  
  23. End Sub
  24.  
  25. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  26. Dim CropRect As New Rectangle(25, 20, 90, 20)
  27. Dim OrignalImage = PictureBox1.Image
  28. Dim CropImage = New Bitmap(CropRect.Width, CropRect.Height)
  29. Using grp = Graphics.FromImage(CropImage)
  30. grp.DrawImage(OrignalImage, New Rectangle(0, 0, CropRect.Width, CropRect.Height), CropRect, GraphicsUnit.Pixel)
  31.  
  32. PictureBox1.Image = CropImage
  33. End Using
  34.  
  35.  
  36.  
  37. Dim OCRz As Tesseract = New Tesseract("tessdata", "eng", Tesseract.OcrEngineMode.OEM_TESSERACT_ONLY)
  38. OCRz.SetVariable("tessedit_char_whitelist", "x0123456789")
  39. Dim pic As Bitmap = PictureBox1.Image
  40. OCRz.Recognize(New Image(Of Bgr, Byte)(pic))
  41. RichTextBox1.Text = OCRz.GetText
  42.  
  43. Dim raspuns As String
  44. Dim s As String = RichTextBox1.Text
  45.  
  46. ' Split string based on spaces
  47. Dim words As String() = s.Split(New Char() {"x"})
  48.  
  49. raspuns = words(0).ToString * words(1).ToString
  50. TextBox1.Text = raspuns
  51.  
  52.  
  53. '' request copy paste de pe msdn
  54. Dim request As WebRequest = WebRequest.Create("http://ratati.org/chall/index.php")
  55. request.Method = "POST"
  56. Dim postData As String = "res=" + raspuns.ToString + "&submit=submit"
  57. Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
  58. request.ContentType = "application/x-www-form-urlencoded"
  59. request.ContentLength = byteArray.Length
  60. Dim dataStream As Stream = request.GetRequestStream()
  61. dataStream.Write(byteArray, 0, byteArray.Length)
  62. dataStream.Close()
  63. Dim response As WebResponse = request.GetResponse()
  64. Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)
  65. dataStream = response.GetResponseStream()
  66. Dim reader As New StreamReader(dataStream)
  67. Dim responseFromServer As String = reader.ReadToEnd()
  68. WebBrowser1.DocumentText = (responseFromServer)
  69. reader.Close()
  70. dataStream.Close()
  71. response.Close()
  72.  
  73. End Sub
  74.  
  75.  
  76. End Class
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement