Search image by train subfloders - Face Recognition Project

Hi,
My project is face recognition.i want search a image by train subfloders.i have attached my coding.In where i have to modify to that code(searching a image in train subfloder)

import java.lang.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
 
class MyFaceRecog extends JFrame implements ActionListener
{
JFrame frmMain=new JFrame("Dictionary-based Face Recognition");
JLabel lblTestPath=new JLabel("Input Test Image:");
JTextField txtTestPath=new JTextField("");
JButton btRecognize=new JButton("Recognize");
JButton bt = new JButton("select file");
JLabel lblResult=new JLabel("Result:");
JFrame frmImage2=new JFrame("Matched Image");
JTextArea txtResult=new JTextArea("");
JScrollPane spResult=new JScrollPane(txtResult);
JFrame frmImage1=new JFrame("Input Image");
JFileChooser chooser = new JFileChooser();
String loc;
int MaxFaceIndex=17;
double DifferenceThreshold=15000.0;
int NumFaces;
int MaxFaces=100;
int FaceTemplate[][];
String fac;
int Faces[][][];
String[] a;
 
int LaplacianFaces[][][];
String FaceFileNames[];
String tResult="";
public MyFaceRecog()
{
frmMain.setDefaultLookAndFeelDecorated(true);
frmMain.setResizable(false);
frmMain.setSize(600, 400);
frmMain.getContentPane().setLayout(null);
lblTestPath.setBounds(17,15,100,20);
frmMain.getContentPane().add(lblTestPath,BorderLayout.WEST);
txtTestPath.setBounds(15,35,170,20);
frmMain.getContentPane().add(txtTestPath, BorderLayout.AFTER_LAST_LINE);
lblResult.setBounds(17,65,100,20);
frmMain.getContentPane().add(lblResult);
spResult.setBounds(15,85,280,120);
frmMain.getContentPane().add(spResult);
txtResult.setEditable(false);
btRecognize.setBounds(193,35,100,20);
btRecognize.addActionListener(this);
bt.setBounds(400, 35, 100, 20);
bt.addActionListener(this);
frmMain.getContentPane().add(btRecognize);
frmMain.getContentPane().add(bt);
frmImage1.setDefaultLookAndFeelDecorated(true);
frmImage1.setResizable(false);
frmImage1.setBounds(450,100,200,150);
frmImage2.setDefaultLookAndFeelDecorated(true);
frmImage2.setResizable(false);
frmImage2.setBounds(670,100,200,150);
frmImage1.setVisible(true);
frmImage2.setVisible(true);
frmMain.setVisible(true);
}
 
 
public void actionPerformed(ActionEvent evt)
{
 
if(evt.getSource()==bt)
{
int returnVal = chooser.showOpenDialog(MyFaceRecog.this);
 
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
loc=file.getPath();
System.out.println("Loc is "+loc);
txtTestPath.setText(loc);
 
}
}
if(evt.getSource()==btRecognize)
{
System.out.println("Inside If");
if(new File(txtTestPath.getText()).exists()==false)
{
JOptionPane.showMessageDialog(null,"Test Image, not found.");
return;
}
 
drawImage(frmImage1.getGraphics(),txtTestPath.getText());
 
tResult="";
txtResult.setText(tResult);
train();
test();
}
 
}
 
void drawImage(Graphics g,String tPath)
{
PGM tpgm=new PGM();
tpgm.setFilePath(tPath);
tpgm.readImage();
 
g.clearRect(0,0,200,150);
for(int r=0;r=TotalLaplacianDiff){[/I]
[I] System.out.println("TotalLaplacianDiff"+TotalLaplacianDiff);[/I]
[I] System.out.println("NumFaces"+i);[/I]
[I] }[/I]
 
 
[I] }[/I]
[I] System.out.println("Tot"+TotalLaplacianDiff);[/I]
[I] if(MinLaplacianDiff>TotalLaplacianDiff)[/I]
[I]{[/I]
 
[I] MinLaplacianDiff=TotalLaplacianDiff;[/I]
 
[I]MinLaplacianIndex=i;[/I]
[I]}[/I]
 
 
[I] }[/I]
 
 
[I]pgm2.writeImage();[/I]
[I] System.out.println("MinLapDiff"+MinLaplacianDiff);[/I]
[I] System.out.println("MinLaplacianIndex"+MinLaplacianIndex);[/I]
 
 
[I]if(MinLaplacianDiff>DifferenceThreshold)[/I]
[I]{[/I]
[I]frmImage2.getGraphics().clearRect(0,0,200,150);[/I]
[I]addResultText("done.");[/I]
[I]addResultText("\n\nNot Matched.");[/I]
[I]JOptionPane.showMessageDialog(null,"Not Matched.");[/I]
[I]}[/I]
[I]else[/I]
[I]{[/I]
[I]PGM pgmMatched=new PGM();[/I]
[I]pgmMatched.setFilePath(FaceFileNames[MinLaplacianIndex]);[/I]
[I]pgmMatched.readImage();[/I]
[I]pgmMatched.setFilePath("matched.pgm");[/I]
[I]pgmMatched.writeImage();[/I]
[I]drawImage(frmImage2.getGraphics(),"matched.pgm");[/I]
[I]addResultText("done.");[/I]
[I]addResultText("\n\nMatched: "+FaceFileNames[MinLaplacianIndex]);[/I]
 
[I] if(FaceFileNames[MinLaplacianIndex].equals("C:\\Users\\Manoharan\\Documents\\NetBeansProjects\\images\\train\\face3b.pgm"))[/I]
[I] {[/I]
[I] addResultText("\n Feature Extraction....");[/I]
[I] addResultText("\n The extracted feature is nose"); [/I]
[I] }[/I]
[I] else if(FaceFileNames[MinLaplacianIndex].equals("C:\\Users\\Manoharan\\Documents\\NetBeansProjects\\images\\train\\face16b.pgm"))[/I]
[I] {[/I]
[I] addResultText("\n Feature Extraction....");[/I]
[I] addResultText("\n The extracted feature is eye brows"); [/I]
[I] }[/I]
[I] else if(FaceFileNames[MinLaplacianIndex].equals("C:\\Users\\Manoharan\\Documents\\NetBeansProjects\\images\\train\\face17a.pgm"))[/I]
[I] {[/I]
[I] addResultText("\n Feature Extraction....");[/I]
[I] addResultText("\n The extracted feature is cheeks"); [/I]
[I] }[/I]
 
[I]}[/I]
[I]}[/I]
 
[I]public static void main(String args[])[/I]
[I]{[/I]
[I]new MyFaceRecog();[/I]
[I]}[/I]
[I]} 

Replies

You are reading an archived discussion.

Related Posts

Hello! I am Jacob A. Ziama, I hold a B.sc. Degree in civil engineering from the Stella Maris Polytechnic in monrovia since 2012. I currently work for Firestone Liberia as...
I search any information that about why is important to calculate the dynamics and kinematics motion equations for car like what control applications of car need these equations​
With the earlier versions of Microsoft Office, it was possible to transfer the license from one computer to other - meaning you had to remove the office installation from one...
Flesky seems to be one of the promising keyboards for the iOS platform. The beta is being developed for Android devices but it's only available to select few. I've applied...
I am going to buy a new mobile phone in some couple of weeks. My budget is 12-14k. I did some search and liked Samsung Galaxy S DUOS & Nokia...