tensorflow - What should I add so that when the system detects some specific object it will play an alert sound?
问题描述
I have done the object detection api using webcam, the system was run successful detected object, now i want to add, when the system detected some specific object it will play diff alert sound
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
my system is auto detect dangerous weapon, when my system detected "Gun", or "Knife" it will alert security by using sound alarm.
解决方案
插入循环
import winsound
if category_index=='index of knife':
windsound.beep(duration(ms),frequency)
else:
pass
推荐阅读
- reactjs - 刷新反应应用程序时出现nginx 404错误
- android - 我在 android 9 中面临这个问题,android 底部软键按钮隐藏了 textview 和按钮
- php - 在 PHP 中比较两个对象数组的最有效方法
- windows - Spark 在 Windows 上使用的临时文件的默认文件夹是什么?
- puppeteer - 如何将 json 对象传递给 $eval 函数
- paypal - Drupal 7/PayPal Express Checkout:如何根据地址设置送货选项
- arduino - ESP8266/Arduino:为什么需要将 ICACHE_RAM_ATTR 宏添加到 ISR 和从那里调用的函数?
- c# - 对每个模型中字符串类型的所有属性使用特定的正则表达式
- java - 以下布尔表达式将被评估为什么值?!(假) && (5 > 4)
- javascript - Express-Validator 自动生成的错误消息