Commit ·
b4b4853
1
Parent(s): c6987bc
update gradio
Browse files- .gitignore +1 -0
- hikvision.py +40 -0
- requirements.txt +1 -1
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
__pycache__
|
hikvision.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import cv2
|
| 2 |
+
import numpy as np
|
| 3 |
+
|
| 4 |
+
# hikvision_cameras_dict = {
|
| 5 |
+
# 1: cv2.VideoCapture("rtsp://admin:Admin123@192.168.254.200:554/Streaming/Channels/101", cv2.CAP_FFMPEG),
|
| 6 |
+
# 2: cv2.VideoCapture("rtsp://admin:Admin123@192.168.254.201:554/Streaming/Channels/101", cv2.CAP_FFMPEG),
|
| 7 |
+
# 3: cv2.VideoCapture("rtsp://admin:Admin123@192.168.254.202:554/Streaming/Channels/101", cv2.CAP_FFMPEG),
|
| 8 |
+
# 4: cv2.VideoCapture("rtsp://admin:Admin123@192.168.254.203:554/Streaming/Channels/101", cv2.CAP_FFMPEG),
|
| 9 |
+
# }
|
| 10 |
+
|
| 11 |
+
hikvision_cameras_dict = {
|
| 12 |
+
1: cv2.VideoCapture("./example_videos/birdsflyingduringsunsetinmadrid_preview-SMALLER.mp4"),
|
| 13 |
+
2: cv2.VideoCapture("./example_videos/birdsflyingovertreesatsunset_preview.mp4"),
|
| 14 |
+
3: cv2.VideoCapture("./example_videos/secondmacarthurbridgetaipei03_preview.mp4"),
|
| 15 |
+
4: cv2.VideoCapture("./example_videos/birdsflyingduringsunsetinmadrid_preview-SMALLER.mp4"),
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
def get_image_from_HIKvision_camera(camera_id):
|
| 19 |
+
global hikvision_cameras_dict
|
| 20 |
+
cap = hikvision_cameras_dict[camera_id]
|
| 21 |
+
if not cap.isOpened():
|
| 22 |
+
print("Error: Could not open video stream.")
|
| 23 |
+
return np.zeros((256,256,3))
|
| 24 |
+
ret, frame = cap.read()
|
| 25 |
+
if ret:
|
| 26 |
+
return frame
|
| 27 |
+
else:
|
| 28 |
+
print("Failed to grab frame")
|
| 29 |
+
|
| 30 |
+
return np.zeros((256,256,3))
|
| 31 |
+
|
| 32 |
+
def release_all_caps(dummy_variable=None):
|
| 33 |
+
global hikvision_cameras_dict
|
| 34 |
+
{
|
| 35 |
+
(k,cap.release()) for (k,cap) in hikvision_cameras_dict.items()
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
# # Example usage:
|
| 39 |
+
# frame = get_image_from_HIKvision_camera(
|
| 40 |
+
# camera_id = 1)
|
requirements.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
gradio==5.
|
| 2 |
matplotlib==3.6.0
|
| 3 |
numpy==1.26.4
|
| 4 |
opencv_python==4.9.0.80
|
|
|
|
| 1 |
+
gradio==5.34.0
|
| 2 |
matplotlib==3.6.0
|
| 3 |
numpy==1.26.4
|
| 4 |
opencv_python==4.9.0.80
|