private void tsBtn_Click(object sender, EventArgs e) { ImageProcessType sType = ImageProcessType.File; ToolStripMenuItem item = (ToolStripMenuItem)sender; if (item.Text == "Live") { sType = ImageProcessType.Live; } PlateRecognitionSystemForm f = new PlateRecognitionSystemForm { imageProcessType = sType }; ShowForm(f); }
public void GetImageAndProcess(ImageProcessType sType) { string _imgpath = photopath; Mat _img = null; switch (sType) { case ImageProcessType.Live: Image <Bgr, Byte> new_img = new Image <Bgr, Byte>(_livePhoto); _img = new_img.Mat; break; case ImageProcessType.File: OpenFileDialog dialog = new OpenFileDialog(); dialog.Title = "Select a Image"; dialog.Filter = "jpg files (*.jpg)|*.jpg|All files (*.*)|*.*"; if (dialog.ShowDialog() == DialogResult.OK) { _imgpath = dialog.FileName; pbOrginal.ImageLocation = _imgpath; _img = CvInvoke.Imread(_imgpath, LoadImageType.Color); } break; default: MessageBox.Show("An unexpected error has occurred!"); break; } try { if (_img != null) { ImageProcess(_img); } } catch (Exception ex) { _timer.Enabled = false; MessageBox.Show(ex.Message + " !"); } }
public async Task <IList <FileModel> > SaveImageAsync(IEnumerable <HttpPostedFileBase> files, string path = null, ImageProcessType imageType = ImageProcessType.Nan) { var fileList = new List <FileModel>(); if (files == null) { return(fileList); } foreach (var file in files) { if (imageType == ImageProcessType.Attachment) { var validationFormat = await _imageValidation.GetFormatAttachment(file); if (validationFormat != null) { throw new ArgumentNullException(nameof(validationFormat)); } } else { var validationFormat = await _imageValidation.GetFormatImage(file); if (validationFormat != null) { throw new ArgumentNullException(nameof(validationFormat)); } } if (path == null) { path = FileConst.ImagesWebPath; } var fileSaved = new FileModel() { Id = SequentialGuidGenerator.NewSequentialGuid(), Name = SequentialGuidGenerator.NewSequentialGuid() + Path.GetExtension(file.FileName), Type = FileConst.FileType, Extension = Path.GetExtension(file.FileName), Size = file.ContentLength, Path = path }; var byteFile = await ConvertToByteArrayAsync(file); var pathToSave = Path.Combine(path, fileSaved.Name); await CreateFileAsync(byteFile, fileSaved.Name, path); if (imageType != ImageProcessType.Attachment) { var thumbPath = HttpContext.Current.Server.MapPath(FileConst.ThumbPath); var pathThumbToSave = Path.Combine(thumbPath, fileSaved.Name); } fileList.Add(fileSaved); switch (imageType) { case ImageProcessType.ProductImage: await _imageBuilder.ProductImageProcessAsync(pathToSave); break; case ImageProcessType.CompanyCoverFileName: await _imageBuilder.CompanyCoverFileProcessAsync(pathToSave); break; case ImageProcessType.LogoFileName: await _imageBuilder.LogoProcessAsync(pathToSave); break; case ImageProcessType.CompanyImages: await _imageBuilder.CompanyImagesFileProcessAsync(pathToSave); break; case ImageProcessType.ProductImages: await _imageBuilder.ProductImageProcessAsync(pathToSave); break; } } return(fileList); }