I am testing out python opencv (cv2) to detect multiple images using openvino DNN models. My code for first detection:
import cv2
dog=cv2.imread("dog.jfif")
cat=cv2.imread("cat.jfif")
net=cv2.dnn.readNet("ssd_mobilenetv2_fp16_scale2.xml","ssd_mobilenetv2_fp16_scale2.bin")
blob=cv2.dnn.blobFromImage(dog)
net.setInput(blob)
out=net.forward()
Until here, no error is shown and print (out)
shows that the "dog" detection is successful.
But then when i continue the next detection of "cat" image by adding the next few lines:
blob=cv2.dnn.blobFromImage(cat)
net.setInput(blob)
out=net.forward()
And I get:
>>> out = net.forward()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cv2.error: OpenCV(4.3.0-openvino) ../opencv/modules/dnn/src/ie_ngraph.cpp:522: error: (-215:Assertion failed) !isInitialized() in function 'initPlugin'
Why does this error occur? What is the correct way to do for the second detection?