Tensorflow 我应该添加什么,以便当系统检测到某些特定对象时,它将播放警报声音?
我用网络摄像头做了物体检测api,系统运行成功检测到物体,现在我想补充一下,当系统检测到某个特定物体时,它会播放diff alert声音Tensorflow 我应该添加什么,以便当系统检测到某些特定对象时,它将播放警报声音?,tensorflow,object-detection-api,Tensorflow,Object Detection Api,我用网络摄像头做了物体检测api,系统运行成功检测到物体,现在我想补充一下,当系统检测到某个特定物体时,它会播放diff alert声音 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
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
我的系统是自动检测危险武器的,当我的系统检测到“枪”或“刀”时,它将使用声音警报提醒安全。适用于Windows
import winsound
winsound.PlaySound("sound_file.wav", FLAG)
或者只是一声嘟嘟
import winsound
dur = 500 # as millisecond
freq = 2000 # sound frequency
winsound.Beep(freq, dur)
你可以查看文件
适用于其他操作系统(Linux、Mac等)
插入环
import winsound
if category_index=='index of knife':
windsound.beep(duration(ms),frequency)
else:
pass
谢谢回复,我已经导入了pygame,但是我不知道为什么我将结果和pygame结合起来,它不能正常工作
import winsound
if category_index=='index of knife':
windsound.beep(duration(ms),frequency)
else:
pass