Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            ISample sample =
                new TemplateMatching();

            //TrackbarTest test = new TrackbarTest();
            //test.RunTest();
            //OCRTesseractTest test = new OCRTesseractTest();
            //test.Run();
            //LBPHFaceRecognizerTest test = new LBPHFaceRecognizerTest();
            //test.TrainAndPredict();
            //FastLineDetectorTest test = new FastLineDetectorTest();
            //test.DrawSegmentsUsingInputArray();
            //test.DrawSegmentsUsingVector();
            //new ClaheSample();
            //new ConnectedComponentsSample();
            //new HOGSample();
            //new HoughLinesSample();
            //new MatOperations();
            //new NormalArrayOperations();
            //new PhotoMethods();
            //new MorphologySample();
            //new PixelAccess();
            //new SolveEquation();
            //new Subdiv2DSample();
            //new SVMSample();
            //new VideoWriterSample();
            //new VideoCaptureSample();
            //TestWiringPi();
            //new FaceDetection();
            sample.Run();
            //"mkdir testdir".Bash();
            //BuildWebHost(args).Run();
        }
Exemplo n.º 2
0
 private void button2_Click(object sender, EventArgs e)
 {
     ModelPath = Path.GetFullPath("ModelImg");
     ModelPath += "/Model.dfm";
     //工程需要在x64位
     HalconHelper.TemplateMatching templateMatching = new TemplateMatching();
     var result = templateMatching.Findtemplates(hWindowControl1.HalconWindow,//视图
    new HalconHelper.HalconCommonly().FromBitmap32(DstBmp), ModelPath); //模板路径 //图像
     System.Diagnostics.Debug.Print(result.Count.ToString()); //返回list集合,value为相似度,剩下的自行判断,一般0.9以上都可以被认识是OK
 }
Exemplo n.º 3
0
 private void button1_Click(object sender, EventArgs e)
 {
     OpenFileDialog openFileDialog = new OpenFileDialog();
     openFileDialog.Filter = "All files(*.*) |*.*|Bitmap files (*.Bitmap)|*.Bmp|Jpeg files (*.jpg)|*.jpg|Png files (*.png)|*.png";
     if (openFileDialog.ShowDialog() == DialogResult.OK)
     {
         Bitmap Bmp = (Bitmap)Bitmap.FromFile(openFileDialog.FileName);
         DstBmp = (Bitmap)Bmp.Clone();
         Bmp.Dispose();
         HalconHelper.HalconCommonly halconCommonly = new HalconCommonly();
         halconCommonly.Adaptation_Window(new HalconHelper.HalconCommonly().FromBitmap32(DstBmp), hWindowControl1); //显示图像完全显示
         HalconHelper.TemplateMatching templateMatching = new TemplateMatching();
         templateMatching.Buildtemplate(hWindowControl1.HalconWindow, //视图
             new HalconHelper.HalconCommonly().FromBitmap32(DstBmp)//图像 
             );
     }
 }
Exemplo n.º 4
0
        public void cuda_MatchTemplate()
        {
            Mat  image = Image("lenna.png", ImreadModes.Grayscale);
            Mat  templ = image.RowRange(60, 80).ColRange(60, 80);
            Size size  = image.Size();

            using (GpuMat g_src = new GpuMat(size, image.Type()))
                using (GpuMat d_dst = new GpuMat()) {
                    g_src.Upload(image);

                    TemplateMatching alg = TemplateMatching.create(g_src.Type(), TemplateMatchModes.CCoeff);

                    GpuMat g_templ = new GpuMat();
                    g_templ.Upload(templ);
                    alg.match(g_src, g_templ, d_dst);

                    Mat dst_gold = new Mat();
                    Cv2.MatchTemplate(image, templ, dst_gold, TemplateMatchModes.CCoeff);

                    ImageEquals(g_templ, templ);
                    ShowImagesWhenDebugMode(g_templ, templ);
                }
        }