# I cannot run code that "detects in real time" the model I created.

**URL:** https://discuss.roboflow.com/t/i-cannot-run-code-that-detects-in-real-time-the-model-i-created/3486
**Category:** 🤝  Community Help
**Tags:** segmentation, bugs, feature-request
**Created:** [October 20, 2023, 5:54pm UTC](https://discuss.roboflow.com/t/i-cannot-run-code-that-detects-in-real-time-the-model-i-created/3486 "2023-10-20T17:54:01Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![HCB7](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/hcb7/32/3042_2.png) [@HCB7](https://discuss.roboflow.com/u/HCB7)
#### Post date: [October 20, 2023, 5:54pm UTC](https://discuss.roboflow.com/t/i-cannot-run-code-that-detects-in-real-time-the-model-i-created/3486/1 "2023-10-20T17:54:01Z")

</div>

I have created a model "in a project where I am trying to detect in real time “---------------------------------------------------------------------------  
error Traceback (most recent call last)  
c:\Users\cloud\OneDrive\Desktop\PythonLand\PoloPlus\AI\CV\Food-Detection\Biscuit-Decetion\Special\_Object\_Recognition\yolov8\yolo\_realcv.ipynb Cell 3 line 7  
68 image = infer()  
69 # And display the inference results  
—\> 70 cv2.imshow(‘image’, image)  
72 # Print frames per second  
73 print((1/(time.time()-start)), " fps”)

error: OpenCV(4.6.0) D:\a\opencv-python\opencv-python\opencv\modules\highgui\src\window.cpp:967: error: (-215:Assertion failed) size.width\>0 && size.height\>0 in function ‘cv::imshow’"

I get an error like "{  
“\_\_comment1”: “Obtain these values via Roboflow”,  
“ROBOFLOW\_API\_KEY”: “########”,  
“ROBOFLOW\_MODEL”: “biscuit\_detct”,  
“ROBOFLOW\_SIZE”: 416,

```
"__comment2": "",
"FRAMERATE": 24,
"BUFFER": 0.5"

```

I can not solve this error? I can send the complete code.

Can you help me? .  
Thanks for your help.

---

<div class="post-metadata">

### Author: ![Lenny](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/lenny/32/2383_2.png) [@Lenny](https://discuss.roboflow.com/u/Lenny)
#### Post date: [October 20, 2023, 5:54pm UTC](https://discuss.roboflow.com/t/i-cannot-run-code-that-detects-in-real-time-the-model-i-created/3486/2 "2023-10-20T17:54:43Z")

</div>

The error message you’re seeing is typically due to OpenCV’s `imshow` function not receiving a valid image. This could be because the image is not being loaded correctly or the image path is incorrect.

In the context of Roboflow, if you’re using a webcam or other video source for real-time detection, you might encounter issues if the video source is not found or not accessible. As mentioned in the [Roboflow blog post](https://blog.roboflow.com/how-to-deploy-yolov7-to-jetson-nano/), if you encounter an error like `assert cap.isOpened(), f'Failed to open {s}'` and `AssertionError: Failed to open 0`, it indicates that your camera was unable to be found. You can try reconnecting your camera or changing the `source` argument to `detect.py`. To try changing the `source` argument, use `--source 1` with `detect.py` instead of `--source 0`.

If you’re still encountering issues, please ensure that your image or video source is correctly set up and accessible.

* * *

> Hi! I’m Roboflow’s AI powered bot. This is an automated response powered using AI with knowledge from our docs, blog, knowledge base, and previous forum responses. If you find this to be a helpful answer, please mark it as the solution using the checkbox icon below. If this doesn’t solve your issue, please follow up with what you’ve tried/why, and the community will continue to chime in as usual.
