Package org.opencv.objdetect
Class CascadeClassifier
- java.lang.Object
-
- org.opencv.objdetect.CascadeClassifier
-
public class CascadeClassifier extends java.lang.Object
Cascade classifier class for object detection.
-
-
Field Summary
Fields Modifier and Type Field Description protected long
nativeObj
-
Constructor Summary
Constructors Modifier Constructor Description CascadeClassifier()
protected
CascadeClassifier(long addr)
CascadeClassifier(java.lang.String filename)
Loads a classifier from a file.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CascadeClassifier
__fromPtr__(long addr)
static boolean
convert(java.lang.String oldcascade, java.lang.String newcascade)
void
detectMultiScale(Mat image, MatOfRect objects)
Detects objects of different sizes in the input image.void
detectMultiScale(Mat image, MatOfRect objects, double scaleFactor)
Detects objects of different sizes in the input image.void
detectMultiScale(Mat image, MatOfRect objects, double scaleFactor, int minNeighbors)
Detects objects of different sizes in the input image.void
detectMultiScale(Mat image, MatOfRect objects, double scaleFactor, int minNeighbors, int flags)
Detects objects of different sizes in the input image.void
detectMultiScale(Mat image, MatOfRect objects, double scaleFactor, int minNeighbors, int flags, Size minSize)
Detects objects of different sizes in the input image.void
detectMultiScale(Mat image, MatOfRect objects, double scaleFactor, int minNeighbors, int flags, Size minSize, Size maxSize)
Detects objects of different sizes in the input image.void
detectMultiScale2(Mat image, MatOfRect objects, MatOfInt numDetections)
void
detectMultiScale2(Mat image, MatOfRect objects, MatOfInt numDetections, double scaleFactor)
void
detectMultiScale2(Mat image, MatOfRect objects, MatOfInt numDetections, double scaleFactor, int minNeighbors)
void
detectMultiScale2(Mat image, MatOfRect objects, MatOfInt numDetections, double scaleFactor, int minNeighbors, int flags)
void
detectMultiScale2(Mat image, MatOfRect objects, MatOfInt numDetections, double scaleFactor, int minNeighbors, int flags, Size minSize)
void
detectMultiScale2(Mat image, MatOfRect objects, MatOfInt numDetections, double scaleFactor, int minNeighbors, int flags, Size minSize, Size maxSize)
void
detectMultiScale3(Mat image, MatOfRect objects, MatOfInt rejectLevels, MatOfDouble levelWeights)
This function allows you to retrieve the final stage decision certainty of classification.void
detectMultiScale3(Mat image, MatOfRect objects, MatOfInt rejectLevels, MatOfDouble levelWeights, double scaleFactor)
This function allows you to retrieve the final stage decision certainty of classification.void
detectMultiScale3(Mat image, MatOfRect objects, MatOfInt rejectLevels, MatOfDouble levelWeights, double scaleFactor, int minNeighbors)
This function allows you to retrieve the final stage decision certainty of classification.void
detectMultiScale3(Mat image, MatOfRect objects, MatOfInt rejectLevels, MatOfDouble levelWeights, double scaleFactor, int minNeighbors, int flags)
This function allows you to retrieve the final stage decision certainty of classification.void
detectMultiScale3(Mat image, MatOfRect objects, MatOfInt rejectLevels, MatOfDouble levelWeights, double scaleFactor, int minNeighbors, int flags, Size minSize)
This function allows you to retrieve the final stage decision certainty of classification.void
detectMultiScale3(Mat image, MatOfRect objects, MatOfInt rejectLevels, MatOfDouble levelWeights, double scaleFactor, int minNeighbors, int flags, Size minSize, Size maxSize)
This function allows you to retrieve the final stage decision certainty of classification.void
detectMultiScale3(Mat image, MatOfRect objects, MatOfInt rejectLevels, MatOfDouble levelWeights, double scaleFactor, int minNeighbors, int flags, Size minSize, Size maxSize, boolean outputRejectLevels)
This function allows you to retrieve the final stage decision certainty of classification.boolean
empty()
Checks whether the classifier has been loaded.protected void
finalize()
int
getFeatureType()
long
getNativeObjAddr()
Size
getOriginalWindowSize()
boolean
isOldFormatCascade()
boolean
load(java.lang.String filename)
Loads a classifier from a file.
-
-
-
Constructor Detail
-
CascadeClassifier
protected CascadeClassifier(long addr)
-
CascadeClassifier
public CascadeClassifier()
-
CascadeClassifier
public CascadeClassifier(java.lang.String filename)
Loads a classifier from a file.- Parameters:
filename
- Name of the file from which the classifier is loaded.
-
-
Method Detail
-
getNativeObjAddr
public long getNativeObjAddr()
-
__fromPtr__
public static CascadeClassifier __fromPtr__(long addr)
-
empty
public boolean empty()
Checks whether the classifier has been loaded.- Returns:
- automatically generated
-
load
public boolean load(java.lang.String filename)
Loads a classifier from a file.- Parameters:
filename
- Name of the file from which the classifier is loaded. The file may contain an old HAAR classifier trained by the haartraining application or a new cascade classifier trained by the traincascade application.- Returns:
- automatically generated
-
detectMultiScale
public void detectMultiScale(Mat image, MatOfRect objects, double scaleFactor, int minNeighbors, int flags, Size minSize, Size maxSize)
Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.- Parameters:
image
- Matrix of the type CV_8U containing an image where objects are detected.objects
- Vector of rectangles where each rectangle contains the detected object, the rectangles may be partially outside the original image.scaleFactor
- Parameter specifying how much the image size is reduced at each image scale.minNeighbors
- Parameter specifying how many neighbors each candidate rectangle should have to retain it.flags
- Parameter with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade.minSize
- Minimum possible object size. Objects smaller than that are ignored.maxSize
- Maximum possible object size. Objects larger than that are ignored. IfmaxSize == minSize
model is evaluated on single scale.
-
detectMultiScale
public void detectMultiScale(Mat image, MatOfRect objects, double scaleFactor, int minNeighbors, int flags, Size minSize)
Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.- Parameters:
image
- Matrix of the type CV_8U containing an image where objects are detected.objects
- Vector of rectangles where each rectangle contains the detected object, the rectangles may be partially outside the original image.scaleFactor
- Parameter specifying how much the image size is reduced at each image scale.minNeighbors
- Parameter specifying how many neighbors each candidate rectangle should have to retain it.flags
- Parameter with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade.minSize
- Minimum possible object size. Objects smaller than that are ignored.
-
detectMultiScale
public void detectMultiScale(Mat image, MatOfRect objects, double scaleFactor, int minNeighbors, int flags)
Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.- Parameters:
image
- Matrix of the type CV_8U containing an image where objects are detected.objects
- Vector of rectangles where each rectangle contains the detected object, the rectangles may be partially outside the original image.scaleFactor
- Parameter specifying how much the image size is reduced at each image scale.minNeighbors
- Parameter specifying how many neighbors each candidate rectangle should have to retain it.flags
- Parameter with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade.
-
detectMultiScale
public void detectMultiScale(Mat image, MatOfRect objects, double scaleFactor, int minNeighbors)
Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.- Parameters:
image
- Matrix of the type CV_8U containing an image where objects are detected.objects
- Vector of rectangles where each rectangle contains the detected object, the rectangles may be partially outside the original image.scaleFactor
- Parameter specifying how much the image size is reduced at each image scale.minNeighbors
- Parameter specifying how many neighbors each candidate rectangle should have to retain it. cvHaarDetectObjects. It is not used for a new cascade.
-
detectMultiScale
public void detectMultiScale(Mat image, MatOfRect objects, double scaleFactor)
Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.- Parameters:
image
- Matrix of the type CV_8U containing an image where objects are detected.objects
- Vector of rectangles where each rectangle contains the detected object, the rectangles may be partially outside the original image.scaleFactor
- Parameter specifying how much the image size is reduced at each image scale. to retain it. cvHaarDetectObjects. It is not used for a new cascade.
-
detectMultiScale
public void detectMultiScale(Mat image, MatOfRect objects)
Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles.- Parameters:
image
- Matrix of the type CV_8U containing an image where objects are detected.objects
- Vector of rectangles where each rectangle contains the detected object, the rectangles may be partially outside the original image. to retain it. cvHaarDetectObjects. It is not used for a new cascade.
-
detectMultiScale2
public void detectMultiScale2(Mat image, MatOfRect objects, MatOfInt numDetections, double scaleFactor, int minNeighbors, int flags, Size minSize, Size maxSize)
- Parameters:
image
- Matrix of the type CV_8U containing an image where objects are detected.objects
- Vector of rectangles where each rectangle contains the detected object, the rectangles may be partially outside the original image.numDetections
- Vector of detection numbers for the corresponding objects. An object's number of detections is the number of neighboring positively classified rectangles that were joined together to form the object.scaleFactor
- Parameter specifying how much the image size is reduced at each image scale.minNeighbors
- Parameter specifying how many neighbors each candidate rectangle should have to retain it.flags
- Parameter with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade.minSize
- Minimum possible object size. Objects smaller than that are ignored.maxSize
- Maximum possible object size. Objects larger than that are ignored. IfmaxSize == minSize
model is evaluated on single scale.
-
detectMultiScale2
public void detectMultiScale2(Mat image, MatOfRect objects, MatOfInt numDetections, double scaleFactor, int minNeighbors, int flags, Size minSize)
- Parameters:
image
- Matrix of the type CV_8U containing an image where objects are detected.objects
- Vector of rectangles where each rectangle contains the detected object, the rectangles may be partially outside the original image.numDetections
- Vector of detection numbers for the corresponding objects. An object's number of detections is the number of neighboring positively classified rectangles that were joined together to form the object.scaleFactor
- Parameter specifying how much the image size is reduced at each image scale.minNeighbors
- Parameter specifying how many neighbors each candidate rectangle should have to retain it.flags
- Parameter with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade.minSize
- Minimum possible object size. Objects smaller than that are ignored.
-
detectMultiScale2
public void detectMultiScale2(Mat image, MatOfRect objects, MatOfInt numDetections, double scaleFactor, int minNeighbors, int flags)
- Parameters:
image
- Matrix of the type CV_8U containing an image where objects are detected.objects
- Vector of rectangles where each rectangle contains the detected object, the rectangles may be partially outside the original image.numDetections
- Vector of detection numbers for the corresponding objects. An object's number of detections is the number of neighboring positively classified rectangles that were joined together to form the object.scaleFactor
- Parameter specifying how much the image size is reduced at each image scale.minNeighbors
- Parameter specifying how many neighbors each candidate rectangle should have to retain it.flags
- Parameter with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade.
-
detectMultiScale2
public void detectMultiScale2(Mat image, MatOfRect objects, MatOfInt numDetections, double scaleFactor, int minNeighbors)
- Parameters:
image
- Matrix of the type CV_8U containing an image where objects are detected.objects
- Vector of rectangles where each rectangle contains the detected object, the rectangles may be partially outside the original image.numDetections
- Vector of detection numbers for the corresponding objects. An object's number of detections is the number of neighboring positively classified rectangles that were joined together to form the object.scaleFactor
- Parameter specifying how much the image size is reduced at each image scale.minNeighbors
- Parameter specifying how many neighbors each candidate rectangle should have to retain it. cvHaarDetectObjects. It is not used for a new cascade.
-
detectMultiScale2
public void detectMultiScale2(Mat image, MatOfRect objects, MatOfInt numDetections, double scaleFactor)
- Parameters:
image
- Matrix of the type CV_8U containing an image where objects are detected.objects
- Vector of rectangles where each rectangle contains the detected object, the rectangles may be partially outside the original image.numDetections
- Vector of detection numbers for the corresponding objects. An object's number of detections is the number of neighboring positively classified rectangles that were joined together to form the object.scaleFactor
- Parameter specifying how much the image size is reduced at each image scale. to retain it. cvHaarDetectObjects. It is not used for a new cascade.
-
detectMultiScale2
public void detectMultiScale2(Mat image, MatOfRect objects, MatOfInt numDetections)
- Parameters:
image
- Matrix of the type CV_8U containing an image where objects are detected.objects
- Vector of rectangles where each rectangle contains the detected object, the rectangles may be partially outside the original image.numDetections
- Vector of detection numbers for the corresponding objects. An object's number of detections is the number of neighboring positively classified rectangles that were joined together to form the object. to retain it. cvHaarDetectObjects. It is not used for a new cascade.
-
detectMultiScale3
public void detectMultiScale3(Mat image, MatOfRect objects, MatOfInt rejectLevels, MatOfDouble levelWeights, double scaleFactor, int minNeighbors, int flags, Size minSize, Size maxSize, boolean outputRejectLevels)
This function allows you to retrieve the final stage decision certainty of classification. For this, one needs to setoutputRejectLevels
on true and provide therejectLevels
andlevelWeights
parameter. For each resulting detection,levelWeights
will then contain the certainty of classification at the final stage. This value can then be used to separate strong from weaker classifications. A code sample on how to use it efficiently can be found below:Mat img; vector<double> weights; vector<int> levels; vector<Rect> detections; CascadeClassifier model("/path/to/your/model.xml"); model.detectMultiScale(img, detections, levels, weights, 1.1, 3, 0, Size(), Size(), true); cerr << "Detection " << detections[0] << " with weight " << weights[0] << endl;
- Parameters:
image
- automatically generatedobjects
- automatically generatedrejectLevels
- automatically generatedlevelWeights
- automatically generatedscaleFactor
- automatically generatedminNeighbors
- automatically generatedflags
- automatically generatedminSize
- automatically generatedmaxSize
- automatically generatedoutputRejectLevels
- automatically generated
-
detectMultiScale3
public void detectMultiScale3(Mat image, MatOfRect objects, MatOfInt rejectLevels, MatOfDouble levelWeights, double scaleFactor, int minNeighbors, int flags, Size minSize, Size maxSize)
This function allows you to retrieve the final stage decision certainty of classification. For this, one needs to setoutputRejectLevels
on true and provide therejectLevels
andlevelWeights
parameter. For each resulting detection,levelWeights
will then contain the certainty of classification at the final stage. This value can then be used to separate strong from weaker classifications. A code sample on how to use it efficiently can be found below:Mat img; vector<double> weights; vector<int> levels; vector<Rect> detections; CascadeClassifier model("/path/to/your/model.xml"); model.detectMultiScale(img, detections, levels, weights, 1.1, 3, 0, Size(), Size(), true); cerr << "Detection " << detections[0] << " with weight " << weights[0] << endl;
- Parameters:
image
- automatically generatedobjects
- automatically generatedrejectLevels
- automatically generatedlevelWeights
- automatically generatedscaleFactor
- automatically generatedminNeighbors
- automatically generatedflags
- automatically generatedminSize
- automatically generatedmaxSize
- automatically generated
-
detectMultiScale3
public void detectMultiScale3(Mat image, MatOfRect objects, MatOfInt rejectLevels, MatOfDouble levelWeights, double scaleFactor, int minNeighbors, int flags, Size minSize)
This function allows you to retrieve the final stage decision certainty of classification. For this, one needs to setoutputRejectLevels
on true and provide therejectLevels
andlevelWeights
parameter. For each resulting detection,levelWeights
will then contain the certainty of classification at the final stage. This value can then be used to separate strong from weaker classifications. A code sample on how to use it efficiently can be found below:Mat img; vector<double> weights; vector<int> levels; vector<Rect> detections; CascadeClassifier model("/path/to/your/model.xml"); model.detectMultiScale(img, detections, levels, weights, 1.1, 3, 0, Size(), Size(), true); cerr << "Detection " << detections[0] << " with weight " << weights[0] << endl;
- Parameters:
image
- automatically generatedobjects
- automatically generatedrejectLevels
- automatically generatedlevelWeights
- automatically generatedscaleFactor
- automatically generatedminNeighbors
- automatically generatedflags
- automatically generatedminSize
- automatically generated
-
detectMultiScale3
public void detectMultiScale3(Mat image, MatOfRect objects, MatOfInt rejectLevels, MatOfDouble levelWeights, double scaleFactor, int minNeighbors, int flags)
This function allows you to retrieve the final stage decision certainty of classification. For this, one needs to setoutputRejectLevels
on true and provide therejectLevels
andlevelWeights
parameter. For each resulting detection,levelWeights
will then contain the certainty of classification at the final stage. This value can then be used to separate strong from weaker classifications. A code sample on how to use it efficiently can be found below:Mat img; vector<double> weights; vector<int> levels; vector<Rect> detections; CascadeClassifier model("/path/to/your/model.xml"); model.detectMultiScale(img, detections, levels, weights, 1.1, 3, 0, Size(), Size(), true); cerr << "Detection " << detections[0] << " with weight " << weights[0] << endl;
- Parameters:
image
- automatically generatedobjects
- automatically generatedrejectLevels
- automatically generatedlevelWeights
- automatically generatedscaleFactor
- automatically generatedminNeighbors
- automatically generatedflags
- automatically generated
-
detectMultiScale3
public void detectMultiScale3(Mat image, MatOfRect objects, MatOfInt rejectLevels, MatOfDouble levelWeights, double scaleFactor, int minNeighbors)
This function allows you to retrieve the final stage decision certainty of classification. For this, one needs to setoutputRejectLevels
on true and provide therejectLevels
andlevelWeights
parameter. For each resulting detection,levelWeights
will then contain the certainty of classification at the final stage. This value can then be used to separate strong from weaker classifications. A code sample on how to use it efficiently can be found below:Mat img; vector<double> weights; vector<int> levels; vector<Rect> detections; CascadeClassifier model("/path/to/your/model.xml"); model.detectMultiScale(img, detections, levels, weights, 1.1, 3, 0, Size(), Size(), true); cerr << "Detection " << detections[0] << " with weight " << weights[0] << endl;
- Parameters:
image
- automatically generatedobjects
- automatically generatedrejectLevels
- automatically generatedlevelWeights
- automatically generatedscaleFactor
- automatically generatedminNeighbors
- automatically generated
-
detectMultiScale3
public void detectMultiScale3(Mat image, MatOfRect objects, MatOfInt rejectLevels, MatOfDouble levelWeights, double scaleFactor)
This function allows you to retrieve the final stage decision certainty of classification. For this, one needs to setoutputRejectLevels
on true and provide therejectLevels
andlevelWeights
parameter. For each resulting detection,levelWeights
will then contain the certainty of classification at the final stage. This value can then be used to separate strong from weaker classifications. A code sample on how to use it efficiently can be found below:Mat img; vector<double> weights; vector<int> levels; vector<Rect> detections; CascadeClassifier model("/path/to/your/model.xml"); model.detectMultiScale(img, detections, levels, weights, 1.1, 3, 0, Size(), Size(), true); cerr << "Detection " << detections[0] << " with weight " << weights[0] << endl;
- Parameters:
image
- automatically generatedobjects
- automatically generatedrejectLevels
- automatically generatedlevelWeights
- automatically generatedscaleFactor
- automatically generated
-
detectMultiScale3
public void detectMultiScale3(Mat image, MatOfRect objects, MatOfInt rejectLevels, MatOfDouble levelWeights)
This function allows you to retrieve the final stage decision certainty of classification. For this, one needs to setoutputRejectLevels
on true and provide therejectLevels
andlevelWeights
parameter. For each resulting detection,levelWeights
will then contain the certainty of classification at the final stage. This value can then be used to separate strong from weaker classifications. A code sample on how to use it efficiently can be found below:Mat img; vector<double> weights; vector<int> levels; vector<Rect> detections; CascadeClassifier model("/path/to/your/model.xml"); model.detectMultiScale(img, detections, levels, weights, 1.1, 3, 0, Size(), Size(), true); cerr << "Detection " << detections[0] << " with weight " << weights[0] << endl;
- Parameters:
image
- automatically generatedobjects
- automatically generatedrejectLevels
- automatically generatedlevelWeights
- automatically generated
-
isOldFormatCascade
public boolean isOldFormatCascade()
-
getOriginalWindowSize
public Size getOriginalWindowSize()
-
getFeatureType
public int getFeatureType()
-
convert
public static boolean convert(java.lang.String oldcascade, java.lang.String newcascade)
-
finalize
protected void finalize() throws java.lang.Throwable
- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
-