private Mat ShowScore(Image <Bgr, byte> imageFrame) { try { //CvInvoke.Resize(imageFram, imageFrame, new Size(100, 100)); List <QZScore> score = new List <QZScore>(); foreach (var grp in _qz.QZGroupArr) { // grp ? if (grp == null) { continue; } // score QZScore scr = new QZScore(); scr.GrpNbr = grp.GNbr; scr.GrpSymbol = grp.GSymbol; scr.Score = grp.GTime; scr.ScoreTot = grp.GTotalTime; score.Add(scr); } int y = 100; foreach (var grp in score.OrderBy(x => x.ScoreTot)) { imageFrame.Draw($"| G{grp.GrpNbr}", new Point(10, y), Emgu.CV.CvEnum.FontFace.HersheyPlain, 4.0, new Bgr(Color.Yellow), 3); imageFrame.Draw($"| {grp.GrpSymbol}", new Point(150, y), Emgu.CV.CvEnum.FontFace.HersheyPlain, 4.0, new Bgr(Color.Yellow), 3); imageFrame.Draw($"| {(grp.Score / 1000).ToString("N0")}", new Point(650, y), Emgu.CV.CvEnum.FontFace.HersheyPlain, 4.0, new Bgr(Color.Yellow), 3); imageFrame.Draw($"| {(grp.ScoreTot / 1000).ToString("N0")}", new Point(950, y), Emgu.CV.CvEnum.FontFace.HersheyPlain, 4.0, new Bgr(Color.Yellow), 5); y += 100; } Mat imageFram = new Mat(); //= new Image<Bgr, byte>(1280, 720); CvInvoke.Canny(imageFrame, imageFram, 100, 100); CvInvoke.Imshow("eee", imageFram); CvInvoke.WaitKey(1); return(imageFram); } catch (Exception) { } return(null); }
private Image <Bgr, byte> ShowScore2(Image <Bgr, byte> imageFrame) { try { if (imageFrame == null) { return(null); } //Mat imageTo = new Mat(); //CvInvoke.CvtColor(imageFrame, imageTo, ColorConversion.Bgr2Gray); //CvInvoke.CvtColor(imageFrame, imageTo, ColorConversion.Bgra2YuvYv12); //CvInvoke.CvtColor(imageFrame, imageTo, ColorConversion.Rgb2HsvFull); //Mat imageTo2 = new Mat(); ///CvInvoke.Canny(imageTo, imageTo2, 80, 100); //Mat imageGray = new Mat(); //CvInvoke.CvtColor(imageFrame, imageGray, ColorConversion.Bgr2Gray); //Mat imageBlur = new Mat(); //CvInvoke.MedianBlur(imageGray, imageBlur, 5); //Mat imageEdge = new Mat(); //CvInvoke.AdaptiveThreshold(imageBlur, imageEdge, 255, AdaptiveThresholdType.MeanC, ThresholdType.Binary, 5, 4); //CvInvoke.Imshow("edge", imageEdge); //CvInvoke.WaitKey(1); //Mat color = new Mat(); //CvInvoke.BilateralFilter(imageFrame, color, 9, 300, 300); //CvInvoke.Imshow("or", imageFrame); //CvInvoke.WaitKey(1); //CvInvoke.Imshow("blur", color); //CvInvoke.WaitKey(1); //Mat cartoon = new Mat(); //CvInvoke.BitwiseAnd(color, color, cartoon, imageEdge); //CvInvoke.Imshow("cartoon", cartoon); //CvInvoke.WaitKey(1); Mat blurred = new Mat(); CvInvoke.MedianBlur(imageFrame, blurred, 5); //CvInvoke.Imshow("blur", blurred); //CvInvoke.WaitKey(1); Mat can = new Mat(); CvInvoke.Canny(blurred, can, 80, 100); //CvInvoke.Imshow("can", can); //CvInvoke.WaitKey(1); imageFrame = can.ToImage <Bgr, byte>(); List <QZScore> score = new List <QZScore>(); foreach (var grp in _qz.QZGroupArr) { // grp ? if (grp == null) { continue; } // score QZScore scr = new QZScore(); scr.GrpNbr = grp.GNbr; scr.GrpSymbol = grp.GSymbol; scr.Score = grp.GTime; scr.ScoreTot = grp.GTotalTime; score.Add(scr); } int y = 100; foreach (var grp in score.OrderBy(x => x.ScoreTot)) { if ((grp.Score == 0) && (grp.ScoreTot == 0)) { continue; } imageFrame.Draw($"| G{grp.GrpNbr}", new Point(10, y), Emgu.CV.CvEnum.FontFace.HersheyPlain, 4.0, new Bgr(Color.Yellow), 3); imageFrame.Draw($"| {grp.GrpSymbol}", new Point(150, y), Emgu.CV.CvEnum.FontFace.HersheyPlain, 4.0, new Bgr(Color.Yellow), 3); imageFrame.Draw($"| {(grp.Score / 1000).ToString("N0")}", new Point(650, y), Emgu.CV.CvEnum.FontFace.HersheyPlain, 4.0, new Bgr(Color.Yellow), 3); imageFrame.Draw($"| {(grp.ScoreTot / 1000).ToString("N0")}", new Point(950, y), Emgu.CV.CvEnum.FontFace.HersheyPlain, 4.0, new Bgr(Color.Yellow), 5); y += 100; } return(imageFrame); } catch (Exception ex) { } return(null); }