Example #1
0
    # Write info on the image
    annotated_frame = frame
    cv2.putText(annotated_frame, "Count: %s" % tracker.counted_blobs, (120, 295), cv2.FONT_HERSHEY_COMPLEX_SMALL, 0.75, (255, 255, 255))

    # Draw a diagonal blue line with thickness of 5 px
    if blob_count != tracker.counted_blobs:
        cv2.line(annotated_frame, (200, 300), (300, 300), (150, 255, 255), 2)
        blob_count = tracker.counted_blobs
    else:
        cv2.line(annotated_frame, (200, 300), (300, 300), (150, 150, 255), 2)

    if show_more_info:
        annotated_frame = cv2.drawKeypoints(annotated_frame, keypoints, np.array([]), (0, 0, 255),
                                            cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
        tracker.draw_live_ids(annotated_frame)
        tracker.draw_predictions(annotated_frame)
        cv2.putText(annotated_frame, "Frame %d" % frame_counter, (600, 20), cv2.FONT_HERSHEY_COMPLEX_SMALL, 0.75, (255, 255, 255))
        cv2.putText(annotated_frame, "keypts %d" % len(keypoints), (600, 40), cv2.FONT_HERSHEY_COMPLEX_SMALL, 0.75, (255, 255, 255))
        cv2.putText(annotated_frame, "Live %s" % tracker.live_blobs, (600, 60), cv2.FONT_HERSHEY_COMPLEX_SMALL, 0.75, (255, 255, 255))


    # Display results
    if show_debug_img:
        cv2.imshow('gray', gray)
        cv2.imshow('fgmask', fgmask)
        cv2.imshow('opening', opening)

    cv2.imshow('result', annotated_frame)
    if out is not None:
        out.write(annotated_frame)