def verify_street(frame):
    """
    Verify street of the LEGO car - image processing must see more than 50 percent of the image as a road
    this function is using road segmentation network
    :param frame: image from from the camera
    """
    frame_num = 0

    frames_path = os.path.join(os.path.dirname(__file__), 'src', 'frames')
    road_model_xml = os.getcwd() + "/src/data/road-segmentation/road-segmentation-adas-0001.xml"
    road_model_bin = os.path.splitext(road_model_xml)[0] + ".bin"

    road_net = IENetwork(model=road_model_xml, weights=road_model_bin)
    log.info("Road-Segmentation network has been loaded:\n\t{}\n\t{}".format(road_model_xml, road_model_bin))
    assert len(road_net.inputs.keys()) == 1, "Sample supports only single input topologies"
    assert len(road_net.outputs) == 1, "Sample supports only single output topologies"
    log.info("Preparing input blobs")
    input_blob = next(iter(road_net.inputs))
    out_blob = next(iter(road_net.outputs))
    road_net.batch_size = 1
    log.info("Batch size is {}".format(road_net.batch_size))

    # Read and pre-process input images
    n, c, h, w = road_net.inputs[input_blob].shape
    images = np.ndarray(shape=(n, c, h, w))

    if frame.shape[:-1] != (h, w):
        log.warning("Image {} is resized from {} to {}".format("CAM", frame.shape[:-1], (h, w)))
        image = cv2.resize(frame, (w, h))

    image = image.transpose((2, 0, 1))  # Change data layout from HWC to CHW
    images[frame_num] = image
    log.info("Snapping frame: {}".format(frame_num))
    frame_num += 1

    # Loading model to the plugin
    log.info("Loading road-segmentation model to the plugin")
    road_exec_net = plugin.load(network=road_net)

    # Start sync inference
    log.info("Starting inference ({} iterations)".format(1))
    infer_time = []
    for i in range(1):
        t0 = time()
        res = road_exec_net.infer(inputs={input_blob: images})
        infer_time.append((time() - t0) * 1000)
    log.info("Average running time of one iteration: {} ms".format(np.average(np.asarray(infer_time))))

    # Processing output blob
    log.info("Processing output blob")
    res = res[out_blob]
    _, _, out_h, out_w = res.shape
    t0 = time()
    for batch, data in enumerate(res):
        classes_map = np.zeros(shape=(out_h, out_w, 3), dtype=np.int)
        for i in range(out_h):
            for j in range(out_w):
                if len(data[:, i, j]) == 1:
                    pixel_class = int(data[:, i, j])
                else:
                    pixel_class = np.argmax(data[:, i, j])
                classes_map[i, j, :] = classes_color_map[min(pixel_class, 20)]

    # Check red color (road) percentage - for verifying road
    RED_MIN = np.array([0, 0, 128])
    RED_MAX = np.array([250, 250, 255])
    classes_map = select_region(classes_map)
    out_img = os.path.join(frames_path, "processed_image.bmp")
    cv2.imwrite(out_img, classes_map)
    log.info("Result image was saved to {}".format(out_img))

    size = classes_map.size
    dstr = cv2.inRange(classes_map, RED_MIN, RED_MAX)
    no_red = cv2.countNonZero(dstr)
    frac_red = np.divide(float(no_red), int(size))
    percent_red = int(np.multiply(frac_red, 100)) + 50  # 50 = black region

    log.info("Road-segmentation processing time is: {} sec.".format((time() - t0) * 1000))
    log.info("Road detected {}% of the frame: ".format(str(percent_red)))

    if percent_red < 50:
        raise Exception("Can't detect any road!! please put the car on a road")

    Verify street of the LEGO car - image processing must see more than 50 percent of the image as a road
    this function is using road segmentation network
    :param frame: image from from the camera
    
apps/driving_pi/driving_pi.py