Detect objects in an image with an Artificial Neural Network.
* * * * * Not tested (no free model found) * * * * *
Detect objects in an image with an Artificial Neural Network.
* * * * * Not tested (no free model found) * * * * *
def __init__(self):
super(NeuralNetONNXDetector, self).__init__()
self._extension = '.onnx'
Initialize the model with the given file.
IOError, Exception
def _set_detector(self, model):
"""Initialize the model with the given file.
:param model: (str) Filename of the Caffe model file
:raise: IOError, Exception
"""
try:
self._detector = cv2.dnn.readNetFromONNX(model)
except cv2.error as e:
logging.error('Artificial Neural Network model (ONNX) failed to be read.')
raise sppasError(str(e))
Initialize net and blob for the processing.
def _net_detections(self, image):
"""Initialize net and blob for the processing.
:returns: detections.
"""
blob = cv2.dnn.blobFromImage(image, 1.0, (320, 240), (127, 127, 127), False, False)
self._detector.setInput(blob)
return self._detector.forward()