speed_detection.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:ETS2Autopilot 作者: BrunoTh 项目源码 文件源码
def get_speed(frame):
    """
    :param frame: Captured image
    :return: Speed
    """
    # Disable speed detection
    return 0
    speed = frame[settings.IMAGE_SPEED_Y[0]:settings.IMAGE_SPEED_Y[1], settings.IMAGE_SPEED_X[0]:settings.IMAGE_SPEED_X[1]]
    speed_gray = cv2.cvtColor(speed, cv2.COLOR_BGR2GRAY)

    # Zoom
    rows, cols = speed_gray.shape[:2]
    M = np.float32([[2, 0, 0], [0, 2, 0]])
    speed_zoom = cv2.warpAffine(speed_gray, M, (cols * 2, rows * 2))
    _, speed_threshold = cv2.threshold(speed_zoom, 210, 255, cv2.THRESH_BINARY)

    to_detect = speed_threshold[:, 26:]
    #cv2.imshow('speed', to_detect)
    to_detect = cv2.resize(to_detect, (20, 20))
    to_detect = to_detect.reshape((1, 400))
    to_detect = np.float32(to_detect)
    _, results, _, _ = model.findNearest(to_detect, k=1)

    return int((results[0][0]))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号