Skip to content

Commit

Permalink
* update faq
Browse files Browse the repository at this point in the history
  • Loading branch information
lxowalle committed Dec 9, 2024
1 parent f8c3e44 commit d5cd634
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
15 changes: 15 additions & 0 deletions docs/doc/en/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,18 @@ with open("/root/a.txt", "r") as f:

Similarly, other functions that are not covered in the documentation can be searched to check if they are included in Python’s built-in libraries, which you can call directly.

### Error: camera read timeout during image capture

This error might occur when the camera's image buffer does not contain new images, causing a timeout during image capture. In most cases, this happens because the image is read too quickly, or multiple camera channels are attempting to read simultaneously. For instance, if one camera channel is bound to an RTSP service while another thread tries to capture images from a second camera channel.

Solution: Catch the exception, wait for a short period, and then retry the capture. Example code:

```python
img = None
try:
img = cam.read()
except:
time.sleep_ms(10)
continue
```

11 changes: 11 additions & 0 deletions docs/doc/zh/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,15 @@ with open("/root/a.txt", "r") as f:

类似的,其它在文档中没介绍的功能可以尝试搜一艘是不是 Python 自带的库,可以直接调用。

## 取图时出现`camera read timeout`的错误

这可能是在取图时摄像头缓存的图片缓存区没有新图片,导致取图超时.大部分情况是由于读图太快, 或者有多个Camera通道在同时读图时会遇到, 例如将一个Camera通道绑定到Rtsp服务后, 又在另一个线程从第二个Camera通道取图. 解决方法是捕获到异常后稍等片刻再次尝试取图, 参考代码:

```python
img = None
try:
img = cam.read()
except:
time.sleep_ms(10)
continue
```
8 changes: 7 additions & 1 deletion projects/app_rtsp/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ def touch_box(t, box, oft = 0):
need_exit = False
show_urls = False
while not app.need_exit():
img = cam2.read()
img = None
try:
img = cam2.read()
except:
time.sleep_ms(10)
continue

t = ts.read()

box = [20, 15, img_exit.width(), img_exit.height()]
Expand Down

0 comments on commit d5cd634

Please sign in to comment.