【发布时间】:2018-10-27 10:04:15
【问题描述】:
我已按照此处的示例:https://www.youtube.com/watch?v=MoMjIwGSFVQ 并使用网络摄像头进行对象检测。
但我已将网络摄像头切换为使用来自 IP 摄像头的 rtsp 流,我认为它正在流式传输 H264,我现在注意到大约有 30 秒视频滞后,加上视频有时非常停止。
这是进行主要处理的python代码:
import cv2
cap = cv2.VideoCapture("rtsp://192.168.200.1:5544/stream1")
# Running the tensorflow session
with detection_graph.as_default():
with tf.Session(graph=detection_graph) as sess:
ret = True
while (ret):
ret,image_np = cap.read()
# Expand dimensions since the model expects images to have shape: [1, None, None, 3]
image_np_expanded = np.expand_dims(image_np, axis=0)
image_tensor = detection_graph.get_tensor_by_name('image_tensor:0')
# Each box represents a part of the image where a particular object was detected.
boxes = detection_graph.get_tensor_by_name('detection_boxes:0')
# Each score represent how level of confidence for each of the objects.
# Score is shown on the result image, together with the class label.
scores = detection_graph.get_tensor_by_name('detection_scores:0')
classes = detection_graph.get_tensor_by_name('detection_classes:0')
num_detections = detection_graph.get_tensor_by_name('num_detections:0')
# Actual detection.
(boxes, scores, classes, num_detections) = sess.run(
[boxes, scores, classes, num_detections],
feed_dict={image_tensor: image_np_expanded})
# Visualization of the results of a detection.
vis_util.visualize_boxes_and_labels_on_image_array(
image_np,
np.squeeze(boxes),
np.squeeze(classes).astype(np.int32),
np.squeeze(scores),
category_index,
use_normalized_coordinates=True,
line_thickness=8)
# plt.figure(figsize=IMAGE_SIZE)
# plt.imshow(image_np)
cv2.imshow('image',cv2.resize(image_np,(1280,960)))
if cv2.waitKey(25) & 0xFF == ord('q'):
cv2.destroyAllWindows()
cap.release()
break
我是 python 和 tensorflow 的新手。是否应该以任何方式修改此代码以应对 rtsp 流?我的电脑没有 GPU 卡。
【问题讨论】:
-
在不检测的情况下通过流式传输 IP 摄像机获得多少 fps?
-
1080p 的 fps 是 30fps
标签: python opencv tensorflow