private void test() { Image <Gray, byte> testImage = new Image <Gray, byte>("E:/Images/tmp.jpg"); result = Eigen_Recog.Recognise(testImage); distance = Eigen_Recog.Get_Eigen_Distance; textBox1.Text = result; textBox2.Text = distance.ToString(); imageBox7.Image = testImage; imageBox1.Image = db.getResultImage(result); }
private void runAR(string nameID) { Rectangle drawArea = new Rectangle(framePoint, frameSize); Rectangle drawArea2 = new Rectangle(new Point(framePoint.X + 15, framePoint.Y + 15), new Size(140, 175)); Image <Bgr, Byte> opacityOverlay = new Image <Bgr, Byte>(drawArea.Width, drawArea.Height, new Bgr(Color.Black)); drawFrame.ROI = drawArea; opacityOverlay.CopyTo(drawFrame); drawFrame.ROI = Rectangle.Empty; double alpha = 0.7; double beta = 1 - alpha; double gamma = 0; drawFrame.Draw(drawArea, new Bgr(Color.Black), 2); drawFrame = imageFrame.AddWeighted(drawFrame, alpha, beta, gamma); drawFrame.Draw(drawArea, new Bgr(Color.LimeGreen), 2); ////***********TEXT*********** if (!ARDisplayFlag) { if (!nameID.Equals("0")) { txtAR = mydb.getUserData(nameID); } else { txtAR = "Can not recognize any face"; } Console.WriteLine("loop"); } Console.WriteLine(txtAR + " " + nameID); //txtAR = "abc def ghi"; int tmpY = framePoint.Y; if (!nameID.Equals("0")) { string[] txtSet = txtAR.Split(' '); for (int i = 0; i < txtSet.Length + 1; i++) { switch (i) { case 0: drawFrame.Draw(" User ID: " + txtSet[i], ref font, new Point(framePoint.X + 170, tmpY + 30), new Bgr(Color.LawnGreen)); label9.Text = "User ID: " + txtSet[i]; tmpY += 30; break; case 1: drawFrame.Draw(" Name: " + txtSet[i], ref font, new Point(framePoint.X + 170, tmpY + 30), new Bgr(Color.LawnGreen)); label4.Text = "Name: " + txtSet[i]; tmpY += 30; break; case 2: drawFrame.Draw(" Surname: " + txtSet[i], ref font, new Point(framePoint.X + 170, tmpY + 30), new Bgr(Color.LawnGreen)); label5.Text = "Surname: " + txtSet[i]; tmpY += 30; break; case 3: drawFrame.Draw(" Birthdate: " + txtSet[i], ref font, new Point(framePoint.X + 170, tmpY + 30), new Bgr(Color.LawnGreen)); label7.Text = "Birthdate: " + txtSet[i]; tmpY += 30; break; case 4: break; case 5: drawFrame.Draw("Blood group: " + txtSet[i], ref font, new Point(framePoint.X + 170, tmpY + 30), new Bgr(Color.LawnGreen)); label6.Text = "Blood group: " + txtSet[i]; tmpY += 30; break; case 6: drawFrame.Draw(" Gender: " + txtSet[i], ref font, new Point(framePoint.X + 170, tmpY + 30), new Bgr(Color.LawnGreen)); label8.Text = "Gender: " + txtSet[i]; tmpY += 30; break; case 7: drawFrame.Draw(" Confident: " + Math.Round(confident, 2), ref font, new Point(framePoint.X + 170, tmpY + 30), new Bgr(Color.LawnGreen)); tmpY += 30; break; default: break; } } } else { string txtSet = txtAR; label4.Text = ""; label5.Text = ""; label6.Text = ""; label7.Text = ""; label8.Text = ""; label9.Text = ""; drawFrame.Draw(txtSet, ref font, new Point(framePoint.X + 170, tmpY + 30), new Bgr(Color.LawnGreen)); } ////***********Picture*********** if (!ARDisplayFlag) { imgAR = mydb.getResultImage(name); } Image <Bgr, Byte> imageSrc = imgAR.Convert <Bgr, byte>(); drawFrame.ROI = drawArea2; CvInvoke.cvCopy(imageSrc, drawFrame, IntPtr.Zero); drawFrame.ROI = Rectangle.Empty; ARDisplayFlag = true; }