Example #1
0
 static void IncomingImage(Object sender, NewImageEventArgs e)
 {
     decodecount++;
     if (FramesTimeOut != 0)
     {
         FramesTimeOut--;
         return;
     }
     Bitmap Output = e.DecodedOutput;
     // First test to see if its the frame we want.
     Color Target = Color.FromArgb(255, 49, 76, 153);
     int Tolerance = 15;
     if(decodecount%10 == 0)
         Console.WriteLine("Decoding Frame {0}", decodecount);
     if (Img.FrameCycle(Output, Target, Tolerance, 5) && Img.FrameCycle(Output, Target, Tolerance, 560))
     {
         Console.WriteLine("We seem to have a frame that matches what we want.");
         Bitmap ToBeOCR = Img.CropToText(Output);
         string letters = OCRText(ToBeOCR);
         Console.WriteLine("THE TEXT IS {0}", letters);
         Searcher Words = new Searcher(letters);
         int limit = 0;
         var aaa = Words.Results.OrderBy(key => key.Value);
         string results = "For '"+letters+"' ";
         foreach (KeyValuePair<string, int> item in aaa)
         {
             if (Words.Results.Count < (limit + 3))
                 results += string.Format("Word {0} is {1} letters long. ", item.Key, item.Value);
             limit++;
         }
         new Twitter().Tweet(results);
         FramesTimeOut = 2000;
         return;
     }
 }
Example #2
0
 protected virtual void OnNewImage(NewImageEventArgs e)
 {
     NewImageEventHandler handler = NewImage;
     if (handler != null)
     {
         handler(this, e);
     }
 }
Example #3
0
 private void DecodeAndFlush(int x)
 {
     DecodeCount++;
     if(DecodeCount % 10 == 0)
         Console.Title = DecodeCount + "";
     // Get the byte array of JPEG
     try
     {
         MemoryStream JPEGRAW = new MemoryStream(ExtractFromArray(BufferPointer));
         Image MaybeJPEG = Image.FromStream(JPEGRAW);
         NewImageEventArgs args = new NewImageEventArgs();
         args.DecodedOutput = new Bitmap(MaybeJPEG);
         OnNewImage(args);
         MaybeJPEG.Dispose();
         JPEGRAW.Dispose();
     }
     catch
     {
         Console.WriteLine("Failed to decode buffer");
         //This can happen from time to time, Not always the users fault.
     }
 }