简体   繁体   English

Object 使用 YOLO 检测:获取每个检测到的 object 的计数

[英]Object Detection using YOLO : get count of each detected object

I am using YOLO to identify objects which is working fine however, I want to get count of the vehicles identified and to apply some calc_pollution further.我正在使用 YOLO 来识别工作正常的对象,但是,我想获得识别的车辆的数量并进一步应用一些calc_pollution I am using below code however, I am getting error: TypeError: list indices must be integers or slices, not tuple for the line: L = [labels.get(value) for index,value in enumerate(v_labels[0]) if v_scores[0,index] > 0.1]但是,我正在使用以下代码,但出现错误: TypeError: list indices must be integers or slices, not tupleL = [labels.get(value) for index,value in enumerate(v_labels[0]) if v_scores[0,index] > 0.1]

# correct the sizes of the bounding boxes for the shape of the image
correct_yolo_boxes(boxes, image_h, image_w, input_h, input_w)
# suppress non-maximal boxes
do_nms(boxes, 0.5)
# define the labels
labels = ["person", "bicycle", "car", "motorbike", "aeroplane", "bus", "train", "truck",
    "boat", "traffic light", "fire hydrant", "stop sign", "parking meter", "bench",
    "bird", "cat", "dog", "horse", "sheep", "cow", "elephant", "bear", "zebra", "giraffe"]
# get the details of the detected objects
v_boxes, v_labels, v_scores = get_boxes(boxes, labels, class_threshold)
# summarize what we found
for i in range(len(v_boxes)):
    print(v_labels[i], v_scores[i])
# draw what we found
draw_boxes(photo_filename, v_boxes, v_labels, v_scores)
# Filtering results
L = [labels.get(value) for index,value in enumerate(v_labels[0]) if v_scores[0,index] > 0.1]
M=[]
vehicles=['car','bus','truck','motorcycle','auto-rickshaw']
for i in L:
  if i['name']in vehicles:
    M.append(i['name'])
S=set(M)
text=''
car=motorcycle=truck=bus=auto_rickshaw=0
for i in S:
  if i == 'car': car += M.count(i)
  if i == 'motorcycle': motorcycle += M.count(i)
  if i == 'truck': truck += M.count(i)
  if i == 'bus': bus += M.count(i)
  if i == 'auto-rickshaw' : auto_rickshaw += M.count(i)
  text+=str(i +' : '+ str(M.count(i))+"\t" )
print('Vehicles Identified -',text)
calc_pollution(car, motorcycle, truck, bus, auto_rickshaw)

Any help would be appreciated.任何帮助,将不胜感激。

Is v_scores a list of nested lists? v_scores 是嵌套列表的列表吗? Is so, you would need to change this part v_scores[0,index] to something like v_scores[0][index]是这样,您需要将这部分v_scores[0,index]更改为类似v_scores[0][index]

If that doesn't work, please share more information about the contents of v_boxes, v_labels, and v_scores.如果这不起作用,请分享有关 v_boxes、v_labels 和 v_scores 内容的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Windows中的YOLO对象检测 - YOLO object detection in windows 如何在YOLO物体检测中获取边界框的坐标? - How to get the coordinates of the bounding box in YOLO object detection? (-212:Parsing error) 在使用 yolo、google colab 和 opencv 的对象检测中 - (-212:Parsing error) in Object Detection using yolo, google colab and opencv 如何在 Yolo model 中检测到特定检测到的 object - how to detect a particular detected object in Yolo model 在 Hololens 上实现 YOLO/Tensorflow 对象检测 - Implementing YOLO/Tensorflow object detection on Hololens 具有距离测量和音频反馈的 YOLO 物体检测 - YOLO Object Detection with distance measurement and audio feedback Yolo对象检测网络摄像头OpenCV错误 - Yolo object detection webcam opencv error 打印使用TF时检测到的类和分数Object检测API - Print the detected classes and scores when using TF Object Detection API yolo v3如何提取检测到的物体的图像 - yolo v3 how to extract an image of a detected object 如何从 TensorFlow/OpenCV ZA8CFDE6331CFEB6669CFDE6331CFEB68 检测到的每个 Object 报告中触发 JSON 或 pd Dataframe 报告 - How do I trigger a JSON or pd Dataframe report from each Object detected by a TensorFlow/OpenCV object detection
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM