Package org.opencv.dnn
Class DetectionModel
- java.lang.Object
- 
- org.opencv.dnn.Model
- 
- org.opencv.dnn.DetectionModel
 
 
- 
 public class DetectionModel extends Model This class represents high-level API for object detection networks. DetectionModel allows to set params for preprocessing input image. DetectionModel creates net from file with trained weights and config, sets preprocessing input, runs forward pass and return result detections. For DetectionModel SSD, Faster R-CNN, YOLO topologies are supported.
- 
- 
Constructor SummaryConstructors Modifier Constructor Description protectedDetectionModel(long addr)DetectionModel(java.lang.String model)Create detection model from network represented in one of the supported formats.DetectionModel(java.lang.String model, java.lang.String config)Create detection model from network represented in one of the supported formats.DetectionModel(Net network)Create model from deep learning network.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DetectionModel__fromPtr__(long addr)voiddetect(Mat frame, MatOfInt classIds, MatOfFloat confidences, MatOfRect boxes)Given theinputframe, create input blob, run net and return result detections.voiddetect(Mat frame, MatOfInt classIds, MatOfFloat confidences, MatOfRect boxes, float confThreshold)Given theinputframe, create input blob, run net and return result detections.voiddetect(Mat frame, MatOfInt classIds, MatOfFloat confidences, MatOfRect boxes, float confThreshold, float nmsThreshold)Given theinputframe, create input blob, run net and return result detections.protected voidfinalize()booleangetNmsAcrossClasses()Getter for nmsAcrossClasses.DetectionModelsetNmsAcrossClasses(boolean value)nmsAcrossClasses defaults to false, such that when non max suppression is used during the detect() function, it will do so per-class.- 
Methods inherited from class org.opencv.dnn.ModelgetNativeObjAddr, predict, setInputCrop, setInputMean, setInputParams, setInputParams, setInputParams, setInputParams, setInputParams, setInputParams, setInputScale, setInputSize, setInputSize, setInputSwapRB, setPreferableBackend, setPreferableTarget
 
- 
 
- 
- 
- 
Constructor Detail- 
DetectionModelprotected DetectionModel(long addr) 
 - 
DetectionModelpublic DetectionModel(java.lang.String model, java.lang.String config)Create detection model from network represented in one of the supported formats. An order ofmodelandconfigarguments does not matter.- Parameters:
- model- Binary file contains trained weights.
- config- Text file contains network configuration.
 
 - 
DetectionModelpublic DetectionModel(java.lang.String model) Create detection model from network represented in one of the supported formats. An order ofmodelandconfigarguments does not matter.- Parameters:
- model- Binary file contains trained weights.
 
 - 
DetectionModelpublic DetectionModel(Net network) Create model from deep learning network.- Parameters:
- network- Net object.
 
 
- 
 - 
Method Detail- 
__fromPtr__public static DetectionModel __fromPtr__(long addr) 
 - 
setNmsAcrossClassespublic DetectionModel setNmsAcrossClasses(boolean value) nmsAcrossClasses defaults to false, such that when non max suppression is used during the detect() function, it will do so per-class. This function allows you to toggle this behaviour.- Parameters:
- value- The new value for nmsAcrossClasses
- Returns:
- automatically generated
 
 - 
getNmsAcrossClassespublic boolean getNmsAcrossClasses() Getter for nmsAcrossClasses. This variable defaults to false, such that when non max suppression is used during the detect() function, it will do so only per-class- Returns:
- automatically generated
 
 - 
detectpublic void detect(Mat frame, MatOfInt classIds, MatOfFloat confidences, MatOfRect boxes, float confThreshold, float nmsThreshold) Given theinputframe, create input blob, run net and return result detections.- Parameters:
- classIds- Class indexes in result detection.
- confidences- A set of corresponding confidences.
- boxes- A set of bounding boxes.
- confThreshold- A threshold used to filter boxes by confidences.
- nmsThreshold- A threshold used in non maximum suppression.
- frame- automatically generated
 
 - 
detectpublic void detect(Mat frame, MatOfInt classIds, MatOfFloat confidences, MatOfRect boxes, float confThreshold) Given theinputframe, create input blob, run net and return result detections.- Parameters:
- classIds- Class indexes in result detection.
- confidences- A set of corresponding confidences.
- boxes- A set of bounding boxes.
- confThreshold- A threshold used to filter boxes by confidences.
- frame- automatically generated
 
 - 
detectpublic void detect(Mat frame, MatOfInt classIds, MatOfFloat confidences, MatOfRect boxes) Given theinputframe, create input blob, run net and return result detections.- Parameters:
- classIds- Class indexes in result detection.
- confidences- A set of corresponding confidences.
- boxes- A set of bounding boxes.
- frame- automatically generated
 
 
- 
 
-