获取模板
在examples/rtspDeviceShifu中查看模板文件。
批改配置
在examples/rtspDeviceShifu/camera-deployment/deviceshifu-camera-deployment.yaml
中:
spec:
...
template:
...
spec:
containers:
...
- image: edgehub/camera-python:v0.0.1
...
env:
- name: EDGEDEVICE_NAME
value: "edgedevice-camera"
- name: EDGEDEVICE_NAMESPACE
value: "devices"
- name: IP_CAMERA_ADDRESS
value: "192.168.14.254" # 批改此值
- name: IP_CAMERA_USERNAME
value: "admin" # 批改此值
- name: IP_CAMERA_PASSWORD
value: "password" # 批改此值
- name: IP_CAMERA_CONTAINER_PORT
value: "11112" # 批改此值
...
举荐应用Secret存储明码,对于接入设施这是不必要的,然而这样会大大增强安全性
- 创立 Secret,在 rtsp_password 字段填写明码
kubectl create secret generic deviceshifu-secret --from-literal=rtsp_password=your_password -n deviceshifu
- 将环境变量IP_CAMERA_PASSWORD的值批改为从Secret中获取
- name: IP_CAMERA_PASSWORD
valueFrom:
secretKeyRef:
name: deviceshifu-secret
key: rtsp_password
optional: false
查看摄像头的ip地址能够应用海康威视提供的官网工具:
SADP
macOS下载
Windows下载
部署deviceShifu
执行上面的命令:
kubectl apply -f examples/rtspDeviceShifu/camera-deployment
与deviceShifu交互
在examples/rtspDeviceShifu/camera-deployment/deviceshifu-camera-configmap.yaml
中:
data:
...
instructions: |
...
instructions:
capture:
info:
stream:
move/up:
move/down:
move/left:
move/right:
您能够通过这些指令与数字孪生交互,这等同于操作理论的海康威视摄像头。
通过浏览器拜访摄像头
咱们能够通过service 来实现对 pod 的拜访 , 在默认的yaml 文件中咱们曾经设置了对应的 service , 当初只须要用它启用端转发
通过上面的命令取得以后的 service列表
kubectl get svc -A
其中存在工夫最短的应该就是咱们刚刚增加的service , 通过上面命令咱们开启端口转发
kubectl port-forward -n deviceshifu svc/<填入刚刚增加的service名> 3000:
运行顺利的话咱们能够看到如下输入
Forwarding from 127.0.0.1:3000 -> 8080
Forwarding from [::1]:3000 -> 8080
而后就能够实现从浏览器拜访摄像头了 比方拜访localhost:3000/info
应该就会显示摄像头相干的信息 将info 替换为其余的 instruction 就能够实现对应的性能。
本文由边无际受权公布
发表回复