@@ -97,37 +97,47 @@ $ curl http://127.0.0.1:8081/analyze/my_cat_name -X POST --header "Content-Type
9797```
9898` my_cat_name ` 是注册的猫咪名称;` test.jpeg ` 是测试图片;` output.jpg ` 是返回的可视化图片。
9999
100- ## 五、视频识别
100+ ## 五、准备视频识别
101101
102- 准备一个 rtsp 视频流地址,做测试输入(因不可抗力 MegFlow 无法提供现成地址)。模型包目录提供了测试视频,在 ` models/cat_finder_testdata ` ,需要用户自行部署 live555 服务。最直接的办法:
102+ 启动解析服务
103+ ``` bash
104+ $ cd flow-python/examples
105+ $ run_with_plugins -c cat_finder/video_gpu.toml -p cat_finder # 有 GPU 的机器
106+ $ run_with_plugins -c cat_finder/video_cpu.toml -p cat_finder # 无 GPU 的设备用这句
107+ ```
108+ 浏览器打开 8082 端口服务(如 http://127.0.0.1:8082/docs ,注意区分物理机和虚拟机的对应 ip)
109+
110+ ![ ] ( images/cat_finder_video_select.jpg )
111+
112+ 可以看到 MegFlow 提供了 4 个 API:启/停一路解析、消费当前解析结果、列出所有信息。
113+
114+ 开启一路视频流解析需要流的 url,这里有两种方法:
115+
116+ 1)准备一个 rtsp 视频流地址,做测试输入(流地址部署不方便,也可以直接用离线文件的绝对路径代替)。模型包目录提供了测试视频,在 ` models/cat_finder_testdata ` ,需要用户自行部署 live555 服务。最直接的办法:
103117``` bash
104118$ wget https://github.com/aler9/rtsp-simple-server/releases/download/v0.17.2/rtsp-simple-server_v0.17.2_linux_amd64.tar.gz
105119$
106120$ tar xvf rtsp-simple-server_v0.17.2_linux_amd64.tar.gz && ./rtsp-simple-server
107121$ ffmpeg -re -stream_loop -1 -i ${models} /cat_finder_testdata/test1.ts -c copy -f rtsp rtsp://127.0.0.1:8554/test1.ts
108122```
109123
110-
111124* 想用 laptop/树莓派摄像头可搜索 Camera 推流教程
112125* 也可以手机拍摄视频,再用 ffmpeg 转成 .ts 格式推到 live555 server
113126
114127相关教程已整合在 [ 如何生成自己的 rtsp 流地址] ( ../../../docs/how-to-build-and-run/generate-rtsp.zh.md ) 。
115128
116- 启动视频识别服务
117- ``` bash
118- $ cd flow-python/examples
119- $ run_with_plugins -c cat_finder/video_gpu.toml -p cat_finder # 有 GPU 的机器
120- $ run_with_plugins -c cat_finder/video_cpu.toml -p cat_finder # 无 GPU 的设备用这句
121- ```
122- 打开 8082 端口服务(如 http://127.0.0.1:8082/docs )。
129+ 2)如果 rtsp 流地址部署不方便,也可以直接用离线文件的绝对路径代替,也就是在 WebUI 中输入类似` /mnt/data/stream/file.ts ` 的路径。需要自行保证服务器可访问这个文件、并且格式是可以被 ffmpeg 解析的(例如 .ts/.mp4/.h264/.h265)。
123130
124- ``` bash
125- $ google-chrome-stable http://127.0.0.1:8082/docs
126- ```
131+ ## 六、视频识别 FAQ
127132
128- ![ ] ( images/cat_finder_video_select.jpg )
133+ * 如果用 wsl2 部署,注意区分物理机和虚拟机的 ip
134+ * 如果服务部署在 docker 里,同样可以把 8082 端口映射到宿主机端口
129135
130- ` try it out ` 其中的 ` /start/{url} ` 接口,输入 rtsp 地址(例如“rtsp://127.0.0.1:8554/test1.ts”),会返回 stream_id(例如 0)。
136+ ## 七、运行
137+
138+ ### 1)WebUI 方式
139+
140+ ` try it out ` 其中的 ` /start/{url} ` 接口,输入 rtsp 地址(如“rtsp://127.0.0.1:8554/test1.ts”或者“/home/name/file.mp4”),会返回 stream_id(例如 0)。
131141
132142* 服务将打印相关日志
133143
@@ -150,13 +160,10 @@ $ redis-cli
1501602) " notification.cat_finder"
1511613) " feature.pingai"
152162```
153- 用 ` brpop notification.cat_finder ` 可消费报警消息。
154-
163+ 用 ` rpop notification.cat_finder ` 可消费报警消息。
155164
156- ## 六、视频识别 FAQ
157- 如果用 wsl2 部署,注意区分物理机和虚拟机的 ip。
158-
159- 如果服务部署在 docker 里,同样可以把 8082 端口映射到宿主机端口;对应的 ` cURL ` 命令参考
165+ ### 2)命令行方式
166+ 对应的 ` cURL ` 命令参考
160167``` bash
161168$ curl -X POST ' http://127.0.0.1:8082/start/rtsp%3A%2F%2F127.0.0.1%3A8554%2Ftest1.ts' # start rtsp://127.0.0.1:8554/test1.ts
162169start stream whose id is 2%
@@ -165,7 +172,10 @@ $ curl 'http://127.0.0.1:8082/list' # list all stream
165172```
166173路径中的 ` %2F ` 、` %3A ` 是 [ URL] ( https://www.ietf.org/rfc/rfc1738.txt ) 的转义字符
167174
168- ## 七、模型列表
175+ ### 3)Python 代码方式
176+ 参照 [ simple_det_classify client.py] ( ../simple_det_classify/client.py ) 实现
177+
178+ ## 八、模型列表
169179
170180本服务有以下模型的痕迹
171181
0 commit comments