public ActionResult Index(OCRModelClass obj, HttpPostedFileBase file) { string _FileName = getUniqueFileName(Path.GetFileName(file.FileName)); _path = Path.Combine(Server.MapPath("~/UploadedFiles"), _FileName); file.SaveAs(_path); // Create a Bitmap object from an image file. Bitmap myBitmap1 = new Bitmap(@"C:\Users\UPENDRA\source\repos\OCR\OCR\imagetoupload\cheque.jpg"); Bitmap myBitmap2 = new Bitmap(_path); // Get the color of a pixel within myBitmap. Color pixelColor1 = myBitmap1.GetPixel(50, 50); Color pixelColor2 = myBitmap2.GetPixel(50, 50); if (pixelColor1 == pixelColor2) { string extractText = this.ExtractTextFromImage(_path, obj.language); ViewBag.ImageText = extractText; ViewBag.Message = "Both images are identical"; } else { ViewBag.Message = "Both images are different"; } return(View()); //catch //{ // ViewBag.Message = "File upload failed!!"; // return View(); //} }
public ActionResult Index(OCRModelClass modelOCR, HttpPostedFileBase file) { try { if (file.ContentLength > 0) { string _FileName = getUniqueFileName(Path.GetFileName(file.FileName)); string _path = Path.Combine(Server.MapPath("~/UploadedFiles"), _FileName); file.SaveAs(_path); string extractText = this.ExtractTextFromImage(_path, modelOCR.language); ViewBag.ImageText = extractText; } ViewBag.Message = "File Uploaded Successfully."; return(View()); } catch { ViewBag.Message = "File upload failed!!"; return(View()); } }