private void InitFaceDetector() { if (_faceDetector == null) { InitPath(); String ssdFileLocal = MaskRcnnPage.DnnDownloadFile( "https://github.com/opencv/opencv_3rdparty/raw/dnn_samples_face_detector_20170830/", "res10_300x300_ssd_iter_140000.caffemodel", _path); String ssdProtoFileLocal = MaskRcnnPage.DnnDownloadFile( "https://raw.githubusercontent.com/opencv/opencv/4.0.1/samples/dnn/face_detector/", "deploy.prototxt", _path); _faceDetector = DnnInvoke.ReadNetFromCaffe(ssdProtoFileLocal, ssdFileLocal); } }
private void InitFacemark() { if (_facemark == null) { InitPath(); String facemarkFileName = "lbfmodel.yaml"; String facemarkFileUrl = "https://raw.githubusercontent.com/kurnianggoro/GSOC2017/master/data/"; String facemarkFileLocal = MaskRcnnPage.DnnDownloadFile( facemarkFileUrl, facemarkFileName, _path); using (FacemarkLBFParams facemarkParam = new CV.Face.FacemarkLBFParams()) { _facemark = new CV.Face.FacemarkLBF(facemarkParam); _facemark.LoadModel(facemarkFileLocal); } } }
public App() { Button helloWorldButton = new Button(); helloWorldButton.Text = "Hello world"; Button planarSubdivisionButton = new Button(); planarSubdivisionButton.Text = "Planar Subdivision"; Button faceDetectionButton = new Button(); faceDetectionButton.Text = "Face Detection (CascadeClassifier)"; Button faceLandmarkDetectionButton = new Button(); faceLandmarkDetectionButton.Text = "Face Landmark Detection (DNN Module)"; Button featureDetectionButton = new Button(); featureDetectionButton.Text = "Feature Matching"; Button shapeDetectionButton = new Button(); shapeDetectionButton.Text = "Shape Detection"; Button pedestrianDetectionButton = new Button(); pedestrianDetectionButton.Text = "Pedestrian Detection"; Button ocrButton = new Button(); ocrButton.Text = "OCR"; Button maskRcnnButton = new Button(); maskRcnnButton.Text = "Mask RCNN (DNN module)"; Button yoloButton = new Button(); yoloButton.Text = "Yolo (DNN module)"; Button stopSignDetectionButton = new Button(); stopSignDetectionButton.Text = "Stop Sign Detection (DNN module)"; List <View> buttonList = new List <View>() { helloWorldButton, planarSubdivisionButton, faceDetectionButton, faceLandmarkDetectionButton, featureDetectionButton, shapeDetectionButton, pedestrianDetectionButton, ocrButton, maskRcnnButton, stopSignDetectionButton, yoloButton, }; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && Emgu.Util.Platform.ClrType != Emgu.Util.Platform.Clr.NetFxCore) { Button viz3dButton = new Button(); viz3dButton.Text = "Simple 3D reconstruction"; buttonList.Add(viz3dButton); viz3dButton.Clicked += (sender, args) => { Mat left = CvInvoke.Imread("imL.png", ImreadModes.Color); Mat right = CvInvoke.Imread("imR.png", ImreadModes.Color); Viz3d v = Simple3DReconstruct.GetViz3d(left, right); v.Spin(); }; } StackLayout buttonsLayout = new StackLayout { VerticalOptions = LayoutOptions.Start, }; foreach (View b in buttonList) { buttonsLayout.Children.Add(b); } // The root page of your application ContentPage page = new ContentPage() { Content = new ScrollView() { Content = buttonsLayout, } }; String aboutIcon = null; /* * String aboutIcon; * if (Emgu.Util.Platform.OperationSystem == Emgu.Util.Platform.OS.IOS) * { * aboutIcon = null; * } * else if (Emgu.Util.Platform.ClrType == Emgu.Util.Platform.Clr.NetFxCore) * aboutIcon = null; * else * aboutIcon = "questionmark.png";*/ MainPage = new NavigationPage( page ); ToolbarItem aboutItem = new ToolbarItem("About", aboutIcon, () => { MainPage.Navigation.PushAsync(new AboutPage()); //page.DisplayAlert("Emgu CV Examples", "App version: ...", "Ok"); } ); page.ToolbarItems.Add(aboutItem); helloWorldButton.Clicked += (sender, args) => { MainPage.Navigation.PushAsync(new HelloWorldPage()); }; planarSubdivisionButton.Clicked += (sender, args) => { MainPage.Navigation.PushAsync(new PlanarSubdivisionPage()); }; faceDetectionButton.Clicked += (sender, args) => { MainPage.Navigation.PushAsync(new FaceDetectionPage()); }; shapeDetectionButton.Clicked += (sender, args) => { MainPage.Navigation.PushAsync(new ShapeDetectionPage()); }; pedestrianDetectionButton.Clicked += (sender, args) => { MainPage.Navigation.PushAsync(new PedestrianDetectionPage()); }; featureDetectionButton.Clicked += (sender, args) => { MainPage.Navigation.PushAsync(new FeatureMatchingPage()); }; if (Emgu.Util.Platform.ClrType == Emgu.Util.Platform.Clr.NetFxCore) { //No DNN module for UWP apps maskRcnnButton.IsVisible = false; faceLandmarkDetectionButton.IsVisible = false; stopSignDetectionButton.IsVisible = false; yoloButton.IsVisible = false; } else { maskRcnnButton.Clicked += (sender, args) => { MainPage.Navigation.PushAsync(new MaskRcnnPage()); }; faceLandmarkDetectionButton.Clicked += (sender, args) => { MainPage.Navigation.PushAsync(new FaceLandmarkDetectionPage()); }; stopSignDetectionButton.Clicked += (sender, args) => { MaskRcnnPage stopSignDetectionPage = new MaskRcnnPage(); stopSignDetectionPage.DefaultImage = "stop-sign.jpg"; stopSignDetectionPage.ObjectsOfInterest = new string[] { "stop sign" }; MainPage.Navigation.PushAsync(stopSignDetectionPage); }; yoloButton.Clicked += (sender, args) => { MainPage.Navigation.PushAsync(new YoloPage()); }; } ocrButton.Clicked += (sender, args) => { MainPage.Navigation.PushAsync(new OcrPage()); }; }
public App() { Button helloWorldButton = new Button(); helloWorldButton.Text = "Hello world"; Button planarSubdivisionButton = new Button(); planarSubdivisionButton.Text = "Planar Subdivision"; Button faceDetectionButton = new Button(); faceDetectionButton.Text = "Face Detection (CascadeClassifier)"; Button faceLandmarkDetectionButton = new Button(); faceLandmarkDetectionButton.Text = "Face Landmark Detection (DNN Module)"; Button featureDetectionButton = new Button(); featureDetectionButton.Text = "Feature Matching"; Button shapeDetectionButton = new Button(); shapeDetectionButton.Text = "Shape Detection"; Button pedestrianDetectionButton = new Button(); pedestrianDetectionButton.Text = "Pedestrian Detection"; Button ocrButton = new Button(); ocrButton.Text = "OCR"; Button maskRcnnButton = new Button(); maskRcnnButton.Text = "Mask RCNN (DNN module)"; Button yoloButton = new Button(); yoloButton.Text = "Yolo (DNN module)"; Button stopSignDetectionButton = new Button(); stopSignDetectionButton.Text = "Stop Sign Detection (DNN module)"; Button licensePlateRecognitionButton = new Button(); licensePlateRecognitionButton.Text = "License Plate Recognition"; List <View> buttonList = new List <View>() { helloWorldButton, planarSubdivisionButton, faceDetectionButton, faceLandmarkDetectionButton, featureDetectionButton, shapeDetectionButton, pedestrianDetectionButton, ocrButton, maskRcnnButton, stopSignDetectionButton, yoloButton, licensePlateRecognitionButton }; var openCVConfigDict = CvInvoke.ConfigDict; bool haveViz = (openCVConfigDict["HAVE_OPENCV_VIZ"] != 0); bool haveDNN = (openCVConfigDict["HAVE_OPENCV_DNN"] != 0); bool hasInferenceEngine = false; if (haveDNN) { var dnnBackends = DnnInvoke.AvailableBackends; hasInferenceEngine = Array.Exists(dnnBackends, dnnBackend => (dnnBackend.Backend == Dnn.Backend.InferenceEngine || dnnBackend.Backend == Dnn.Backend.InferenceEngineNgraph || dnnBackend.Backend == Dnn.Backend.InferenceEngineNnBuilder2019)); } if (haveViz) { Button viz3dButton = new Button(); viz3dButton.Text = "Simple 3D reconstruction"; buttonList.Add(viz3dButton); viz3dButton.Clicked += (sender, args) => { Mat left = CvInvoke.Imread("imL.png", ImreadModes.Color); Mat right = CvInvoke.Imread("imR.png", ImreadModes.Color); Viz3d v = Simple3DReconstruct.GetViz3d(left, right); v.Spin(); }; } StackLayout buttonsLayout = new StackLayout { VerticalOptions = LayoutOptions.Start, }; foreach (View b in buttonList) { buttonsLayout.Children.Add(b); } // The root page of your application ContentPage page = new ContentPage() { Content = new ScrollView() { Content = buttonsLayout, } }; String aboutIcon = null; /* * String aboutIcon; * if (Emgu.Util.Platform.OperationSystem == Emgu.Util.Platform.OS.IOS) * { * aboutIcon = null; * } * else if (Emgu.Util.Platform.ClrType == Emgu.Util.Platform.Clr.NetFxCore) * aboutIcon = null; * else * aboutIcon = "questionmark.png";*/ NavigationPage navigationPage = new NavigationPage(page); MainPage = navigationPage; //Fix for UWP navigation text if (Device.RuntimePlatform == Device.WPF) { navigationPage.BarTextColor = Color.Green; } ToolbarItem aboutItem = new ToolbarItem("About", aboutIcon, () => { MainPage.Navigation.PushAsync(new AboutPage()); //page.DisplayAlert("Emgu CV Examples", "App version: ...", "Ok"); } ); page.ToolbarItems.Add(aboutItem); helloWorldButton.Clicked += (sender, args) => { MainPage.Navigation.PushAsync(new HelloWorldPage()); }; planarSubdivisionButton.Clicked += (sender, args) => { MainPage.Navigation.PushAsync(new PlanarSubdivisionPage()); }; faceDetectionButton.Clicked += (sender, args) => { MainPage.Navigation.PushAsync(new FaceDetectionPage()); }; shapeDetectionButton.Clicked += (sender, args) => { MainPage.Navigation.PushAsync(new ShapeDetectionPage()); }; pedestrianDetectionButton.Clicked += (sender, args) => { MainPage.Navigation.PushAsync(new PedestrianDetectionPage()); }; featureDetectionButton.Clicked += (sender, args) => { MainPage.Navigation.PushAsync(new FeatureMatchingPage()); }; licensePlateRecognitionButton.Clicked += (sender, args) => { MainPage.Navigation.PushAsync(new LicensePlateRecognitionPage()); }; maskRcnnButton.Clicked += (sender, args) => { MainPage.Navigation.PushAsync(new MaskRcnnPage()); }; faceLandmarkDetectionButton.Clicked += (sender, args) => { MainPage.Navigation.PushAsync(new FaceLandmarkDetectionPage()); }; stopSignDetectionButton.Clicked += (sender, args) => { MaskRcnnPage stopSignDetectionPage = new MaskRcnnPage(); stopSignDetectionPage.DefaultImage = "stop-sign.jpg"; stopSignDetectionPage.ObjectsOfInterest = new string[] { "stop sign" }; MainPage.Navigation.PushAsync(stopSignDetectionPage); }; yoloButton.Clicked += (sender, args) => { MainPage.Navigation.PushAsync(new YoloPage()); }; ocrButton.Clicked += (sender, args) => { MainPage.Navigation.PushAsync(new OcrPage()); }; maskRcnnButton.IsVisible = haveDNN; faceLandmarkDetectionButton.IsVisible = haveDNN; stopSignDetectionButton.IsVisible = haveDNN; yoloButton.IsVisible = haveDNN; licensePlateRecognitionButton.IsVisible = hasInferenceEngine; }