params_cam = sensor_params["params_cam"]

    rospy.init_node('lane_detector', anonymous=True)

    image_parser = IMGParser()
    bev_op = BEVTransform(params_cam=params_cam)
    curve_learner = CURVEFit(order=1)

    rate = rospy.Rate(20)

    while not rospy.is_shutdown():

        if image_parser.edges is not None:

            img_warp = bev_op.warp_bev_img(image_parser.edges)
            lane_pts = bev_op.recon_lane_pts(image_parser.edges)

            x_pred, y_pred_l, y_pred_r = curve_learner.fit_curve(lane_pts)

            curve_learner.write_path_msg(x_pred, y_pred_l, y_pred_r)

            curve_learner.pub_path_msg()

            xyl, xyr = bev_op.project_lane2img(x_pred, y_pred_l, y_pred_r)

            img_warp1 = draw_lane_img(img_warp, xyl[:, 0].astype(np.int32),
                                      xyl[:, 1].astype(np.int32),
                                      xyr[:, 0].astype(np.int32),
                                      xyr[:, 1].astype(np.int32))

            cv2.imshow("Image window", img_warp1)
Exemplo n.º 2
0
from utils import BEVTransform, STOPLineEstimator

if __name__ == "__main__":

    rp = rospkg.RosPack()

    currentPath = rp.get_path("lane_detection_example")

    with open(os.path.join(currentPath, 'sensor/sensor_params.json'), 'r') as fp:
        sensor_params = json.load(fp)
    
    params_cam = sensor_params["params_cam"]
    
    rospy.init_node('stoplane_detector', anonymous=True)
    image_parser = IMGParser()
    bev_op = BEVTransform(params_cam=params_cam)
    sline_detectpr = STOPLineEstimator()

    rate = rospy.Rate(30)

    while not rospy.is_shutdown():

        if image_parser.img_wlane is not None:
            lane_pts = bev_op.recon_lane_pts(image_parser.img_wlane)

            sline_detectpr.get_x_points(lane_pts)
            sline_detectpr.estimate_dist(0.3)
            sline_detectpr.pub_sline()

            rate.sleep()
Exemplo n.º 3
0
    lane_detector = LINEDetector()

    rate = rospy.Rate(20)
    img_wlane = None

    while not rospy.is_shutdown():

        if lane_detector.cam is not None:
            img_wlane = lane_detector.binary_image()

        if img_wlane is not None:

            # 카메라 이미지를 BEV이미지로 변환
            img_bev = bev_trans.warp_bev_img(img_wlane)
            # 카메라 이미지에서 차선에 해당하는 포인트들을 추출
            lane_pts = bev_trans.recon_lane_pts(img_wlane)

            # 추출한 포인트를 기반으로 차선을 예측
            x_pred, y_pred_l, y_pred_r = pts_learner.fit_curve(lane_pts)

            # 예측한 차선을 Path로 변환하여 메세지의 데이터를 작성
            pts_learner.write_path_msg(x_pred, y_pred_l, y_pred_r)
            # 예측한 차선을 publish topic: /lane_path
            pts_learner.pub_path_msg()

            # 예측한 차선 포인트들을 이미지에 넣기 위해서 변환
            xyl, xyr = bev_trans.project_lane2img(x_pred, y_pred_l, y_pred_r)

            # 예측한 차선 포인트들을 BEV이미지에 넣기
            img_bev_line = draw_lane_img(
                img_bev,
Exemplo n.º 4
0
        sensor_params = json.load(fp)

    params_cam = sensor_params["params_cam"]

    rospy.init_node('StopLine_Detector', anonymous=True)

    # WeCar의 카메라 이미지에서 차선에 관한 포인트들을 추출하기 위해 클래스를 선언
    bev_trans = BEVTransform(params_cam=params_cam)
    # 카메라 이미지에서 추출한 포인트로 차선이 정지선인지 판단 및 정지선까지의 거리를 계산하는 클래스를 선언
    stopline_estimator = STOPLineEstimator()

    stopline_detector = STOPLineDetector()

    rate = rospy.Rate(20)

    while not rospy.is_shutdown():

        if stopline_detector.image_sline is not None:

            # 카메라 이미지에서 차선에 관한 포인트들을 추출
            lane_pts = bev_trans.recon_lane_pts(stopline_detector.image_sline)

            # 추출한 포인트에서 x 값을 받아옴 -> y값의 제한을 둬서 좌우 차선에 해당하는 포인트는 걸러냄
            stopline_estimator.get_x_points(lane_pts)
            # 정지선을 판단 및 정지선까지의 거리를 계산
            stopline_estimator.estimate_dist(30)
            # 정지선까지의 거리를 publish topic: /stop_line
            stopline_estimator.pub_sline()

            rate.sleep()
Exemplo n.º 5
0
        sensor_params = json.load(fp)

    params_cam = sensor_params["params_cam"]

    rospy.init_node('lane_detector', anonymous=True)

    image_parser = IMGParser()
    bev_op = BEVTransform(params_cam=params_cam)
    curve_learner = CURVEFit(order=3)

    rate = rospy.Rate(20)

    while not rospy.is_shutdown():
        img_wlane = image_parser.get_bi_img()
        img_warp = bev_op.warp_bev_img(img_wlane)
        lane_pts = bev_op.recon_lane_pts(img_wlane)

        x_pred, y_pred_l, y_pred_r = curve_learner.fit_curve(lane_pts)

        curve_learner.write_path_msg(x_pred, y_pred_l, y_pred_r)

        curve_learner.pub_path_msg()

        xyl, xyr = bev_op.project_lane2img(x_pred, y_pred_l, y_pred_r)

        img_warp1 = draw_lane_img(img_warp, xyl[:, 0].astype(np.int32),
                                  xyl[:, 1].astype(np.int32),
                                  xyr[:, 0].astype(np.int32),
                                  xyr[:, 1].astype(np.int32))

        cv2.imshow("Image window", img_warp1)