DetectionModel
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.
Member of Dnn
-
Create detection model from network represented in one of the supported formats. An order of @p model and @p config arguments does not matter.
Declaration
Objective-C
- (nonnull instancetype)initWithModel:(nonnull NSString *)model config:(nonnull NSString *)config;
Swift
init(model: String, config: String)
Parameters
model
Binary file contains trained weights.
config
Text file contains network configuration.
-
Create detection model from network represented in one of the supported formats. An order of @p model and @p config arguments does not matter.
Declaration
Objective-C
- (nonnull instancetype)initWithModel:(nonnull NSString *)model;
Swift
init(model: String)
Parameters
model
Binary file contains trained weights.
-
Given the @p input frame, create input blob, run net and return result detections.
Declaration
Objective-C
- (void)detect:(nonnull Mat *)frame classIds:(nonnull IntVector *)classIds confidences:(nonnull FloatVector *)confidences boxes:(nonnull NSMutableArray<Rect2i *> *)boxes confThreshold:(float)confThreshold nmsThreshold:(float)nmsThreshold;
Swift
func detect(frame: Mat, classIds: IntVector, confidences: FloatVector, boxes: NSMutableArray, confThreshold: Float, nmsThreshold: Float)
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.
-
Given the @p input frame, create input blob, run net and return result detections.
Declaration
Objective-C
- (void)detect:(nonnull Mat *)frame classIds:(nonnull IntVector *)classIds confidences:(nonnull FloatVector *)confidences boxes:(nonnull NSMutableArray<Rect2i *> *)boxes confThreshold:(float)confThreshold;
Swift
func detect(frame: Mat, classIds: IntVector, confidences: FloatVector, boxes: NSMutableArray, confThreshold: Float)
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.
-
Given the @p input frame, create input blob, run net and return result detections.
Declaration
Objective-C
- (void)detect:(nonnull Mat *)frame classIds:(nonnull IntVector *)classIds confidences:(nonnull FloatVector *)confidences boxes:(nonnull NSMutableArray<Rect2i *> *)boxes;
Swift
func detect(frame: Mat, classIds: IntVector, confidences: FloatVector, boxes: NSMutableArray)
Parameters
classIds
Class indexes in result detection.
confidences
A set of corresponding confidences.
boxes
A set of bounding boxes.