# Opencv ERROR in object detection

**URL:** <https://forum.opencv.org/t/opencv-error-in-object-detection/3211>\
**Category:** Python\
**Tags:** dnn\
**Created:** [May 7, 2021, 5:01pm UTC](https://forum.opencv.org/t/opencv-error-in-object-detection/3211 "2021-05-07T17:01:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jophin123](https://avatars.discourse-cdn.com/v4/letter/j/50afbb/32.png) [@jophin123](https://forum.opencv.org/u/jophin123)\
**Post date:** [May 7, 2021, 5:01pm UTC](https://forum.opencv.org/t/opencv-error-in-object-detection/3211/1 "2021-05-07T17:01:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [May 7, 2021, 5:14pm UTC](https://forum.opencv.org/t/opencv-error-in-object-detection/3211/2 "2021-05-07T17:14:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jophin123](https://avatars.discourse-cdn.com/v4/letter/j/50afbb/32.png) [@jophin123](https://forum.opencv.org/u/jophin123)\
**Post date:** [May 7, 2021, 5:18pm UTC](https://forum.opencv.org/t/opencv-error-in-object-detection/3211/3 "2021-05-07T17:18:41Z")

</div>

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¼/ÇÑ»ó’¼

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [May 7, 2021, 5:21pm UTC](https://forum.opencv.org/t/opencv-error-in-object-detection/3211/4 "2021-05-07T17:21:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![matti.vuori](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@matti.vuori](https://forum.opencv.org/u/matti.vuori)\
**Post date:** [May 7, 2021, 6:29pm UTC](https://forum.opencv.org/t/opencv-error-in-object-detection/3211/5 "2021-05-07T18:29:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jophin123](https://avatars.discourse-cdn.com/v4/letter/j/50afbb/32.png) [@jophin123](https://forum.opencv.org/u/jophin123)\
**Post date:** [May 8, 2021, 3:48am UTC](https://forum.opencv.org/t/opencv-error-in-object-detection/3211/6 "2021-05-08T03:48:32Z")

</div>

not workingshowing the same error
