def main():
    """Main entry point from the terminal to run the calibration routine."""
    # Parse in arguments
    parser = argparse.ArgumentParser(
        description='Calibrate Images',
        epilog="This software is designed to calibrate a camera based on images"
               " fed in from a folder. Images should be of a grid of white and"
               " black squares or circles. It works best if there is a white"
               " border around the grid and if the number of columns and rows"
               " is different. This can work with any camera, just put the"
               " calibration images in a folder and run this script. For best"
               " results you need at least 10 calibratable images.")

    parser.add_argument("--dir", metavar="directory", type=str,
                        help='The directory of images to calibrate off of.',
                        default="\\")

    parser.add_argument("-s", "--spacing", type=float,
                        help="The grid spacing in mm.", required=True)

    parser.add_argument("-c", "--columns", type=int,
                        help="the number of inner corners horizontally",
                        required=True)

    parser.add_argument("-r", "--rows", type=int,
                        help="the number of inner corners vertically",
                        required=True)

    parser.add_argument("-w", "--window", type=int,
                        help="The size of the window to use for sub-pixel "
                             "localization of the corners", default=11)

    parser.add_argument("--save", help="Whether to save image output",
                        action='store_true', default=True)

    parser.add_argument("--outdir", type=str, help="Where to save image output",
                        default="output")

    parser.add_argument("-v", "--visualize",
                        help="Whether to show visualizations",
                        action='store_true')

    parser.add_argument("--circles",
                        help="Whether to use a circle calibration grid",
                        action='store_true', default=False)

    args = parser.parse_args()

    camera_calibration.calibrate(
        rows=args.rows,
        cols=args.columns,
        win=args.window,
        save=args.save,
        directory_out=args.outdir,
        space=args.spacing,
        visualize=args.visualize,
        circles=args.circles,
        directory=args.dir)
예제 #2
0
def main():

    config = Config()

    # Calibrate camera
    calibrate(config)

    # Create and save histogram for obstacles
    obstacle_image_names = ['obstacles.jpg']
    hist_builder = HistogramBuilder()
    hist = hist_builder.create_histogram(
        obstacle_image_names, config.get_obstacle_hist_bucket_size())
    np.savez(config.get_obstacle_hist_filename(), obstacle_histogram=hist)
 def __init__(self, calibration_images, calibration_nx, calibration_ny,
              logger):
     self.camera_matrix, self.distortion_coeff = cc.calibrate(
         calibration_images, calibration_nx, calibration_ny)
     self.logger = logger
     self.frame_count = 0
     self.left_fit = None
     self.right_fit = None
     self.margin = 100
     self.nwindows = 9
     self.left_lane_lines = []
     self.right_lane_lines = []
     self.previous_lane_count = 0
def processFrame(img):
    objpoints, imgpoints = calibrate(9, 6)
    undist = undistort(objpoints, imgpoints, img)
    sxybinary = convertBinary(undist)
    masked_sxybinary = mask(sxybinary)
    binary_warped, Minv = warp(masked_sxybinary)
    left_fit, right_fit, left_fitx, right_fitx, ploty, leftx, lefty, rightx, righty = visualizeLanes(
        binary_warped)

    left_radius, right_radius = curvature(leftx, lefty, rightx, righty)
    distance = lanePosition(left_fitx, right_fitx, undist)
    img = addData(undist, left_radius, right_radius, distance)

    return drawLane(img, left_fit, right_fit, left_fitx, right_fitx, ploty,
                    binary_warped, Minv)
예제 #5
0
inp_dim = int(model.net_info["height"])
assert inp_dim % 32 == 0
assert inp_dim > 32

#If there's a GPU availible, put the model on GPU
if CUDA:
    model.cuda()

#Set the model in evaluation mode
model.eval()

#########################################################################################################################

# Lane detection and distance estimation code to be run only once

ret, mtx, dist, rvecs, tvecs = camera_calibration.calibrate(False)

#########################################################################################################################

# YOLO prediction function
# Takes BGR image and returns: 1) image annotated with bounding boxes, 2) list of top left and bottom right
# coordinates of bounding boxes, 3) list of class numbers which correspond to class labels


def get_pred(img):
    read_dir = time.time()
    #Detection phase
    imlist = ['img']

    if not os.path.exists(det):
        os.makedirs(det)
예제 #6
0
def main():
    """Main entry point from the terminal to run the calibration routine."""
    # Parse in arguments
    parser = argparse.ArgumentParser(
        description='Calibrate Images',
        epilog="This software is designed to calibrate a camera based on images"
        " fed in from a folder. Images should be of a grid of white and"
        " black squares or circles. It works best if there is a white"
        " border around the grid and if the number of columns and rows"
        " is different. This can work with any camera, just put the"
        " calibration images in a folder and run this script. For best"
        " results you need at least 10 calibratable images.")

    parser.add_argument("--dir",
                        metavar="directory",
                        type=str,
                        help='The directory of images to calibrate off of.',
                        default="\\")

    parser.add_argument("-s",
                        "--spacing",
                        type=float,
                        help="The grid spacing in mm.",
                        required=True)

    parser.add_argument("-c",
                        "--columns",
                        type=int,
                        help="the number of inner corners horizontally",
                        required=True)

    parser.add_argument("-r",
                        "--rows",
                        type=int,
                        help="the number of inner corners vertically",
                        required=True)

    parser.add_argument("-w",
                        "--window",
                        type=int,
                        help="The size of the window to use for sub-pixel "
                        "localization of the corners",
                        default=11)

    parser.add_argument("--save",
                        help="Whether to save image output",
                        action='store_true',
                        default=True)

    parser.add_argument("--outdir",
                        type=str,
                        help="Where to save image output",
                        default="output")

    parser.add_argument("-v",
                        "--visualize",
                        help="Whether to show visualizations",
                        action='store_true')

    parser.add_argument("--circles",
                        help="Whether to use a circle calibration grid",
                        action='store_true',
                        default=False)

    args = parser.parse_args()

    camera_calibration.calibrate(rows=args.rows,
                                 cols=args.columns,
                                 win=args.window,
                                 save=args.save,
                                 directory_out=args.outdir,
                                 space=args.spacing,
                                 visualize=args.visualize,
                                 circles=args.circles,
                                 directory=args.dir)