Sep-09-2022, 07:30 AM
Hello! I am doing object recognition on a windows system.
I have a code:
import cv2
Help please, thanks in advance.
P.S. The files are in the project folder.
I have a code:
import cv2
img = cv2.imread('Doroga_na_ylitce1.jpg') classNames = classFile = ‘coco.names’ with open(classFile, ‘rt’) as f: classNames = f.read().rstrip('\n').split('\n') configPath = ‘ssd_mobilenet_v3_large_coco_2020_01_14.pbtxt’ weightsPath = ‘frozen_inference_graph.pb’ net = cv2.dnn_DetectionModel(weightsPath, configPath) net.setInputSize(320, 320) net.setInputScale(1.0/ 127.5) net.setInputMean((127.5, 127.5, 127.5)) net.setInputSwapRB(True) classIds, confs, bbox = net.detect(img, confThreshold=0.5) print(classIds, bbox) cv2.imshow('Output', img) cv2.waitKey(0)It gives me an error:
Error:global D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\tensorflow\tf_import er. cpp (3159) cv::dnn::dnn4_v20211220::anonymous-namespace'::TFImporter::parseNode DNN/TF: Can't parse layer for node='FeatureExtractor/MobilenetV3/Conv/Conv2D' of type='Conv2D'. Exception: OpenCV(4.5.5) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\tensorflow\tf_import er.cpp:2830: error: (-2:Unspecified error) Const input blob for weights not found in function ‘cv::dnn::dnn4_v20211220::anonymous-namespace’::TFImporter::getConstBlob'
cv2.error: OpenCV(4.5.5) D:\a\opencv-python\opencv\modules\dnn\src\tensorflow\tf_import er. cpp:2830: error: (-2:Unspecified error) Const input blob for weights not found in function ‘cv::dnn::dnn4_v20211220::`anonymous-namespace’::TFImporter::getConstBlob'
The above exception was the immediate cause of the following exception:
Traceback (last call):
“CUsers/Daniel/PycharmProjects/object_detection/real_time_object_detection.py” file, line 13, in .
net = cv2.dnn_DetectionModel(weightsPath, configPath)
SystemError: The <class ‘cv2.dnn_DetectionModel’> returned a result with a set of errors
Process ended with exit code 1Help please, thanks in advance.
P.S. The files are in the project folder.