Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("carPlateId,carPlateNumber")] CarPlate carPlate)
        {
            if (id != carPlate.carPlateId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(carPlate);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CarPlateExists(carPlate.carPlateId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(carPlate));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("carPlateId,carPlateNumber")] CarPlate carPlate)
        {
            if (ModelState.IsValid)
            {
                _context.Add(carPlate);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(carPlate));
        }
Exemplo n.º 3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //khởi tạo đối tượng
            //Init class
            IPSScar detector = new IPSScar();

            //CÁC OPTION

            //đường dẫn chứa file output, nếu set null hoặc rỗng thì sẽ không save ảnh output
            //set output dir, if output dir is null or empty engine will not save output image
            detector.OutputFoler = @"D:\Result";


            //engine nhận tham số là ảnh hoặc đường dẫn đến ảnh
            //you can set input pameter is bitmap or image path
            CarPlate result = detector.ReadPlate(@"Test98.JPG");

            //kết quả trả về là class IPSSresult gồm nhiều thuộc tính
            //text là các ký tự biển số
            //result is a class contain some values
            //.text is plate character
            label1.Text = result.text;

            //bitmap là hình ảnh kết quả
            //bimap is image has returned
            Bitmap bmp = result.bitmap;

            pictureBox1.Image = bmp;

            //thời gian xử lý
            //elapsed time read plate
            int ms = result.elapsedMilisecond;

            //mã lỗi (nếu có)
            //error code to diagnostic
            string error = result.error;

            //nếu có biển số giá trị là true
            //.hasPlate is true when found plate in image
            bool hasPlate = result.hasPlate;

            //nếu đọc đủ các ký tự thì kết quả là true
            //.isValid is true when read enough character
            bool isValid = result.isValid;

            //biển số vuông hay biển số dài
            //.type is long or short plate
            label2.Text = result.type.ToString();
        }
Exemplo n.º 4
0
        public async Task <IActionResult> SubmitFeedback(FeedbackViewModel input)
        {
            //getting existing carplate from the database.
            var myCarPlate = await _context.CarPlate
                             .FirstOrDefaultAsync(m => m.PlateNumber == input.PlateNumber);

            //if the carplate number is not in the database
            if (myCarPlate == null)
            {
                var carPlate = new CarPlate {
                    PlateNumber = input.PlateNumber
                };
                _context.Add(carPlate);
                _context.SaveChanges();

                myCarPlate = await _context.CarPlate
                             .FirstOrDefaultAsync(m => m.PlateNumber == carPlate.PlateNumber);
            }
            //getting the badge from the database
            var myBadge = await _context.Badge
                          .FirstOrDefaultAsync(m => m.Id == input.BadgeId);

            //creating a new feedback
            var feedback = new Feedback
            {
                BadgeId    = myBadge.Id,
                CarPlateId = myCarPlate.Id,
                Created    = DateTime.Now
            };

            //saving feedback to db
            _context.Add(feedback);
            await _context.SaveChangesAsync();

            ViewBag.Success = $"Thank you! Your feedback for number {feedback.CarPlate.PlateNumber} was added with Success!";

            return(View("Index"));
        }
