Пример #1
0
    //Match features from canvas
    public IEnumerator MatchFeatures()
    {
        ImageString image;
        GameObject  instantiatedWait = Instantiate(wait, screenshotPreview.transform);

        //Pick the pixels inside the square
        ImagePartToByteArray();

        //Get imageList
        yield return(imageList.GetTextFromURL());

        Debug.Log("Image list count: " + imageList.getImageList().Count);

        //Don't match features if no images is on the canvas
        if (imageList.getImageList().Count == 0)
        {
            image = new ImageString(Convert.ToBase64String(imagePart), -1);
        }
        // Match feature from images on canvas.
        else
        {
            image = featureMatcher.MatchFeatures(Convert.ToBase64String(imagePart), imageList.getImageList());
        }
        Destroy(instantiatedWait);
        UploadToInAppBrowser(image.getImageString(), image.getWinnerIndex());
    }
Пример #2
0
        public async Task <FileContentResult> Get(ImageString image)
        {
            if (hoststring == "")
            {
                hoststring = HttpContext.Request.Host.Value;
            }
            Image _image = _imageService.GetById(image.ImageKey, image.Username);

            return(File(_image.bytes, "image/jpeg", _image.Name + ".jpg"));
        }
Пример #3
0
 public void Post([FromBody] ImageString value)
 {
     Debug.WriteLine("POST COUNT = " + value.base64.Count);
     foreach (var item in value.base64)
     {
         CurrTasks.Enqueue(item);
         //Task.Run(() => handleAsyncCalls(item));
     }
     if (!IsInProcess)
     {
         ContinueOrStartProcess();
     }
     //return Redirect("Photo");
 }
Пример #4
0
        public void StartClickHandler(object sender, RoutedEventArgs e)
        {
            Classes.Clear();

            foreach (string pathImage in Directory.GetFiles(path).Where(s => s.EndsWith(".JPEG") || s.EndsWith(".jpg")))
            {
                ImageString obj = new ImageString()
                {
                    path        = pathImage,
                    ImageBase64 = ImageToBase64(new Avalonia.Media.Imaging.Bitmap(pathImage)),
                    Probability = 0,
                    ClassImage  = "Default"
                };
                Thread t = new Thread(new ParameterizedThreadStart(Post));
                t.Start(obj);
            }
        }
        public ResultClassification Post([FromBody] ImageString obj)
        {
            ResultClassification result;

            OnnxClassifier.OnnxClassifier onnxModel;

            using (var db = new ApplicationContext())
            {
                result = db.FindInDataBase(obj);
                if (result != null)
                {
                    return(result);
                }
                onnxModel = new OnnxClassifier.OnnxClassifier();
                result    = onnxModel.PredictModel(obj.path);

                obj.path        = result._PathImage;
                obj.Probability = result._Probability;
                obj.ClassImage  = result._ClassImage;
                db.AddToDataBase(obj);
            }
            return(result);
        }
Пример #6
0
            public ResultClassification FindInDataBase(ImageString obj)
            {
                byte[] array = Convert.FromBase64String(obj.ImageBase64);

                lock (this)
                {
                    var images = this.Images.Where(p => p.Hash == GetHashFromBytes(array)).Select(p => p).ToList();
                    foreach (var img in images)
                    {
                        this.Entry(img).Reference(p => p.ImageBytes).Load();
                        if (array.SequenceEqual(img.ImageBytes.Bytes))
                        {
                            img.Call += 1;
                            this.SaveChanges();
                            return(new ResultClassification(img.Path, img.Class, img.Prob));
                        }
                    }
                }

                Console.WriteLine("NOT_FOUND");

                return(null);
            }
Пример #7
0
            public void AddToDataBase(ImageString obj)
            {
                lock (this)
                {
                    byte[] BytesImage = Convert.FromBase64String(obj.ImageBase64);
                    Blob   ImageBlob  = new Blob {
                        Bytes = BytesImage
                    };
                    this.Blobs.Add(ImageBlob);
                    this.SaveChanges();

                    RecognitionImage elem = new RecognitionImage
                    {
                        Class      = obj.ClassImage,
                        Prob       = obj.Probability,
                        ImageBytes = ImageBlob,
                        Call       = 0,
                        Hash       = GetHashFromBytes(BytesImage),
                        Path       = obj.path
                    };
                    this.Images.Add(elem);
                    this.SaveChanges();
                }
            }