Package org.opencv.objdetect
Class CascadeClassifier
- java.lang.Object
- 
- org.opencv.objdetect.CascadeClassifier
 
- 
 public class CascadeClassifier extends java.lang.ObjectCascade classifier class for object detection.
- 
- 
Field SummaryFields Modifier and Type Field Description protected longnativeObj
 - 
Constructor SummaryConstructors Modifier Constructor Description CascadeClassifier()protectedCascadeClassifier(long addr)CascadeClassifier(java.lang.String filename)Loads a classifier from a file.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CascadeClassifier__fromPtr__(long addr)static booleanconvert(java.lang.String oldcascade, java.lang.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(java.lang.String filename)Loads a classifier from a file.
 
- 
- 
- 
Constructor Detail- 
CascadeClassifierprotected CascadeClassifier(long addr) 
 - 
CascadeClassifierpublic CascadeClassifier() 
 - 
CascadeClassifierpublic 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- 
getNativeObjAddrpublic long getNativeObjAddr() 
 - 
__fromPtr__public static CascadeClassifier __fromPtr__(long addr) 
 - 
emptypublic boolean empty() Checks whether the classifier has been loaded.- Returns:
- automatically generated
 
 - 
loadpublic 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
 
 - 
detectMultiScalepublic 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. If- maxSize == minSizemodel is evaluated on single scale.
 
 - 
detectMultiScalepublic 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.
 
 - 
detectMultiScalepublic 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.
 
 - 
detectMultiScalepublic 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.
 
 - 
detectMultiScalepublic 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.
 
 - 
detectMultiScalepublic 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.
 
 - 
detectMultiScale2public 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. If- maxSize == minSizemodel is evaluated on single scale.
 
 - 
detectMultiScale2public 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.
 
 - 
detectMultiScale2public 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.
 
 - 
detectMultiScale2public 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.
 
 - 
detectMultiScale2public 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.
 
 - 
detectMultiScale2public 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.
 
 - 
detectMultiScale3public 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 generated
- objects- automatically generated
- rejectLevels- automatically generated
- levelWeights- automatically generated
- scaleFactor- automatically generated
- minNeighbors- automatically generated
- flags- automatically generated
- minSize- automatically generated
- maxSize- automatically generated
- outputRejectLevels- automatically generated
 
 - 
detectMultiScale3public 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 generated
- objects- automatically generated
- rejectLevels- automatically generated
- levelWeights- automatically generated
- scaleFactor- automatically generated
- minNeighbors- automatically generated
- flags- automatically generated
- minSize- automatically generated
- maxSize- automatically generated
 
 - 
detectMultiScale3public 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 generated
- objects- automatically generated
- rejectLevels- automatically generated
- levelWeights- automatically generated
- scaleFactor- automatically generated
- minNeighbors- automatically generated
- flags- automatically generated
- minSize- automatically generated
 
 - 
detectMultiScale3public 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 generated
- objects- automatically generated
- rejectLevels- automatically generated
- levelWeights- automatically generated
- scaleFactor- automatically generated
- minNeighbors- automatically generated
- flags- automatically generated
 
 - 
detectMultiScale3public 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 generated
- objects- automatically generated
- rejectLevels- automatically generated
- levelWeights- automatically generated
- scaleFactor- automatically generated
- minNeighbors- automatically generated
 
 - 
detectMultiScale3public 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 generated
- objects- automatically generated
- rejectLevels- automatically generated
- levelWeights- automatically generated
- scaleFactor- automatically generated
 
 - 
detectMultiScale3public 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 generated
- objects- automatically generated
- rejectLevels- automatically generated
- levelWeights- automatically generated
 
 - 
isOldFormatCascadepublic boolean isOldFormatCascade() 
 - 
getOriginalWindowSizepublic Size getOriginalWindowSize() 
 - 
getFeatureTypepublic int getFeatureType() 
 - 
convertpublic static boolean convert(java.lang.String oldcascade, java.lang.String newcascade)
 - 
finalizeprotected void finalize() throws java.lang.Throwable- Overrides:
- finalizein class- java.lang.Object
- Throws:
- java.lang.Throwable
 
 
- 
 
-