■ Latent SVM 검출기를 사용하는 방법을 보여준다.
▶ Program.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
using System; using System.Drawing; using System.Windows.Forms; using Emgu.CV; using Emgu.CV.Structure; using Emgu.CV.UI; using System.Diagnostics; namespace TestProject { /// <summary> /// 프로그램 /// </summary> static class Program { //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Static //////////////////////////////////////////////////////////////////////////////// Private #region 프로그램 시작하기 - Main() /// <summary> /// 프로그램 시작하기 /// </summary> [STAThread] private static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Run(); } #endregion #region 실행하기 - Run() /// <summary> /// 실행하기 /// </summary> private static void Run() { using(Image<Bgr, Byte> image = new Image<Bgr, byte>("cat.jpg")) { using(LatentSvmDetector detector = new LatentSvmDetector("cat.xml")) { Stopwatch stopwatch = Stopwatch.StartNew(); MCvObjectDetection[] objectDetectionArray = detector.Detect(image, 0.5f); stopwatch.Stop(); foreach(MCvObjectDetection objectDetection in objectDetectionArray) { if(objectDetection.score > -0.5) { image.Draw(objectDetection.Rect, new Bgr(Color.Red), 1); } } ImageViewer.Show(image, String.Format("객체 탐지 : {0} 밀리초", stopwatch.ElapsedMilliseconds)); } } } #endregion } } |