我已经使用网络摄像头完成了对象检测api,系统已成功运行了检测到的对象,现在我想添加,当系统检测到某些特定对象时,它将播放差异警报声音
while True:
# Acquire frame and expand frame dimensions to have shape: [1, None, None, 3]
# i.e. a single-column array, where each item in the column has the pixel RGB value
ret, frame = video.read()
frame_expanded = np.expand_dims(frame, axis=0)
# Perform the actual detection by running the model with the image as input
(boxes, scores, classes, num) = sess.run(
[detection_boxes, detection_scores, detection_classes, num_detections],
feed_dict={image_tensor: frame_expanded})
# Draw the results of the detection (aka 'visulaize the results')
vis_util.visualize_boxes_and_labels_on_image_array(
frame,
np.squeeze(boxes),
np.squeeze(classes).astype(np.int32),
np.squeeze(scores),
category_index,
use_normalized_coordinates=True,
line_thickness=8,
min_score_thresh=0.60)
#if xxxxx:
# alert.play()
#else:
# pass
# All the results have been drawn on the frame, so it's time to display it.
cv2.imshow('Object detector', frame)
# Press 'q' to quit
if cv2.waitKey(1) == ord('q'):
break
我的系统是自动检测危险武器,当我的系统检测到“枪”或“刀”时,它将通过声音警报来提醒安全。
答案 0 :(得分:0)
对于Windows
import winsound
winsound.PlaySound("sound_file.wav", FLAG)
或只是哔哔声
import winsound
dur = 500 # as millisecond
freq = 2000 # sound frequency
winsound.Beep(freq, dur)
您可以检查文件 https://docs.python.org/3.7/library/winsound.html
用于其他操作系统(Linux,Mac等)
import os
os.system("sound_file.wav&")
答案 1 :(得分:0)
插入循环
Date Planned_x Actuals ... C2P (%) Planned_y Delta
766 2019-09-19 284.000000 439.0 ... NaN NaN -155.000000
767 2019-09-20 284.000000 469.0 ... NaN NaN -185.000000
768 2019-09-21 260.000000 240.0 ... NaN NaN 20.000000
769 2019-09-22 305.000000 229.0 ... NaN NaN 76.000000
770 2019-09-23 351.000000 225.0 ... 0.533391 NaN 126.000000
771 2019-09-24 387.353430 1.0 ... NaN NaN 386.353430
772 2019-09-25 444.317519 152.0 ... NaN NaN 292.317519
773 2019-09-26 475.557830 300.0 ... NaN NaN 175.557830
774 2019-09-27 404.524517 150.0 ... NaN NaN 254.524517
775 2019-09-28 355.303705 550.0 ... NaN NaN -194.696295