Hi, I have run this code and it is only detect the frontal faces, I am doing my final year research project and I want to detect the different position of the face to detect.
The code I have use is...
package UWU_CST_09_0039.UniversityProject;
import com.googlecode.javacv.*;
import com.googlecode.javacv.cpp.*;
import com.googlecode.javacv.cpp.opencv_core.IplImage;
import com.googlecode.javacpp.Loader;
import static com.googlecode.javacv.cpp.opencv_core.*;
import static com.googlecode.javacv.cpp.opencv_imgproc.*;
import static com.googlecode.javacv.cpp.opencv_highgui.*;
import static com.googlecode.javacv.cpp.opencv_objdetect.*;
public class FaceDetection
{
private static final int SCALE = 2;
// scaling factor to reduce size of input image
// cascade definition for face detection
private static final String CASCADE_FILE = "C:\\opencv\\data\\haarcascades\\haarcascade_frontalface_alt.xml";
private static final String OUT_FILE = "images\\markedFacesImage.jpg";
public static void main(String[] args)
{
args[0]="images\\StitchImage.jpg";
if (args.length != 1) {
System.out.println("Usage: run FaceDetection <input-file>");
return;
}
System.out.println("Starting OpenCV...");
// preload the opencv_objdetect module to work around a known bug
Loader.load(opencv_objdetect.class);
// load an image
System.out.println("Loading image from " + args[0]);
IplImage origImg = cvLoadImage(args[0]);
// convert to grayscale
IplImage grayImg = IplImage.create(origImg.width(), origImg.height(), IPL_DEPTH_8U, 1);
cvCvtColor(origImg, grayImg, CV_BGR2GRAY);
// scale the grayscale (to speed up face detection)
IplImage smallImg = IplImage.create(grayImg.width()/SCALE,
grayImg.height()/SCALE, IPL_DEPTH_8U, 1);
cvResize(grayImg, smallImg, CV_INTER_LINEAR);
// equalize the small grayscale
IplImage equImg = IplImage.create(smallImg.width(),
smallImg.height(), IPL_DEPTH_8U, 1);
cvEqualizeHist(smallImg, equImg);
// create temp storage, used during object detection
CvMemStorage storage = CvMemStorage.create();
CvHaarClassifierCascade cascade = new CvHaarClassifierCascade(cvLoad(CASCADE_FILE));
System.out.println("Detecting faces...");
CvSeq faces = cvHaarDetectObjects(equImg, cascade, storage, 1.1, 3, CV_HAAR_DO_CANNY_PRUNING);
cvClearMemStorage(storage);
// iterate over the faces and draw yellow rectangles around them
int total = faces.total();
System.out.println("Found " + total + " face(s)");
for (int i = 0; i < total; i++) {
CvRect r = new CvRect(cvGetSeqElem(faces, i));
// cvSetImageROI(equImg,r);
cvRectangle(origImg, cvPoint( r.x()*SCALE, r.y()*SCALE ), // undo the scaling
cvPoint( (r.x() + r.width())*SCALE, (r.y() + r.height())*SCALE ),
CvScalar.YELLOW, 6, CV_AA, 0);
}
if (total > 0) {
System.out.println("Saving marked-faces version of " + args[0] + " in " + OUT_FILE);
cvSaveImage(OUT_FILE, origImg);
final IplImage image = cvLoadImage(OUT_FILE);
// Create image window named "My Image".
//
// Note that you need to indicate to CanvasFrame not to apply gamma correction,
// by setting gamma to 1, otherwise the image will not look correct.
final CanvasFrame canvas = new CanvasFrame("My Image", 1);
// Request closing of the application when the image window is closed.
canvas.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
// Show image on window.
canvas.showImage(image);
}
} // end of main()
}
I have found this code with the link..
http://code.google.com/p/javacv/wiki/Windows7AndOpenCVand Is that can detect the various position of a face? And it cannot be run as an java application.It require Run as configuration...
Can you please consider about this issue please....Thank you