Exemplo n.º 5
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////

        private void bgWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            string inputPath = "";

            if (txtFolderInput.Text != "")
            {
                inputPath = TGMTutil.CorrectPath(txtFolderInput.Text);
            }
            string failedDir = "";

            if (txtFailedDir.Text != "")
            {
                failedDir = TGMTutil.CorrectPath(txtFailedDir.Text);
            }

            string validDir = "";

            if (txtValidDir.Text != "")
            {
                validDir = TGMTutil.CorrectPath(txtValidDir.Text);
            }

            string invalidDir = "";

            if (txtInvalidDir.Text != "")
            {
                invalidDir = TGMTutil.CorrectPath(txtInvalidDir.Text);
            }

            int    exactlyCount = 0;
            string content      = "";

            for (int i = 0; i < lstImage.Items.Count; i++)
            {
                if (bgWorker1.CancellationPending)
                {
                    return;
                }
                bgWorker1.ReportProgress(i + 1);

                carDetector.OutputFileName = lstImage.Items[i].Text;

                string filePath = inputPath + lstImage.Items[i].Text;
                string ext      = filePath.Substring(filePath.Length - 4).ToLower();
                content += Path.GetFileName(filePath) + ",";

                if (ext != ".jpg" && ext != ".png" && ext != ".bmp")
                {
                    continue;
                }
                PrintMessage(i + " / " + lstImage.Items.Count + " " + filePath);

                CarPlate result = carDetector.ReadPlate(filePath);

                if (result.hasPlate)
                {
                    if (lstImage.Items[i].SubItems.Count == 1)
                    {
                        lstImage.Items[i].SubItems.Add(result.text);
                        lstImage.Items[i].SubItems.Add(GetPlateType(result.type));
                    }
                    else
                    {
                        lstImage.Items[i].SubItems[1].Text = result.text;
                        lstImage.Items[i].SubItems[2].Text = GetPlateType(result.type);
                    }
                    lstImage.Items[i].ForeColor = result.isValid ? Color.Blue : Color.Black;
                    content += "x,";

                    if (result.isValid)
                    {
                        exactlyCount++;
                        if (chkMoveValid.Checked)
                        {
                            Task.Run(() => File.Move(inputPath + lstImage.Items[i].Text, validDir + lstImage.Items[i].Text));
                        }
                    }
                    else
                    {
                        if (chkMoveInvalid.Checked)
                        {
                            Task.Run(() => File.Move(inputPath + lstImage.Items[i].Text, invalidDir + lstImage.Items[i].Text));
                        }
                    }
                }
                else
                {
                    if (lstImage.Items[i].SubItems.Count == 1)
                    {
                        lstImage.Items[i].SubItems.Add(result.error);
                    }
                    else
                    {
                        lstImage.Items[i].SubItems[1].Text = result.error;
                    }
                    if (chkMoveFail.Checked)
                    {
                        Task.Run(() => File.Move(inputPath + lstImage.Items[i].Text, failedDir + lstImage.Items[i].Text));
                    }
                    lstImage.Items[i].ForeColor = Color.Red;
                    content += ",";
                }

                content += result.text;


                result.Dispose();
                content += "\r\n";

                lstImage.EnsureVisible(i);
            }

            if (inputPath != "")
            {
                File.WriteAllText(Path.GetDirectoryName(inputPath) + "\\_report.csv", content);
            }
        }
Exemplo n.º 6
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////

        void ReadPlate()
        {
            if (!rdCamera.Checked && !rdImage.Checked && !rdFolder.Checked)
            {
                PrintError("Source image not selected");
                return;
            }

            if (carDetector == null)
            {
                MessageBox.Show("Please contact to author to fix problem");
                return;
            }

            carDetector.OutputFoler = txtFolderOutput.Text;

            if (rdCamera.Checked) //camera
            {
                if (rdNetworkCamera.Checked)
                {
                    if (streamPlayer.IsPlaying)
                    {
                        g_bmp = streamPlayer.GetCurrentFrame();
                    }
                }
                if (g_bmp == null)
                {
                    PrintError("Image is null");
                    return;
                }

                Bitmap bmp = (Bitmap)g_bmp.Clone();
                if (bmp == null)
                {
                    return;
                }


                CarPlate result = carDetector.ReadPlate(bmp);
                if (result.bitmap != null)
                {
                    picResult.Image = result.bitmap;
                }

                txtResult.Text = result.text;
                PrintMessage(result.error + " (" + result.elapsedMilisecond.ToString() + " ms)");
            }
            else if (rdImage.Checked) //static image
            {
                if (g_bmp == null)
                {
                    PrintError("Image is null");
                    return;
                }
                picResult.Image = null;
                CarPlate result = carDetector.ReadPlate((Bitmap)g_bmp.Clone());
                txtResult.Text = result.text;

                if (result.bitmap != null)
                {
                    picResult.Image = result.bitmap;
                }
                PrintMessage(result.error + " (" + result.elapsedMilisecond + " ms)");
            }
            else if (rdFolder.Checked) //folder
            {
                if (btnDetect.Text == "Start detect (F5)")
                {
                    if (txtFolderOutput.Text == "")
                    {
                        errorProvider1.SetError(txtFolderOutput, "Folder output is empty");
                        return;
                    }

                    if (txtFolderInput.Text == txtFolderOutput.Text && txtFolderOutput.Text != "")
                    {
                        errorProvider1.SetError(txtFolderOutput, "Folder output must different folder input");
                        return;
                    }
                    if (lstImage.Items.Count == 0)
                    {
                        PrintError("No input image");
                        return;
                    }

                    g_scaleX             = 1;
                    g_scaleY             = 1;
                    progressBar1.Visible = true;
                    timerProgressbar.Start();
                    bgWorker1.RunWorkerAsync();

                    btnDetect.Text = "Stop detect (F5)";
                }
                else
                {
                    bgWorker1.CancelAsync();
                    btnDetect.Text = "Start detect (F5)";
                }
            }
        }