├── __init__.py
├── Network
├── __init__.py
└── cam_link.py
├── Configuration
├── __init__.py
└── config.py
├── read_HIK_Cam
├── __init__.py
├── read_cam.py
└── read_save_cam.py
├── config.ini
├── .idea
├── vcs.xml
├── misc.xml
├── preferred-vcs.xml
├── inspectionProfiles
│ └── profiles_settings.xml
├── modules.xml
└── HIK_FaceDetec_DL_System.iml
└── README.md
/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Network/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Configuration/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/read_HIK_Cam/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/config.ini:
--------------------------------------------------------------------------------
1 | [accountConf]
2 | user = admin
3 | password = 520douxiao
4 | [ipConf]
5 | host = 192.168.199.64
6 | port = 8000
7 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # HIK_FaceDetec_DL_System
2 | 该代码完成对海康威视摄像头的读取(也适用使用普通的摄像头),同时开发其基于深度学习的人脸识别和物体检测功能。
3 |
4 | 该代码的开发环境是: Ubuntu16.04 python3.5.2 opencv3.2 tensorflow1.4
5 |
6 | 1、Configuration是用来配置该工程中用到的一些固定的参数,如IP地址。
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/preferred-vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Git
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/HIK_FaceDetec_DL_System.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Network/cam_link.py:
--------------------------------------------------------------------------------
1 | # coding=utf-8
2 | from Configuration.config import *
3 | import os
4 | ip = get_ip()
5 | #print(ip)
6 |
7 | def cam_link():
8 | cmd = "ping -c 1 %s" % ip
9 | response = os.system(cmd) # 如果连接成功会返回0
10 | if response == 0:
11 | print("HIKCam is connected !")
12 | return 0
13 | else:
14 | print("HIKCam is not connected !")
15 | return 1
16 |
17 | if __name__ == "__main__":
18 | cam_link()
19 |
20 |
21 |
--------------------------------------------------------------------------------
/read_HIK_Cam/read_cam.py:
--------------------------------------------------------------------------------
1 | # coding=utf-8
2 | import cv2
3 | from Configuration.config import * # 引入配置文件包
4 | from Network.cam_link import cam_link
5 |
6 | link = cam_link()
7 | while(True): # 等待摄像头连接
8 | print("未检测到摄像头,请检查设备连接!")
9 | link = cam_link()
10 | if link == 0:
11 | break
12 | source = get_rtsp()
13 | cam = cv2.VideoCapture(source)
14 |
15 | while (True):
16 | # get a frame
17 | ret, frame = cam.read()
18 | # show a frame
19 | cv2.imshow("window", frame)
20 | if cv2.waitKey(1) & 0xff == ord('q'):
21 | break
22 | # 释放摄像头对象和窗口
23 | cam.release()
24 | cv2.destroyAllWindows()
25 |
--------------------------------------------------------------------------------
/read_HIK_Cam/read_save_cam.py:
--------------------------------------------------------------------------------
1 | # coding=utf-8
2 | import os
3 | import shlex
4 | import subprocess
5 |
6 | source = "rtsp://admin:520douxiao@192.168.199.64/Streaming/Channels/1"
7 | cam_save_dir = "/data/视频/HIK_cam"
8 | if not os.path.exists(cam_save_dir): # 如果保存文件路径不存在就创建一个
9 | os.makedirs(cam_save_dir)
10 |
11 | cmd = "ping -c 1 192.168.199.64"
12 | args = shlex.split(cmd)
13 | try:
14 | subprocess.check_call(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
15 | print("baidu server is up!")
16 | except subprocess.CalledProcessError:
17 | print("Failed to get ping.")
18 |
19 | # cam = cv2.VideoCapture(source)
20 |
--------------------------------------------------------------------------------
/Configuration/config.py:
--------------------------------------------------------------------------------
1 | # coding=utf-8
2 | import configparser
3 | import os
4 |
5 | # rootdir = os.getcwd() # 获取配置文件的绝对路径
6 | # rootconf = os.path.join(rootdir, 'config.ini') # 连接路径和相应文件
7 | # print(rootconf)
8 | # 自己在这里犯了一个错误,config.ini应该放在总工程目录下
9 |
10 | config = configparser.ConfigParser()
11 | config.read('/home/douxiao/Desktop/HIK_FaceDetec_DL_System/config.ini') # 读取配置文件中的配置信息
12 |
13 | user = config.get("accountConf", "user")
14 | password = config.get("accountConf", "password")
15 | host = config.get("ipConf", "host")
16 | port = config.get("ipConf", "port")
17 |
18 |
19 | def get_rtsp():
20 | # 海康威视摄像头的RSTP地址
21 | # 海康威视摄像头采用的是RTSP协议 RTSP 实时串流协议(Real time stream protocol,RTSP)
22 | # 是一种网络应用协议,专为娱乐和通信系统使用,以控制流媒体服务器。
23 | rtsp = "rtsp://%s:%s@%s/Streaming/Channels/1" % (user, password, host)
24 | print(rtsp)
25 | return rtsp
26 |
27 |
28 | def get_ip():
29 | return host
30 |
31 | def get_port():
32 | return port
33 |
34 |
35 | if __name__ == "__main__":
36 | get_rtsp()
37 | get_ip()
38 | get_port()
--------------------------------------------------------------------------------