private async Task LoadModelAsync() { StorageFile modelFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri(fileName)); _model = new ObjectDetection(new string[] { "AceOfHearts" }); await _model.Init(modelFile); }
private async void InitModel() { _objectDetection = new ObjectDetection(); var modelFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///Assets/model.onnx")); await _objectDetection.Init(modelFile); }
static void Main(string[] args) { AppDomain domain = Startup(); ImageStitching stitcher = new ImageStitching(); Barcode decoder = new Barcode(); ObjectDetection detector = new ObjectDetection(); string cpu_folder_name; /* Stitch Image and decode barcode: */ var img_list = stitcher.Load_images(SolutionDir.ToString(), Data.Constants.Seg_R, Data.Constants.Seg_R, Data.Constants.filename_top); var img = stitcher.Stitch(img_list); var barcode = decoder.Barcode_finding_run(img); /* Create file and save Image: */ cpu_folder_name = "ACIS_" + DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss"); string save_path = SolutionDir.ToString() + "\\" + cpu_folder_name; Directory.CreateDirectory(Path.Combine(SolutionDir.ToString(), cpu_folder_name)); String fileName = "BarcodeInfo_" + Data.Constants.filename_top + ".xml"; new XDocument(new XElement("ACIS", new XElement("barcode", barcode))).Save(Path.Combine(save_path, fileName)); img.Save(Path.Combine(save_path, Data.Constants.filename_top + ".jpg")); /* Defect Detection: */ Cleanup(domain, stitcher); Console.WriteLine("\n\n"); Console.WriteLine("The stitched image and xml file holding the barcode has been saved"); Console.WriteLine("The save location is in the ACIS_Showcase solution directory under Images"); Console.WriteLine("Defect Detection Will be added shortly."); Console.WriteLine("Thank you. Hit Enter to continue:"); Console.ReadLine(); }
void Start() { characterController = GetComponent <CharacterController>(); objectDetection = GetComponent <ObjectDetection>(); holder = GetComponent <Holder>(); animator = GetComponentInChildren <Animator>(); }
private void Awake() { foxCharacter = GetComponent <Fox>(); modelMesh = GetComponentInChildren <MeshRenderer>(); movementController = GetComponentInChildren <Movement>(); detectorFood = GetComponentInChildren <ObjectDetection>(); boxCollider = GetComponentInChildren <BoxCollider>(); }
public ProcessWithONNX() { List <String> labels = new List <String> { "box" }; objectDetection = new ObjectDetection(labels, 20, 0.4F, 0.45F); }
private async void InitONNX() { var modelFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///Model/{ModelFilename}")); objectDetection = new ObjectDetection(new List <string>() { "Mask", "No Mask" }); await objectDetection.Init(modelFile); }
void Start() { anim = GetComponent <Animator>(); playerCam = Camera.main.transform; targetTransform = new GameObject().transform; targetTransform.name = "targetTransform"; objectDetection = GetComponent <ObjectDetection>(); }
static void Main(string[] args) { try { //Setting global device Logging.OnWriteLog += Logging_OnWriteLog; //XOR Example XORExample.LoadData(); XORExample.BuildModel(); XORExample.Train(); //Housing regression example HousingRegression.LoadData(); HousingRegression.BuildModel(); HousingRegression.Train(); //MNIST Classification example MNISTClassifier.LoadData(); MNISTClassifier.BuildModel(); MNISTClassifier.Train(); //LSTM Time series example TimeSeriesPrediction.LoadData(); TimeSeriesPrediction.BuildModel(); TimeSeriesPrediction.Train(); //Multi variate time series prediction MiltiVariateTimeSeriesPrediction.LoadData(); MiltiVariateTimeSeriesPrediction.BuildModel(); MiltiVariateTimeSeriesPrediction.Train(); //Cifar - 10 Classification example //Cifar10Classification.LoadData(); //Cifar10Classification.BuildModel(); //Cifar10Classification.Train(); //Image classification example Console.WriteLine("ResNet50 Prediction: " + ImageClassification.ImagenetTest(SiaNet.Common.ImageNetModel.ResNet50)[0].Name); //Console.WriteLine("Cifar 10 Prediction: " + ImageClassification.Cifar10Test(SiaNet.Common.Cifar10Model.ResNet110)[0].Name); //Object Detection ObjectDetection.PascalDetection(); //ObjectDetection.GroceryDetection(); Console.ReadLine(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); Console.ReadLine(); } }
static void Main(string[] args) { var templates = new List <Mat>(); AppDomain domain = Startup(); ObjectDetection detector = new ObjectDetection(); var img_path = Path.Combine(SolutionDir.ToString(), Data.Constants.filename_bot + ".jpg"); var img = CvInvoke.Imread(img_path, ImreadModes.AnyColor); templates = detector.Load_tempaltes(SolutionDir.ToString()); detector.Init_detection(0.96); detector.Match_templates(img, templates); }
private async void Page_Loaded(object sender, RoutedEventArgs e) { StorageFile modelFile = await StorageFile.GetFileFromApplicationUriAsync( new Uri("ms-appx:///Assets/model.onnx")); string labelsString = await File.ReadAllTextAsync("Assets/labels.txt"); var labels = labelsString.Split("\r\n"); model = new ObjectDetection(labels); await model.Init(modelFile); }
async void Start() { try { // Get components _user = GetComponent <UserInput>(); // Load model StatusBlock.text = $"Loading ONNX ..."; #if ENABLE_WINMD_SUPPORT _file = await Package.Current.InstalledLocation.GetFileAsync("model.onnx"); _dnnModel = new ObjectDetection(new[] { "Arc Mouse", "Surface Book", "Surface Pro" }); await _dnnModel.Init(_file); StatusBlock.text = $"Loaded model. Starting camera..."; // Configure camera to return frames fitting the model input size _mediaCapturer = new MediaCapturer(); await _mediaCapturer.StartCapturing(416, 416); StatusBlock.text = $"Camera started. Running!"; // Run processing loop in separate parallel Task _isRunning = true; await Task.Run(async() => { while (_isRunning) { using (var videoFrame = _mediaCapturer.GetLatestFrame()) { if (videoFrame != null) { await EvaluateFrame(videoFrame); } } } }); #endif } catch (Exception ex) { #if ENABLE_WINMD_SUPPORT string filename = _file != null ? _file.Name : "nofile"; StatusBlock.text = $"File: {filename}, Error init: {ex.Message}"; #endif Debug.LogError(ex); } }
public async Task LoadModelAsync(string modelName = "", int maxDetections = 20, float probabilityThreshold = 0.1f, float iouThreshold = 0.45f) { if (maxDetections > 0 && maxDetections <= 20) { this.maxDetections = maxDetections; } if (probabilityThreshold > 0 && probabilityThreshold <= 1) { this.probabilityThreshold = probabilityThreshold; } if (iouThreshold > 0 && iouThreshold <= 1) { this.iouThreshold = iouThreshold; } if (!string.IsNullOrWhiteSpace(modelName)) { ModelFilename = modelName; } ModifyText($"Loading {ModelFilename}..."); #if UNITY_WSA && !UNITY_EDITOR try { TimeRecorder = Stopwatch.StartNew(); var modelFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///Data/StreamingAssets/{ModelFilename}")); var labelFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///Data/StreamingAssets/labels.txt")); var labels = await FileIO.ReadLinesAsync(labelFile); Model = new ObjectDetection(labels, maxDetections, probabilityThreshold, iouThreshold); await Model.InitAsync(modelFile); TimeRecorder.Stop(); ModifyText($"Loaded {ModelFilename} in {TimeRecorder.ElapsedMilliseconds}ms"); } catch (Exception ex) { ModifyText($"Error: {ex.Message}"); Model = null; } #endif }
// Use this for initialization void Start() { #if UNITY_UWP Task.Run(async() => { var modelFile = await StorageFile.GetFileFromApplicationUriAsync( new Uri("ms-appx:///Assets/LearningModel.onnx")); _objectDetection = new ObjectDetection(new List <string>(new[] { "AngelPie", "ChocoPie" }), 20, .3f, .45f); await _objectDetection.Init(modelFile); IsReady = true; }); #endif }
// Use this for initialization void Start() { #if UNITY_UWP Task.Run(async() => { var modelFile = await StorageFile.GetFileFromApplicationUriAsync( new Uri("ms-appx:///Assets/LearningModel.onnx")); //学習させた内容に合わせてタグは適宜変更する _objectDetection = new ObjectDetection(new List <string>(new[] { "curry", "gyoza", "meat", "pizza", "sushi" }), 20, .3f, .45f); await _objectDetection.Init(modelFile); IsReady = true; }); #endif }
private async Task LoadCurrentModelAsync(CustomVisionModelData currentProject) { try { this.deleteBtn.Visibility = currentProject.IsPrebuiltModel ? Visibility.Collapsed : Visibility.Visible; LoadSupportedClasses(currentProject); StorageFile modelFile = await GetModelFileAsync(currentProject); this.objectDetectionModel = new ObjectDetection(this.allModelObjects, probabilityThreshold: MinProbabilityValue); await this.objectDetectionModel.Init(modelFile); } catch (Exception ex) { await Util.GenericApiCallExceptionHandler(ex, "Failure loading current project"); } }
private void ProcessImage() { switch (currentStep) { case 0: this.Text = "GrayValue"; this.image = new Image(InputImage); break; case 1: this.Text = "Smoothing"; image.Apply(Operation.Operations.Smoothing); break; case 2: this.Text = "Edges + subtraction"; Image temp = new Image(image.GetPixels(), image.Size); image.Apply(Operation.Operations.Edges); //image = Addition.Apply(image, temp); image = new Image(image.GetPixels(), image.Size); image = Minval.Apply(image, temp); break; case 3: << << << < HEAD this.Text = "Opening"; image.Apply(Operation.Operations.Opening); break; case 4: this.Text = "Closing"; image.Apply(Operation.Operations.Closing); break; case 5: this.Text = "Colouring"; ObjectDetection od = new ObjectDetection(image); od.Apply(); ObjectFiltering of = new ObjectFiltering(od.objects); of.Apply(); image = new Coloring(of.coffeeMugObjectList).ConstructNewImage(image.Size); == == == = this.Text = "Negative Threshold"; image.Apply(Operation.Operations.NegativeThreshold);
private async void Instance_SDKRegistrationStateChanged(SDKRegistrationState state, SDKError errorCode) { var isReg = state == SDKRegistrationState.Succeeded && errorCode == SDKError.NO_ERROR; if (_isRunning) { return; } if (isReg) { List <String> labels = new List <String> { "Box", "Nobox" }; objectDetection = new ObjectDetection(labels, 10, 0.45F, 0.45F); await init_onnx(); var gimbal = await DJISDKManager.Instance.ComponentManager.GetGimbalHandler(0, 0).GetGimbalAttitudeAsync(); if (gimbal.value == null || gimbal.value.Value.pitch == 0) { //for (; ; ) //{ var err0r1 = DJISDKManager.Instance.ComponentManager.GetGimbalHandler(0, 0).RotateByAngleAsync(new GimbalAngleRotation { mode = GimbalAngleRotationMode.ABSOLUTE_ANGLE, pitch = -16.9, roll = 0, yaw = 0, pitchIgnored = false, rollIgnored = true, yawIgnored = true, duration = 1.0 }); // if (err0r1.Result == SDKError.NO_ERROR) // { // break; // } //} } _isRunning = true; Thread.Sleep(2000); workerThread.Start(); } }
private async void Page_Loaded(object sender, RoutedEventArgs e) { var maximumObjects = 5; //maximum number of Objects that can be detected StorageFile labelsFile = await StorageFile.GetFileFromApplicationUriAsync( new Uri("ms-appx:///Assets/labels.txt")); IList <string> data = await FileIO.ReadLinesAsync(labelsFile); List <string> labelsList = data.ToList(); od = new ObjectDetection(labelsList, maximumObjects); StorageFile modelFile = await StorageFile.GetFileFromApplicationUriAsync( new Uri("ms-appx:///Assets/model.onnx")); await od.Init(modelFile); }
/// <summary> /// Main function. /// </summary> /// <param name="args"><c>--clientSecret</c> and <c>--clientId</c> are required arguments, <c>--baseUrl</c> is optional.</param> private static void Main(string[] args) { string clientSecret, clientId, baseUrl; ProcessArguments(args, out clientSecret, out clientId, out baseUrl); try { var api = new ImagingApi(clientSecret, clientId, baseUrl); PrepareOutput(); Console.WriteLine("Running Imaging Cloud examples:"); Console.WriteLine(); // Update parameters of existing BMP image var bmpImage = new UpdateBmpImage(api); bmpImage.ModifyBmpFromStorage(); bmpImage.ModifyBmpAndUploadToStorage(); bmpImage.CreateModifiedBmpFromRequestBody(); // Crop an existing image var cropImage = new CropImage(api); cropImage.CropImageFromStorage(); cropImage.CropImageAndUploadToStorage(); cropImage.CreateCroppedImageFromRequestBody(); // Deskew an existing image var deskewImage = new DeskewImage(api); deskewImage.DeskewImageFromStorage(); deskewImage.DeskewImageAndUploadToStorage(); deskewImage.CreateDeskewedImageFromRequestBody(); // grayscale an existing image var grayscaleImage = new GrayscaleImage(api); grayscaleImage.GrayscaleImageFromStorage(); grayscaleImage.GrayscaleImageAndUploadToStorage(); grayscaleImage.CreateGrayscaledImageFromRequestBody(); // Process existing EMF imaging using given parameters var updateEmfImage = new UpdateEmfImage(api); updateEmfImage.ModifyEmfFromStorage(); updateEmfImage.ModifyEmfAndUploadToStorage(); updateEmfImage.CreateModifiedEmfFromRequestBody(); // Export existing image to another format var exportImage = new ExportImage(api); exportImage.SaveImageAsFromStorage(); exportImage.SaveImageAsAndUploadToStorage(); exportImage.CreateSavedImageAsFromRequestBody(); // Apply a filtering effect to an image var filterImage = new FilterImage(api); filterImage.FilterImageFromStorage(); filterImage.FilterImageAndUploadToStorage(); // Get properties of an image var imageProperties = new ImageProperties(api); imageProperties.GetImagePropertiesFromStorage(); imageProperties.ExtractImagePropertiesFromRequestBody(); // Resize an existing image var resizeImage = new ResizeImage(api); resizeImage.ResizeImageFromStorage(); resizeImage.ResizeImageAndUploadToStorage(); resizeImage.CreateResizedImageFromRequestBody(); // Rotate and/or flip an existing image var rotateFlipImage = new RotateFlipImage(api); rotateFlipImage.RotateFlipImageFromStorage(); rotateFlipImage.RotateFlipImageAndUploadToStorage(); rotateFlipImage.CreateRotateFlippedImageFromRequestBody(); // TIFF Frames var multiframeImage = new MultiframeImage(api); multiframeImage.GetImageFrameFromStorage(); multiframeImage.GetImageFrameAndUploadToStorage(); multiframeImage.CreateImageFrameFromRequestBody(); multiframeImage.GetImageFrameRangeFromStorage(); multiframeImage.GetImageFrameRangeAndUploadToStorage(); multiframeImage.CreateImageFrameRangeFromRequestBody(); multiframeImage.GetImageFramePropertiesFromStorage(); multiframeImage.ExtractImageFramePropertiesFromRequestBody(); // Update parameters of existing TIFF image var tiffImage = new TiffImage(api); tiffImage.ModifyTiffFromStorage(); tiffImage.ModifyTiffAndUploadToStorage(); tiffImage.CreateModifiedTiffFromRequestBody(); tiffImage.ConvertTiffToFaxFromStorage(); tiffImage.AppendTiffFromStorage(); // Update parameters of existing GIF image var updateGifImage = new UpdateGifImage(api); updateGifImage.ModifyGifFromStorage(); updateGifImage.ModifyGifAndUploadToStorage(); updateGifImage.CreateModifiedGifFromRequestBody(); // Perform scaling, cropping and flipping of an existing image in a single request var updateImage = new UpdateImage(api); updateImage.UpdateImageFromStorage(); updateImage.UpdateImageAndUploadToStorage(); updateImage.CreateUpdatedImageFromRequestBody(); // Update parameters of existing JPEG2000 image var updateJpeg2000Image = new UpdateJpeg2000Image(api); updateJpeg2000Image.ModifyJpeg2000FromStorage(); updateJpeg2000Image.ModifyJpeg2000AndUploadToStorage(); updateJpeg2000Image.CreateModifiedJpeg2000FromRequestBody(); // Update parameters of existing JPEG image var updateJpegImage = new UpdateJpegImage(api); updateJpegImage.ModifyJpegFromStorage(); updateJpegImage.ModifyJpegAndUploadToStorage(); updateJpegImage.CreateModifiedJpegFromRequestBody(); // Update parameters of existing PSD image var updatePsdImage = new UpdatePsdImage(api); updatePsdImage.ModifyPsdFromStorage(); updatePsdImage.ModifyPsdAndUploadToStorage(); updatePsdImage.CreateModifiedPsdFromRequestBody(); // Update parameters of existing WEBP image var webpImage = new UpdateWebPImage(api); webpImage.ModifyWebPFromStorage(); webpImage.ModifyWebPAndUploadToStorage(); webpImage.CreateModifiedWebPFromRequestBody(); // Process existing WMF image using given parameters var wmfImage = new UpdateWmfImage(api); wmfImage.ModifyWmfFromStorage(); wmfImage.ModifyWmfAndUploadToStorage(); wmfImage.CreateModifiedWmfFromRequestBody(); // AI APIs Console.WriteLine("Running AI examples:"); Console.WriteLine(); // Compare two images var compareImages = new CompareImages(api); compareImages.PrepareSearchContext(); compareImages.CompareTwoImagesInCloud(); compareImages.CompareLoadedImageToImageInCloud(); compareImages.DeleteSearchContext(); // Find Duplicate Images var findDuplicateImages = new FindDuplicateImages(api); findDuplicateImages.PrepareSearchContext(); findDuplicateImages.FindImageDuplicates(); findDuplicateImages.DeleteSearchContext(); // Find Similar Images var findImages = new FindSimilarImages(api); findImages.PrepareSearchContext(); findImages.FindImagesSimilar(); findImages.FindImagesByTag(); findImages.SearchImageFromWebSource(); findImages.DeleteSearchContext(); //object detection var objectDetection = new ObjectDetection(api); objectDetection.DetectObjectsImageFromStorage(); objectDetection.DetectedObjectsImageFromRequestBody(); objectDetection.VisualiizeDetectObjectsAndUploadToStorage(); objectDetection.VisualizeDetectedObjectsImageFromRequestBody(); // custom fonts var customFonts = new LoadCustomFonts(api); customFonts.UsingCustomFontsForVectorImageConversion(); } catch (Exception ex) { Console.WriteLine($"Something goes wrong: {ex}"); Environment.Exit(1); } Environment.Exit(0); }
static void Main(string[] args) { ObjectDetection objectDetection = new ObjectDetection("assets/images", "assets/images/output"); objectDetection.Detect(); }
private async void InitModel() { _objectDetection = new ObjectDetection(); await _objectDetection.Init(); }
public async Task SendAndSaveNotifications(IEnumerable <UplinkMessage> uplinkMessageEnumerable) { List <UplinkMessage> uplinkMessages = uplinkMessageEnumerable.ToList(); List <Notification> notifications = uplinkMessages.Select(async uplinkMessage => { NotificationType notificationType; ObjectDetectionNotification objectDetectionNotification = null; if (uplinkMessage.Data.Length == 0) { notificationType = NotificationType.Heartbeat; } else { notificationType = NotificationType.ObjectDetection; ushort?widthCentimeters = ushort.Parse(uplinkMessage.Data, NumberStyles.HexNumber); ObjectDetection objectDetection = widthCentimeters switch { 0 => ObjectDetection.Removed, ushort.MaxValue => ObjectDetection.Detected, _ => ObjectDetection.DetectedWithSize }; if (objectDetection != ObjectDetection.DetectedWithSize) { widthCentimeters = null; } objectDetectionNotification = new ObjectDetectionNotification { ObjectDetection = objectDetection, WidthCentimeters = widthCentimeters, SentToKommune = false }; } string address = (await _storage.GetDevice(uplinkMessage.DeviceEui))?.Address ?? ""; return(new Notification { Address = address, Timestamp = uplinkMessage.Timestamp, Type = notificationType, DeviceEui = uplinkMessage.DeviceEui, ObjectDetectionNotification = objectDetectionNotification }); }) .Select(task => task.Result) .ToList(); _logger.LogInformation("Saving notifications: " + JsonSerializer.Serialize(notifications)); await _storage.AddNotifications(notifications); List <NotificationToKommune> notificationsToKommune = DetectionSystemServiceUtil.NotificationsToKommuneNotifications(notifications); try { await _kommuneService.SendNotifications(notificationsToKommune); foreach (Notification notification in notifications) { notification.ObjectDetectionNotification.SentToKommune = true; } } catch (Exception e) { _logger.LogWarning("Kommune communication exception", e); foreach (Notification notification in notifications) { notification.ObjectDetectionNotification.SentToKommune = false; } } }
void Start() { playerCam = Camera.main.GetComponent <ThirdPersonCamera>(); playerMove = GetComponent <PlayerMove>(); objectDetection = GetComponent <ObjectDetection>(); }
void Start() { characterController = GetComponent <CharacterController>(); objectDetection = GetComponent <ObjectDetection>(); holder = GetComponent <Holder>(); }