Reader small image

You're reading from  OpenCV 3.0 Computer Vision with Java

Product typeBook
Published inJul 2015
Reading LevelIntermediate
Publisher
ISBN-139781783283972
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Daniel Lelis Baggio
Daniel Lelis Baggio
author image
Daniel Lelis Baggio

Daniel Lélis Baggio has started his works in computer vision through medical image processing at InCor (Instituto do Coração – Heart Institute) in São Paulo, Brazil, where he worked with intra-vascular ultrasound (IVUS) image segmentation. After that he has focused on GPGPU and ported that algorithm to work with NVidia's Cuda. He has also dived into 6 degrees of freedom head tracking with Natural User Interface group through a project called EHCI (http://code.google.com/p/ehci/ ). He also wrote “Mastering OpenCV with Practical Computer Vision Projects” from Packt Publishing.
Read more about Daniel Lelis Baggio

Right arrow

Detection


OpenCV already comes with several previously-trained cascades that are ready to be used. Among them, we can find front and profile face detectors as well as eye, body, mouth, nose, lower-body, and upper-body detectors. In this section, we will cover how to use them. The complete source can be found in the project cascade in this chapter.

The following code shows how to load a trained cascade:

private void loadCascade() {
  String cascadePath = "src/main/resources/cascades/lbpcascade_frontalface.xml";
  faceDetector = new CascadeClassifier(cascadePath);
}

Most of the action happens in the class CascadeClassifier, from the objdetect package. This class wraps cascade loading and object detection. The constructor with strings already loads the cascade from the given path. In case you want to postpone the cascade name, you can use the empty constructor and the load method.

The runMainLoop method, which is not shown here, will simply grab an image from the webcam and pass it to detectAndDrawFace...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
OpenCV 3.0 Computer Vision with Java
Published in: Jul 2015Publisher: ISBN-13: 9781783283972

Author (1)

author image
Daniel Lelis Baggio

Daniel Lélis Baggio has started his works in computer vision through medical image processing at InCor (Instituto do Coração – Heart Institute) in São Paulo, Brazil, where he worked with intra-vascular ultrasound (IVUS) image segmentation. After that he has focused on GPGPU and ported that algorithm to work with NVidia's Cuda. He has also dived into 6 degrees of freedom head tracking with Natural User Interface group through a project called EHCI (http://code.google.com/p/ehci/ ). He also wrote “Mastering OpenCV with Practical Computer Vision Projects” from Packt Publishing.
Read more about Daniel Lelis Baggio