void UploadSamplesToStation() { try { FolderBrowserDialog selectPicturesFolderDialog = new FolderBrowserDialog(); selectPicturesFolderDialog.ShowNewFolderButton = false; if (selectPicturesFolderDialog.ShowDialog() == DialogResult.OK) { foreach (string jpg in Directory.GetFiles(selectPicturesFolderDialog.SelectedPath, "*.jpg")) { Sample nextSample = new Sample(_currentStation.Lat, _currentStation.Lon, jpg); //OCR template for presure in inHg OCR_Template ocrPres = new OCR_Template("ocrPres", "Moultrie Game Camera", new Rectangle(71, 2018, 225, 96), new Size(2848, 2136)); //OCR template for temp in ºC OCR_Template ocrTemp = new OCR_Template("ocrTemp", "Moultrie Game Camera", new Rectangle(847, 2024, 196, 111), new Size(2848, 2136)); nextSample.OCR_Observations_list.Add(new DoubleObservation("Pressure (inHg)", "", ocrPres)); nextSample.OCR_Observations_list.Add(new IntegerObservation("Temperature (ºC)", "", ocrTemp)); nextSample.Species_Observations_list.Add(new SpeciesObservation("Species", "Pending", 0)); nextSample.RunOCR(nextSample.OCR_Observations_list); Image nextImage = Image.FromFile(jpg); foreach (Station st in _currentProject.StationsList) { if (st.Guid == _currentStation.Guid) { st.SamplesList.Add(nextSample); } } ProjectDAO.InsertImage(_currentProject.Name, nextSample.Guid, ConversionUtilities.ImageToBase64(Main_processing.ResizeImage(nextImage), System.Drawing.Imaging.ImageFormat.Jpeg)); } ProjectDAO.UpdateProject(_currentProject.Name, _currentProject); } } catch (Exception ex) { throw ex; } }
void SelectStationImage() { try { if (tvProject.SelectedNode.Tag.GetType() == _currentStation.GetType()) { OpenFileDialog selectMainPictureDialog = new OpenFileDialog(); selectMainPictureDialog.Filter = "Jpeg files (*.jpg)|*.jpg|All files (*.*)|*.*"; selectMainPictureDialog.Title = "Select the main picture"; if (selectMainPictureDialog.ShowDialog() == DialogResult.OK) { ProjectDAO.InsertImage(_currentProject.Name, _currentStation.Guid, ConversionUtilities.ImageToBase64(Main_processing.ResizeImage(Image.FromFile(selectMainPictureDialog.FileName)), System.Drawing.Imaging.ImageFormat.Jpeg)); _currentStation.MetadataFromImage(selectMainPictureDialog.FileName); pictureBox1.Image = CameratrapManager_db.ProjectDAO.GetCurrentImage(_currentProject.Name, _currentStation.Guid); ProjectDAO.UpdateProject(_currentProject.Name, _currentProject); //Must solve the update node after select station image // UpdateCurrentNodeTree(); refreshViewData(_currentStation); } else { MessageBox.Show("You must select a Station node"); } } } catch (Exception ex) { throw ex; } }