# Do the API code examples still work from this roboflow blog? Errors from sample code

**URL:** https://discuss.roboflow.com/t/do-the-api-code-examples-still-work-from-this-roboflow-blog-errors-from-sample-code/277
**Category:** 🤝  Community Help
**Created:** [March 31, 2022, 7:26pm UTC](https://discuss.roboflow.com/t/do-the-api-code-examples-still-work-from-this-roboflow-blog-errors-from-sample-code/277 "2022-03-31T19:26:39Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Vulcan88](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/vulcan88/32/159_2.png) [@Vulcan88](https://discuss.roboflow.com/u/Vulcan88)
#### Post date: [March 31, 2022, 7:26pm UTC](https://discuss.roboflow.com/t/do-the-api-code-examples-still-work-from-this-roboflow-blog-errors-from-sample-code/277/1 "2022-03-31T19:26:40Z")

</div>

> **[Using Your Webcam with Roboflow Models](https://blog.roboflow.com/python-webcam/)**
>
> Computer vision models are normally trained to give you predictions on a single image at a time. The input to these models are often individual photos or frames from recorded videos collected asynchronously. But oftentimes you'll want to get...

I’m trying to use the roboflow API to run inference on my webcam but neither the simple or async versions work for me, I get the error:

```auto
cv2.imshow('image', image)
cv2.error: OpenCV(4.5.5) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'

[WARN:0@2.715] global D:\a\opencv-python\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (539) `anonymous-namespace'::SourceReaderCB::~SourceReaderCB terminating async callback

```

My webcam definitely is in port 0 and is working on other python scripts that call cv2.videoCapture(0)

Any ideas whats going on?

---

<div class="post-metadata">

### Author: ![anon59033456](https://avatars.discourse-cdn.com/v4/letter/a/a88e57/32.png) [@anon59033456](https://discuss.roboflow.com/u/anon59033456)
#### Post date: [March 31, 2022, 7:31pm UTC](https://discuss.roboflow.com/t/do-the-api-code-examples-still-work-from-this-roboflow-blog-errors-from-sample-code/277/2 "2022-03-31T19:31:34Z")

</div>

Hey @Vulcan88

Skimming through, it looks like `https://infer.roboflow.com/` should be `https://detect.roboflow.com/`. I’ll update this now.

---

<div class="post-metadata">

### Author: ![Vulcan88](https://yyz1.discourse-cdn.com/flex029/user_avatar/discuss.roboflow.com/vulcan88/32/159_2.png) [@Vulcan88](https://discuss.roboflow.com/u/Vulcan88)
#### Post date: [March 31, 2022, 7:39pm UTC](https://discuss.roboflow.com/t/do-the-api-code-examples-still-work-from-this-roboflow-blog-errors-from-sample-code/277/3 "2022-03-31T19:39:15Z")

</div>

Ah i see the blog post itself was wrong but the github files did use detect so I guess they were retroactively changed, unfortunately it wasn’t the cause of the problem 🥲

From some debugging it seems that on line 54 in infer\_simple.py:

```auto
image = cv2.imdecode(image, cv2.IMREAD_COLOR)

```

This is the method at which image is being returned as a NoneType, hmmm…

---

<div class="post-metadata">

### Author: ![anon59033456](https://avatars.discourse-cdn.com/v4/letter/a/a88e57/32.png) [@anon59033456](https://discuss.roboflow.com/u/anon59033456)
#### Post date: [March 31, 2022, 7:50pm UTC](https://discuss.roboflow.com/t/do-the-api-code-examples-still-work-from-this-roboflow-blog-errors-from-sample-code/277/4 "2022-03-31T19:50:42Z")

</div>

Ok, can you try these things while I try to reproduce this error?

- check if your webcam works fine with any other library other than OpenCV
- change VideoCapture(0) =\> VideoCapture(1)
- uninstall OpenCV and reinstall it
- relaunch the code editor or try with a different IDE
