opencv + java face recongnition code

asked 2019-05-15 12:32:20 -0500

susara gravatar image

hello friends i have done face recognition using java + open cv . my question is how to print distance variable only ??

while (runnable) {
                    if (webSource.grab()) {
                        try {
                            webSource.retrieve(frame);
                            Graphics g = jPanel1.getGraphics();
                            faceDetector.detectMultiScale(frame, faceDetections);
                            BufferedImage buff = null;
                            Rect rect_Crop = null;
                            for (Rect rect : faceDetections.toArray()) {
                                Core.rectangle(frame, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height),
                                new Scalar(0, 255, 0));
                                rect_Crop = new Rect(rect.x, rect.y, 200, 200);
                            }
                            Highgui.imencode(".bmp", frame, mem);
                            Image im = ImageIO.read(new ByteArrayInputStream(mem.toArray()));

                            buff = (BufferedImage) im;
                            Mat image_roi = null;
                            fileNameWithMaxValueOnly = null;
                            if (rect_Crop != null) {
                                image_roi = new Mat(frame, rect_Crop);
                                //fileNameWithMaxValueOnly = RecgonizeNewData.RecgonizeNewDataBufferedImage(ImpageCropping.MatToBufferedImage(image_roi));
                                DetectAndRecognize.this.setFileNameWithMaxValueOnly(RecgonizeNewData.RecgonizeNewDataBufferedImage(ImpageCropping.MatToBufferedImage(image_roi)));

                                //System.out.println(RecgonizeNewData.RecgonizeNewDataBufferedImage(ImpageCropping.MatToBufferedImage(image_roi)));

                                System.out.println("fileNameWithMaxValueOnly" + fileNameWithMaxValueOnly);
                            }

                            if (g.drawImage(buff, 0, 0, getWidth(), getHeight() - 150, 0, 0, buff.getWidth(), buff.getHeight(), null)) {
                                if (runnable == false) {
                                    System.out.println("Paused ..... ");

                                    this.wait();

                                }
                            }

// log result like this

Using cache: C:\eigenfacesCash\eigen.cache
Number of matching eigenfaces must be in the range (1-12); using 9
Matches image in C:\Imgs\1.png; distance = 0.5228

my question is how to print distance variable only.

edit retag flag offensive close merge delete

Comments

sorry for the downvote, but your code does neither show any distance calculation or printing

berak gravatar imageberak ( 2019-05-16 07:12:21 -0500 )edit

yes. but it will print. thats the problem. i think it come from opencv c++ file. how can i find it.

susara gravatar imagesusara ( 2019-05-16 07:16:58 -0500 )edit

then can you tell me how can i change the eigenface to fisher face. ? in my code i cannot fined such configuration file ???

susara gravatar imagesusara ( 2019-05-16 07:25:46 -0500 )edit