Opencv ERROR in object detection

runfile(‘E:/machine learning/ML IP CV Course code/computer_vision/mobiledetection/Object_Detection_Files/mobile.py’, wdir=‘E:/machine learning/ML IP CV Course code/computer_vision/mobiledetection/Object_Detection_Files’)
error: OpenCV(4.5.1) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-kh7iq4w7\opencv\modules\dnn\src\tensorflow\tf_io.cpp:42: error: (-2:Unspecified error) FAILED: ReadProtoFromBinaryFile(param_file, param). Failed to parse GraphDef file: E:\machine learning\ML IP CV Course code\computer_vision\mobiledetection\Object_Detection_Files\frozen_inference_graph.pb in function ‘cv::dnn::ReadTFNetParamsFromBinaryFileOrDie’

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File “E:\machine learning\ML IP CV Course code\computer_vision\mobiledetection\Object_Detection_Files\mobile.py”, line 24, in
net = cv2.dnn_DetectionModel(weightsPath,configPath)

SystemError: <class ‘cv2.dnn_DetectionModel’> returned a result with an error set

GETTING ERROR WHILE RUNNING THIS CODE

import cv2
thres = 0.45 # Threshold to detect object

cap = cv2.VideoCapture(0)
cap.set(3,648)
cap.set(4,480)


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)

ANYONE HELP

you probably had to download data from the net, can you try to check your

frozen_inference_graph.pb, e.g by throwing it onto a text editor or
head -c 1000 frozen_inference_graph.pb ?
maybe it only contains a html error msg , not the weights

1 Like

ITS SHOWING SOMETHING LIKE THIS WHILE I OPENING IT.(AM NEW TO PROGRAMMING)

Ž6¼›e¼Iƒ¼!¼ÆÂ-¼›;-¼"Yç»WÈþ»ãq!¼(ô¾»«Ý9;¼¨¤»^¦;¢9Ò»¦Z?¼É¤Ò»«ÊÑ»vè»()Ò»éF»/ëf¼2¼›Ie»K!7¼|‹3¼,
¼td
¼Æ
û»—Ê»Åñ®;ñÑ»¿ƒºi}‚»N!M»–%¼+†O»
†¼ç\ƒ»ò§Ñ»Y÷½Vßλ”ꁼ€¼4¬¼ú6¿¼FD-¼õ
x¼H,3¼
7Ä» <¼µÑ» c„¼Á§P¼’ó9¼Ì-õ»—ÌQ¼­
¼T ¼ë$¼ÁÉz¼n}M¼Ú˜^¼ 2F¼ó^ ¼×²Ñ»4ë ¼å˜¼«ZÒ» Ñ»êÁP¼yÏ0¼ƒë"¼´{:¼*dµ»!£Ð»û<¼ˆ¯» ¨6¼Le¼œM¼R*e¼[^¿:3,ª¼0²Ñ»"”n¼¸Ž¼¶aR¼¡*6¼@-d¼ ”¼§H•¼ê.€¼ ¬š¼"±£¼šª]¼É„¼X‡¼ac_¼­ƒ¼W
±¼gmļœ¼+Aº¼gÿ2¼/ÇÑ»ó’¼

^^ well, at least, that’ s binary, not html, and you can ignore my comment above
(sorry, but it wasn’t that easy …)

1 Like

Just one idea: the path to that file seems to have spaces and I wouldn’t be surprised if some OpenCV functions had difficulties with that

1 Like

not workingshowing the same error