Skip to content

Commit d5cd634

Browse files
committed
* update faq
1 parent f8c3e44 commit d5cd634

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

docs/doc/en/faq.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,18 @@ with open("/root/a.txt", "r") as f:
235235

236236
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.
237237

238+
### Error: camera read timeout during image capture
239+
240+
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.
241+
242+
Solution: Catch the exception, wait for a short period, and then retry the capture. Example code:
243+
244+
```python
245+
img = None
246+
try:
247+
img = cam.read()
248+
except:
249+
time.sleep_ms(10)
250+
continue
251+
```
252+

docs/doc/zh/faq.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,4 +225,15 @@ with open("/root/a.txt", "r") as f:
225225

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

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

230+
这可能是在取图时摄像头缓存的图片缓存区没有新图片,导致取图超时.大部分情况是由于读图太快, 或者有多个Camera通道在同时读图时会遇到, 例如将一个Camera通道绑定到Rtsp服务后, 又在另一个线程从第二个Camera通道取图. 解决方法是捕获到异常后稍等片刻再次尝试取图, 参考代码:
231+
232+
```python
233+
img = None
234+
try:
235+
img = cam.read()
236+
except:
237+
time.sleep_ms(10)
238+
continue
239+
```

projects/app_rtsp/main.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@ def touch_box(t, box, oft = 0):
3434
need_exit = False
3535
show_urls = False
3636
while not app.need_exit():
37-
img = cam2.read()
37+
img = None
38+
try:
39+
img = cam2.read()
40+
except:
41+
time.sleep_ms(10)
42+
continue
43+
3844
t = ts.read()
3945

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

0 commit comments

Comments
 (0)