public List <FaceResult> GetResultFromImageAnalysis(string fileLocation) { ImageAnalyze analyzer = new ImageAnalyze(Configuration["key"], Configuration["url"]); List <FaceResult> lst = analyzer.GetResult(fileLocation); return(lst); }
/// <summary> /// Recognition (LoadBanknotesTrain) => ImageAnalyze (PreProcess) => Recognition (DetectBanknotesResults) /// </summary> private void runToolStripMenuItem_Click(object sender, EventArgs e) { if (_pathImageMain != null) { _recognition = new Recognition(); _recognition.LoadImagesTrain(); Stopwatch watch = new Stopwatch(); _imageAnalyze = new ImageAnalyze(_recognition); var imageResult = new Mat(_pathImageMain, LoadImageType.Color); watch.Start(); _imageAnalyze.RunEvaluateImage(imageResult); watch.Stop(); MessageBox.Show($"Time Evaluate: {watch.Elapsed}"); } else { MessageBox.Show("Select One Image for Evaluate"); } }
public Analyser() { Tevian_Analyser = new ImageAnalyze(); Tevian_Analyser.Init(3.0m, 3.1m, 0.75m, 0.3m, 0.04m, 0.025m, 0.358m, 0.025m, -0.2m, 0.358m, 0.2m); backgoundThread_ImageAnalizer = new BackgroundWorker(); backgoundThread_ImageAnalizer.WorkerSupportsCancellation = true; backgoundThread_ImageAnalizer.DoWork += bwImageAnalizer_DoWork; // webCamErrors = new HashSet<PostUserActivity.Contracts.AnalyzeImageResultType>(); }
private AnalyseResult RotateOnAngle(Bitmap tempBitmap, ImageAnalyze Tevian_Analyser) { AnalyzeImageResultType Error = AnalyzeImageResultType.FaceNotFound; var tempResult = Tevian_Analyser.AnalyseScanImage(tempBitmap); Error = tempResult.Errors; if (Error != AnalyzeImageResultType.InnerException) { if (tempResult.Faces.Length != 0) //&& (tempResult.Document.Height < tempResult.Document.Width) пока не ищет координаты документа...закоментил { double angle = 0; foreach (var item in tempResult.ImageDimensions) { if (item.DimensionName == "Угол") { angle = double.Parse(item.DimensionValue); } } tempBitmap = RotateImage(tempBitmap, angle); tempBitmap.Save("MediaFolder\\AfterRotate_" + DateTime.Now.ToString("MMss") + ".jpg"); tempResult = Tevian_Analyser.AnalyseScanImage(tempBitmap); foreach (var item in tempResult.ImageDimensions) { logger.Info("{0},{1}", item.DimensionName, item.DimensionValue); } if (tempResult.Faces.Length != 0) //&& (tempResult.Document.Height < tempResult.Document.Width) пока не ищет координаты документа...закоментил { FaceCoordinates = new Rectangle(tempResult.Faces[0].X, tempResult.Faces[0].Y, tempResult.Faces[0].Width, tempResult.Faces[0].Height); return(new AnalyseResult { Full = tempBitmap, Cropped = CommonLib.ImageExtensions.CropImage(new Bitmap(tempBitmap), FaceCoordinates), Errors = tempResult.Errors }); } else { // Rectangle Rect = new Rectangle(tempResult.Faces[0].X, tempResult.Faces[0].Y, tempResult.Faces[0].Width, tempResult.Faces[0].Height); return(new AnalyseResult { Full = tempBitmap, Cropped = null, Errors = tempResult.Errors }); } } } return(new AnalyseResult { Full = tempBitmap, Cropped = null, Errors = Error }); }
/// <summary> /// 画面解析タイマー /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timerCapture_Tick(object sender, EventArgs e) { // 同時実行はひとつだけ if (timer1_sync == true) { //System.Diagnostics.Debug.WriteLine(string.Format("{0}: Skip Main_LOOP", DateTime.Now.ToString("HH:mm:ss"))); return; } timer1_sync = true; try { // チェック Bitmap bmp = ScreenCapture.GetBitmap(); if (bmp != null) { ImageAnalyze ia = new ImageAnalyze(bmp); DateTime now = DateTime.Now; txtPosName.Text = ImageMap.CheckScene(ia); // 画損を保存する条件を判定 bool nextSnap = JoyPad.SnapShot == true; if (chkAutoSave.Checked == true) { if (txtPosName.Text == "不明" && ScreenCapture.IsWindowActive == true) { TimeSpan span = now - lastKown; if (span.TotalSeconds > 5f * (snapCount + 1)) { if (snapCount < 3) { nextSnap = true; } lastKown = now; } } else { lastKown = now; snapCount = 0; } } bool freeNG = false; try { #if WITHMANAGER if (frmEdit != null && nextSnap == true) { if (nextSnap && ScreenCapture.IsWindowActive == true) { frmEdit.saveNextSnap = true; JoyPad.SnapShot = false; snapCount++; } // 処理が渡った場合は true が返る freeNG = frmEdit.SetImage(bmp, ImageMap.curScene); } #else // 画像キャプチャ指示 // TODO: フラグのセットをイベントハンドラによるコールバックにするべき if (JoyPad.SnapShot == true) { // ドライブの空き容量確認 (32MB以下なら保存しない) DriveInfo di = new DriveInfo(Path.GetPathRoot(Program.ImageFileDirectory)); if (di.TotalFreeSpace <= 32 * 1024 * 1024) { return; } // ファイル名生成 string fileNameRule = "yyyy年MM月dd日HH時mm分ss秒"; string saveFile = string.Format(@"{0}\{1}.png", Program.ImageFileDirectory, DateTime.Now.ToString(fileNameRule)); // 既に同名のファイルがあれば何もしない if (File.Exists(saveFile)) { return; } try { // PNG形式で保存 bmp.Save(saveFile, System.Drawing.Imaging.ImageFormat.Png); } catch { } } #endif } finally { // 必ずフラグ下ろす JoyPad.SnapShot = false; // キャプチャ画像を委譲してなければ後始末 if (freeNG == false) { bmp.Dispose(); } } } } finally { timer1_sync = false; } }