detectionlib_test.py 文件源码

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

项目:autonomous_driving 作者: StatueFungus 项目源码 文件源码
def main():
    print os.getcwd()
    capture = cv2.VideoCapture('../data/road.avi')
    ticks = 0

    img_prep = ImagePreparator()
    vis = Visualizer()

    while capture.isOpened():
        prevTick = ticks
        ticks = cv2.getTickCount()
        t = (ticks - prevTick) / cv2.getTickFrequency()
        fps = int(1 / t)

        retval, image = capture.read()
        height, width, channels = image.shape

        rect = np.array([
            [0, 200],
            [639, 200],
            [639, 359],
            [0, 359]], dtype="float32")

        dst = np.array([
            [0, 0],
            [639, 0],
            [350, 699],
            [298, 699]], dtype="float32")

        # Aufbereitung des Bilder
        warped = img_prep.warp_perspective(image.copy(), rect, dst, (640, 700))
        roi = img_prep.define_roi(warped, 0.6, 0, 0.40)
        gray = img_prep.grayscale(roi)
        blur = img_prep.blur(gray, (5, 5), 0)
        canny = img_prep.edge_detection(blur, 50, 150, 3)

        vis.draw_text(canny, 'FPS: ' + str(fps), 1, (255, 0, 0), (int(width*0.015), int(height*0.15)))
        vis.show(canny)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号