赞
踩
yolo调用海康威视网络摄像头踩坑记_yolov5连接海康摄像头-CSDN博客
python调用海康威视的摄像头,实时显示监控内容 - 御世制人 - 博客园 (cnblogs.com)
DOC000065841-UD20825B_海康威视网络摄像机(G3渠道)操作手册_V5.5.150.PDF (hikvision.com)
海康威视IPC摄像头rtsp接入 - Dapenson - 博客园 (cnblogs.com)
边缘设备型号:jetson xavier nx developer kit
连接显示器,键盘,鼠标,电源即可使用,通过网线接口与摄像头连接。
ultralytics/yolov5 at v6.1 (github.com)
yolo算法在边缘设备上的运行,先装conda,再配环境,不再赘叙。
产品型号:iDS-2DY9440lX-A/SP T5
连接电源即可使用,通过网线与边缘设备连接。
说明:我先在windows系统本机进行操作,再迁移到边缘设备进行操作!
官方客服给的回答如下:摄像机怎么激活?
(1)我选择方法2,下载软件后(windows本机操作),通过网线连接摄像头,就可以在软件中检索到设备,然后进行网络参数的修改,查看摄像头IP地址,可以修改成自己想要的,比如192.168.1.xx
(2)接下来很重要的一步,我参考这篇文章:http://t.csdnimg.cn/npQY2,打开控制面板,通过网线连接电脑和摄像头后,可以找到“以太网”,就是我们跟摄像头连接的网线,记住不是“WLAN”,然后设置以太网属性,双击IPv4 ,设置ip地址前面三位跟摄像头的ip地址一致,后面一个不同,随便什么都可以,即摄像头的ip地址和网线的ip地址在同一网段,示例如下:
(3)接下来,安装客服给的方法3操作,在网页中输入摄像头的IP地址,如192.168.1.xx,进行注册登录就可以使用摄像头了。
我们把在本机的操作迁移到边缘设备上,记住我们在本机上查到的摄像头IP地址。
通过网线连接摄像头和边缘设备,然后同样地,修改边缘设备IP的前三位与摄像头IP一致,也是以太网进行有线设置。
设置完之后,在浏览器上输入摄像头的IP地址,并进行登录就可以了。
强调:一定要在同一局域网,否则连接超时
理论上运行如下命令行就可以,python detect.py --weights yolov5s.pt --source 0,但我们用的是网络摄像头,比如把摄像头的网络地址传输进去,在参数“--source”这里把default改为摄像头的rtsp地址,rtsp地址又是什么呢?基本格式就是rtsp://用户名:密码@ip地址/Streaming/Channels/2,用户名和密码就是你用网页登录摄像头IP是注册的账户和密码,然后@后面是摄像头的IP。
参考了海康威视IPC摄像头rtsp接入 - Dapenson - 博客园 (cnblogs.com)这篇比较多,下载了IVMS软件客户端软件 - 视频专区 - 海康威视 Hikvision,管理摄像头的相关信息。
parser.add_argument('--source', type=str, default='rtsp://admin:密码@192.168.1.xxx/Streaming/Channels/2', help='file/dir/URL/glob, 0 for webcam')
设置完毕后,运行代码:
python detect.py --weights yolov5s.pt
会出现报错,一个一个解决就行,比较麻烦的是如下报错:
- etect: weights=['yolov5s.pt'], source=rtsp://admin:20202024zfc@192.168.110.115/Streaming/Channels/2, data=data/coco128.yaml, imgsz=[640, 640], conf_thres=0.25, iou_thres=0.45, max_det=1000, device=, view_img=False, save_txt=False, save_conf=False, save_crop=False, nosave=False, classes=None, agnostic_nms=False, augment=False, visualize=False, update=False, project=runs/detect, name=exp, exist_ok=False, line_thickness=3, hide_labels=False, hide_conf=False, half=False, dnn=False
- YOLOv5 2022-2-22 torch 2.0.0+nv23.05 CUDA:0 (Xavier, 14903MiB)
-
- Fusing layers...
- Model Summary: 213 layers, 7225885 parameters, 0 gradients, 16.4 GFLOPs
- WARNING: Environment does not support cv2.imshow() or PIL Image.show() image displays
- OpenCV(4.10.0) /io/opencv/modules/highgui/src/window.cpp:1301: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvShowImage'
-
- 1/1: rtsp://admin:20202024zfc@192.168.110.115/Streaming/Channels/2... Success (inf frames 704x576 at 25.00 FPS)
-
- Traceback (most recent call last):
- File "detect.py", line 257, in <module>
- main(opt)
- File "detect.py", line 252, in main
- run(**vars(opt))
- File "/home/hebeu/miniconda3/envs/yolov5_detection/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
- return func(*args, **kwargs)
- File "detect.py", line 115, in run
- for path, im, im0s, vid_cap, s in dataset:
- File "/home/hebeu/david_workspace/code/yolov5-6.1/utils/datasets.py", line 353, in __next__
- if not all(x.is_alive() for x in self.threads) or cv2.waitKey(1) == ord('q'): # q to quit
- cv2.error: OpenCV(4.10.0) /io/opencv/modules/highgui/src/window.cpp:1367: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvWaitKey'
即:
- sudo apt-get install libgtk2.0-dev pkg-config
- pip uninstall opencv-python-headless
- pip uninstall opencv-python
- pip install open-python
还有一个报错:
- Traceback (most recent call last):
- File "detect.py", line 42, in <module>
- from models.common import DetectMultiBackend
- File "/home/hebeu/david_workspace/code/yolov5-6.1/models/common.py", line 24, in <module>
- from utils.datasets import exif_transpose, letterbox
- File "/home/hebeu/david_workspace/code/yolov5-6.1/utils/datasets.py", line 29, in <module>
- from utils.augmentations import Albumentations, augment_hsv, copy_paste, letterbox, mixup, random_perspective
- File "/home/hebeu/david_workspace/code/yolov5-6.1/utils/augmentations.py", line 12, in <module>
- from utils.general import LOGGER, check_version, colorstr, resample_segments, segment2box
- File "/home/hebeu/david_workspace/code/yolov5-6.1/utils/general.py", line 46, in <module>
- cv2.setNumThreads(0) # prevent OpenCV from multithreading (incompatible with PyTorch DataLoader)
- AttributeError: module 'cv2' has no attribute 'setNumThreads'
解决方法如下:
pip install --upgrade opencv-python
最后运行就可以了!
结果如下:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。