<jupyter_start><jupyter_text>Initialization<jupyter_code>cm = np.load('serialize/camera_matrix.npy')
dc = np.load('serialize/dist_coefs.npy')
CANVAS_SZ = (500, 1500)
OFFSET_X = 100
OFFSET_Y = 0

straight_images_files = ('test_images/straight_lines1.jpg', 'test_images/straight_lines2.jpg')
straight_images = [lanelines.open_image(f, convert_to_rgb=True) for f in straight_images_files]
straight_images_undist = [cv2.undistort(im, cm, dc) for im in straight_images]

warp_src = roadplane.define_flat_plane_on_road(straight_images_undist, x_offset=0)
warp_src[1, 0] += 8 # <- a hack
warp_dst = lanelines.get_rectangle_corners_in_image(CANVAS_SZ, offset_x=OFFSET_X, offset_y=OFFSET_Y)

M = cv2.getPerspectiveTransform(warp_src, warp_dst)
Minv = cv2.getPerspectiveTransform(warp_dst, warp_src)
test_images = [lanelines.open_image(f, convert_to_rgb=True) for f in glob('test_images/*.jpg')]
test_images_undist = [cv2.undistort(im, cm, dc) for im in test_images]<jupyter_output><empty_output><jupyter_text>Pipeline<jupyter_code>runner = CompGraphRunner(cg, frozen_tokens=cg_params)

nxpd.draw(runner.token_manager.to_networkx())<jupyter_output><empty_output><jupyter_text>Experiments<jupyter_code>last_y = CANVAS_SZ[1]
PIXELS_PER_METER = 50

plt.figure(figsize=(20, 5))

for i, im in enumerate(test_images_undist):
    runner.run(image=im, M=M)
    
    plt.subplot(1, 8, i+1)
    plt.imshow( runner['all_thresholds'])
    _ = plt.axis('off')
    
    poly_y, poly_x_left, poly_x_right = lanelines.get_lane_polynomials_points( 
        runner['warped'],
        runner['p_coefs_left'], 
        runner['p_coefs_right']
    )
    
    plt.plot(poly_x_left, poly_y, color='c')
    plt.plot(poly_x_right, poly_y, color='c')
    
    curv_left = lanelines.curvature_poly2(runner['p_coefs_left'], last_y)
    curv_right = lanelines.curvature_poly2(runner['p_coefs_right'], last_y)
    
    plt.title('{:.2f}, {:.2f}'.format(curv_left / PIXELS_PER_METER, curv_right / PIXELS_PER_METER))

plt.figure(figsize=(10, 15))

plt.imshow(runner['warped'])
for i in range(60):
    plt.axhline(i * 20, color='c')
    
for i in range(25):
    plt.axvline(i * 20, color='c')
pix_lane = 13.5 * 20
pix_dash = 9 * 20

pix_lane, pix_dash
m_lane = 3.7
m_dash = 3.

p_x = m_lane / pix_lane
p_y = m_dash / pix_dash

p_x, p_y<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1326442721791559, 'fraction_numerical': 0.02454780361757106, 'mean_word_length': 5.599431818181818, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '513274', 'license': 'MIT', 'n_tokens_mistral': 1022, 'n_tokens_neox': 961, 'n_words': 144, 'path': '11_pixel_to_meter_ratios.ipynb', 'repo_name': 'semeniuta/CarND-AdvancedLaneLines', 'size': '2322'}