How i can create Java Eye Rect?

asked 2018-06-12 03:15:47 -0500

Fascal gravatar image

/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package ekspresi_wajah;

import java.io.File; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import javax.swing.ImageIcon; import javax.swing.JFileChooser; import javax.swing.filechooser.FileNameExtensionFilter; import static ekspresi_wajah.fungsi.*; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; import org.opencv.core.Mat; import org.opencv.core.MatOfRect; import org.opencv.core.Point; import org.opencv.core.Rect; import org.opencv.core.Size; import org.opencv.highgui.Highgui; import org.opencv.imgproc.Imgproc; import org.opencv.objdetect.CascadeClassifier;

public class forminputLatih extends javax.swing.JFrame {

public static final String dirWajah = "lib/haarcascade_frontalface_alt.xml";
public static final String dirHidung = "lib/haarcascade_mcs_nose.xml";
public static final String dirMata = "lib/haarcascade_mcs_lefteye.xml";
String tempImage = "";
ImageIcon gambarAsli;
BufferedImage imageAll;
BufferedImage faceImage;
int imageWidth;
int imageHeight;
int xface;
int yface;
int heightface;
int widthface;
int ynose;
int xnose;
int widthnose;
int heightnose;
int yeye;
int xeye;
int widtheye;
int heighteye;
Rect faceRect;
Rect noseRect;
Rect eyeRect;

public forminputLatih() {
    initComponents();
}

@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">                          
private void initComponents() {

    btnBrowseImage = new javax.swing.JButton();
    setGambar = new javax.swing.JLabel();
    setlDeteksiObjek = new javax.swing.JLabel();
    labelNama = new javax.swing.JLabel();
    labelDeteksiObjek = new javax.swing.JLabel();
    btnClose = new javax.swing.JButton();
    jButton1 = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("Menu Latih");

    btnBrowseImage.setText("Browse");
    btnBrowseImage.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnBrowseImageActionPerformed(evt);
        }
    });

    setGambar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

    setlDeteksiObjek.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

    labelNama.setText("Gambar Asli");

    labelDeteksiObjek.setText("Deteksi Wajah");

    btnClose.setText("Tutup");
    btnClose.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnCloseActionPerformed(evt);
        }
    });

    jButton1.setLabel("DeteksiWajah");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addGap(50, 50, 50)
                            .addComponent(labelNama)
                            .addGap(78, 78, 78)
                            .addComponent(labelDeteksiObjek))
                        .addGroup(layout.createSequentialGroup()
                            .addGap(14, 14, 14)
                            .addComponent(setGambar, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                    .addGap(10, 10, 10)
                                    .addComponent(jButton1))
                                .addComponent(setlDeteksiObjek, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGap(298, 298, 298))
                .addGroup(layout.createSequentialGroup()
                    .addComponent(btnBrowseImage)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnClose)
                    .addContainerGap())))
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addGap(7, 7, 7)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(btnBrowseImage)
                .addComponent(btnClose))
            .addGap(18 ...
(more)
edit retag flag offensive close merge delete