public void UseImageTest1() { Bitmap bmp = new Bitmap(200, 200); var cCell = _IImageWorker.UseImage(bmp, 10); Assert.Equal(4, cCell); Assert.Equal(cCell * cCell, _IImageWorker.Count()); }
/// <summary> /// [NOT CONNECTED TO RECOGNIZE MODULE] Split image on cells and send it to recognize /// </summary> /// <param name="model">Images to recognize</param> /// <returns>Object`s in cells</returns> public async Task <RecognizeResultViewModel[, ]> StartRecognize(RecognizeViewModel model) { var imgUrl = model.SatelliteURL .Remove(0, model.SatelliteURL.LastIndexOf("/images/")) .Replace("/", "\\"); var img = await _applicationDbContext.Images .SingleOrDefaultAsync(a => a.URL == imgUrl); if (img != null) { var count = _imageWorkerService .UseImage(Image.FromFile(_env.WebRootPath + imgUrl), img.Scale); var cellsPath = _fileService .GetNextFilesPath(_imageWorkerService.Count(), DirectoryType.Recognize); int i = 0; var retMatrix = new RecognizeResultViewModel[count, count]; img.Cells = new List <Models.CellDB>(); foreach (var cell in _imageWorkerService) { cell.CellImage.Save(cellsPath[i]); //Send to recognize and mark image img.Cells.Add(new Models.CellDB { URL = cellsPath[i] // Add aditional recognized data }); //Replace to recognized retMatrix[cell.X, cell.Y] = new RecognizeResultViewModel { Class = "Not Recognized", Height = 0, CellURL = cellsPath[i].Remove(0, cellsPath[i].LastIndexOf("\\images\\")) }; i++; } await _applicationDbContext.SaveChangesAsync(); return(retMatrix); } return(null); }