2020年大三下学期第十八周学习心得

主要在复习操作系统,但是通过学习,我做了一个逐帧检测画面识别各个物体数量的功能。

 for i in indices:
            i = i[0]
            box = boxes[i]
            left = box[0]
            top = box[1]
            width = box[2]
            height = box[3]
            print(str(classes[classIds[i]]))
            if(str(classes[classIds[i]])=="person"):
                person+=1
                num=[person,car,motorbike,bus,bicycle]
            if(str(classes[classIds[i]])=="car"):
                car+=1
                num=[person,car,motorbike,bus,bicycle]
            if (str(classes[classIds[i]]) == "motorbike"):
                motorbike += 1
                num = [person, car, motorbike, bus,bicycle]
            if (str(classes[classIds[i]]) == "bus"):
                bus += 1
                num = [person, car, motorbike, bus,bicycle]
            if (str(classes[classIds[i]]) == "bicycle"):
                bicycle += 1
                num = [person, car, motorbike, bus,bicycle]
        return num

  

 label = 'Inference time: %.2f ms' % (t * 1000.0 / cv.getTickFrequency())
    cv.putText(frame, label, (0, 15), cv.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255))
    label = 'Person num:%s' % (postprocess2(frame,outs)[0])
    cv.putText(frame, label, (0, 30), cv.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 0))
    label = 'Car num:%s' % (postprocess2(frame, outs)[1])
    cv.putText(frame, label, (0, 45), cv.FONT_HERSHEY_SIMPLEX, 0.5, (240, 255, 255))
    label = 'Motorbike num:%s' % (postprocess2(frame, outs)[2])
    cv.putText(frame, label, (0, 60), cv.FONT_HERSHEY_SIMPLEX, 0.5, (245, 245, 245))
    label = 'Bus num:%s' % (postprocess2(frame, outs)[3])
    cv.putText(frame, label, (0, 75), cv.FONT_HERSHEY_SIMPLEX, 0.5, (255, 97, 0))
    label = 'Bicycle num:%s' % (postprocess2(frame, outs)[4])
    cv.putText(frame, label, (0, 90), cv.FONT_HERSHEY_SIMPLEX, 0.5, (255, 230, 201))
    # Write the frame with the detection boxes

  截图:

原文地址:https://www.cnblogs.com/jccjcc/p/13098167.html