【发布时间】:2019-02-28 20:57:55
【问题描述】:
我正在使用 Tensorflow 对象检测 API 来检测 respberry pi 上的对象,它是实时对象检测,并且我可以正常工作。它可以绘制带有标签的边界框和它检测到的类的会议分数。所以这是我的问题:
当检测到特定类时,如何将 GPIO 引脚设为高电平,假设特定类是“人”,并且我希望引脚 11 为高电平,我该怎么做?
这是我认为相关的代码:
# 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=3,
min_score_thresh=0.40)
cv2.putText(frame,"FPS: {0:.2f}".format(frame_rate_calc),(30,50),font,1,(255,255,0),2,cv2.LINE_AA)
# All the results have been drawn on the frame, so it's time to display it.
cv2.imshow('Object detector', frame)
np.squeeze(classes).astype(np.int32) 可以成为获取检测到的类的一种方式吗?
【问题讨论】:
标签: python tensorflow raspberry-pi