public CameraDetection() {
OpenCVFrameGrabber grabber = new OpenCVFrameGrabber(0);
try {
grabber.start();
IplImage frame = grabber.grab();
canvasFrame = new CanvasFrame("Camera Detecção");
canvasFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
canvasFrame.setCanvasSize(frame.width(), frame.height());
CvMemStorage storage = CvMemStorage.create();
while(detectionXmlFile==null || detectionXmlFile.isEmpty()) {
chooseXmlDetectionFile();
}
int detectionCount = 0;
CvSeq faces = null;
while (canvasFrame.isVisible() && (frame = grabber.grab()) != null) {
cvSmooth(frame, frame, CV_GAUSSIAN, 9, 9, 2, 2);
detectionCount++;
if (detectionCount > 5) {
detectionCount=0;
IplImage grayImage = null;
try {
grayImage = IplImage.create(frame.width(),
frame.height(), IPL_DEPTH_8U, 1);
} catch (NullPointerException e) {
System.out.println("Error: " + e);