Package org.opencv.objdetect
Class CascadeClassifier
- java.lang.Object
-
- org.opencv.objdetect.CascadeClassifier
-
public class CascadeClassifier extends Object
Cascade classifier class for object detection.
-
-
Field Summary
Fields Modifier and Type Field Description protected longnativeObj
-
Constructor Summary
Constructors Modifier Constructor Description CascadeClassifier()protectedCascadeClassifier(long addr)CascadeClassifier(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 booleanconvert(String oldcascade, String newcascade)voiddetectMultiScale(Mat image, MatOfRect objects)Detects objects of different sizes in the input image.voiddetectMultiScale(Mat image, MatOfRect objects, double scaleFactor)Detects objects of different sizes in the input image.voiddetectMultiScale(Mat image, MatOfRect objects, double scaleFactor, int minNeighbors)Detects objects of different sizes in the input image.voiddetectMultiScale(Mat image, MatOfRect objects, double scaleFactor, int minNeighbors, int flags)Detects objects of different sizes in the input image.voiddetectMultiScale(Mat image, MatOfRect objects, double scaleFactor, int minNeighbors, int flags, Size minSize)Detects objects of different sizes in the input image.voiddetectMultiScale(Mat image, MatOfRect objects, double scaleFactor, int minNeighbors, int flags, Size minSize, Size maxSize)Detects objects of different sizes in the input image.voiddetectMultiScale2(Mat image, MatOfRect objects, MatOfInt numDetections)voiddetectMultiScale2(Mat image, MatOfRect objects, MatOfInt numDetections, double scaleFactor)voiddetectMultiScale2(Mat image, MatOfRect objects, MatOfInt numDetections, double scaleFactor, int minNeighbors)voiddetectMultiScale2(Mat image, MatOfRect objects, MatOfInt numDetections, double scaleFactor, int minNeighbors, int flags)voiddetectMultiScale2(Mat image, MatOfRect objects, MatOfInt numDetections, double scaleFactor, int minNeighbors, int flags, Size minSize)voiddetectMultiScale2(Mat image, MatOfRect objects, MatOfInt numDetections, double scaleFactor, int minNeighbors, int flags, Size minSize, Size maxSize)voiddetectMultiScale3(Mat image, MatOfRect objects, MatOfInt rejectLevels, MatOfDouble levelWeights)This function allows you to retrieve the final stage decision certainty of classification.voiddetectMultiScale3(Mat image, MatOfRect objects, MatOfInt rejectLevels, MatOfDouble levelWeights, double scaleFactor)This function allows you to retrieve the final stage decision certainty of classification.voiddetectMultiScale3(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.voiddetectMultiScale3(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.voiddetectMultiScale3(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.voiddetectMultiScale3(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.voiddetectMultiScale3(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.booleanempty()Checks whether the classifier has been loaded.protected voidfinalize()intgetFeatureType()longgetNativeObjAddr()SizegetOriginalWindowSize()booleanisOldFormatCascade()booleanload(String filename)Loads a classifier from a file.
-
-
-
Constructor Detail
-
CascadeClassifier
protected CascadeClassifier(long addr)
-
CascadeClassifier
public CascadeClassifier(String filename)
Loads a classifier from a file.- Parameters:
filename- Name of the file from which the classifier is loaded.
-
CascadeClassifier
public CascadeClassifier()
-
-
Method Detail
-
getNativeObjAddr
public long getNativeObjAddr()
-
__fromPtr__
public static CascadeClassifier __fromPtr__(long addr)
-
getOriginalWindowSize
public Size getOriginalWindowSize()
-
empty
public boolean empty()
Checks whether the classifier has been loaded.- Returns:
- automatically generated
-
isOldFormatCascade
public boolean isOldFormatCascade()
-
load
public boolean load(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
-
getFeatureType
public int getFeatureType()
-
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 == minSizemodel is evaluated on single scale. The function is parallelized with the TBB library. Note:- (Python) A face detection example using cascade classifiers can be found at opencv_source_code/samples/python/facedetect.py
-
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. The function is parallelized with the TBB library. Note:- (Python) A face detection example using cascade classifiers can be found at opencv_source_code/samples/python/facedetect.py
-
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. The function is parallelized with the TBB library. Note:- (Python) A face detection example using cascade classifiers can be found at opencv_source_code/samples/python/facedetect.py
-
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. The function is parallelized with the TBB library. Note:- (Python) A face detection example using cascade classifiers can be found at opencv_source_code/samples/python/facedetect.py
-
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. The function is parallelized with the TBB library. Note:- (Python) A face detection example using cascade classifiers can be found at opencv_source_code/samples/python/facedetect.py
-
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. The function is parallelized with the TBB library. Note:- (Python) A face detection example using cascade classifiers can be found at opencv_source_code/samples/python/facedetect.py
-
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 == minSizemodel 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 setoutputRejectLevelson true and provide therejectLevelsandlevelWeightsparameter. For each resulting detection,levelWeightswill 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 setoutputRejectLevelson true and provide therejectLevelsandlevelWeightsparameter. For each resulting detection,levelWeightswill 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 setoutputRejectLevelson true and provide therejectLevelsandlevelWeightsparameter. For each resulting detection,levelWeightswill 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 setoutputRejectLevelson true and provide therejectLevelsandlevelWeightsparameter. For each resulting detection,levelWeightswill 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 setoutputRejectLevelson true and provide therejectLevelsandlevelWeightsparameter. For each resulting detection,levelWeightswill 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 setoutputRejectLevelson true and provide therejectLevelsandlevelWeightsparameter. For each resulting detection,levelWeightswill 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 setoutputRejectLevelson true and provide therejectLevelsandlevelWeightsparameter. For each resulting detection,levelWeightswill 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
-
-