if __name__ == '__main__':

    rp = rospkg.RosPack()

    currentPath = rp.get_path("traffic_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('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)
        return imgMat

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('lane_detector',  anonymous=True)

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

    rate = rospy.Rate(30)

    prevTime = curTime = time.time()

    while not rospy.is_shutdown():
        curTime = time.time()
        
        fps = 1 / (curTime - prevTime)
        prevTime = curTime
        fps_str = "FPS: %0.1f" % fps

        ret, img_wlane = image_parser.get_image()
        if not ret: continue
Exemplo n.º 3
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.º 4
0
if __name__ == '__main__':
    rp = rospkg.RosPack()

    currentPath = rp.get_path("lane_detection_example")

    # WeCar의 카메라의 파라미터 값을 적어놓은 json파일을 읽어와서 params_cam으로 저장
    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('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값의 제한을 둬서 좌우 차선에 해당하는 포인트는 걸러냄
Exemplo n.º 5
0
if __name__ == '__main__':
    rp = rospkg.RosPack()

    currentPath = rp.get_path("lane_detection_example")

    # WeCar의 카메라의 파라미터 값을 적어놓은 json파일을 읽어와서 params_cam으로 저장
    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('Line_Detector', anonymous=True)

    # WeCar의 카메라 이미지를 Bird Eye View 이미지로 변환하기 위한 클래스를 선언
    bev_trans = BEVTransform(params_cam=params_cam)
    # BEV로 변환된 이미지에서 추출한 포인트를 기반으로 RANSAC을 이용하여 차선을 예측하는 클래스를 선언
    pts_learner = CURVEFit(order=3)

    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:
if __name__ == '__main__':
    rp = rospkg.RosPack()

    currentPath = rp.get_path("lane_detection_example")

    # WeCar의 카메라의 파라미터 값을 적어놓은 json파일을 읽어와서 params_cam으로 저장
    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('Line_Detector', anonymous=True)

    # WeCar의 카메라 이미지를 Bird Eye View 이미지로 변환하기 위한 클래스를 선언
    bev_trans = BEVTransform(params_cam=params_cam, cut_size=0.55)
    # BEV로 변환된 이미지에서 추출한 포인트를 기반으로 RANSAC을 이용하여 차선을 예측하는 클래스를 선언
    pts_learner = CURVEFit(order=3, init_width=0.5)

    lane_detector = LINEDetector()

    rate = rospy.Rate(20)

    while not rospy.is_shutdown():

        if lane_detector.img_lane is not None:
            img_lane_pts = copy.deepcopy(lane_detector.img_lane)
            img_bev = copy.deepcopy(lane_detector.img_lane)
            # lane_detector.img_lane[:int(0.6*640), :] = 0
            # 카메라 이미지를 BEV이미지로 변환
            img_bev = bev_trans.warp_bev_img(img_bev)