예제 #1
0
    def test_readme_video_images(self):
        # images from sequence in video
        p = pipeline.Pipeline(1)
        imgs = image_util.loadImagesRGB(IMG_DIR2)
        for i, img in enumerate(imgs):
            draw_img, labels, heatmap, boxed_image = p.process_verbose(
                np.copy(img))

            out = image_util.arrangeImages(
                [img, boxed_image, heatmap, labels[0], draw_img],
                ["original", "car detections", "heatmap", "labels", "result"],
                figsize=(5, 1))
            image_util.saveImage(
                out, TEST_OUT_DIR + "/readme_videoprocess" + str(i) + ".png")
        p = pipeline.Pipeline(9)
        imgs = image_util.loadImagesRGB(IMG_DIR2)
        for i, img in enumerate(imgs):
            draw_img, labels, heatmap, boxed_image = p.process_verbose(
                np.copy(img))
            out = image_util.arrangeImages(
                [img, boxed_image, heatmap, labels[0], draw_img],
                ["original", "car detections", "heatmap", "labels", "result"],
                figsize=(5, 1))
            image_util.saveImage(
                out, TEST_OUT_DIR + "/readme_videoprocess_with_history" +
                str(i) + ".png")
예제 #2
0
 def test_process(self):
     p = pipeline.Pipeline()
     imgs = image_util.loadImagesRGB(IMG_DIR)
     for i, img in enumerate(imgs):
         processed_img = p.process(img)
         image_util.saveBeforeAfterImages(
             img, "Original", processed_img, "Thresholded",
             TEST_OUT_DIR + "/thresholded" + str(i) + ".jpg")
예제 #3
0
 def test_03_undistortTestImages(self):
     imgs = image_util.loadImagesRGB(TEST_IMAGES_DIR)
     ret, mtx, dist, rvecs, tvecs = uut.cachedCalibrateCameraFromDir(
         CAMERA_CAL_DIR)
     for i, img in enumerate(imgs):
         dimg = cv2.undistort(img, mtx, dist)
         image_util.saveBeforeAfterImages(
             img, "Original", dimg, "Undistorted",
             TEST_OUT_DIR + "/test_" + str(i) + "_undistorted.png")
예제 #4
0
    def _test_process(self):
        p = pipeline.Pipeline(1)
        imgs = image_util.loadImagesRGB(IMG_DIR)
        for i, img in enumerate(imgs):
            processed_img = p.process(np.copy(img))

            out = image_util.arrangeImages([img, processed_img],
                                           ["original", "car detection"],
                                           figsize=(4, 2))
            image_util.saveImage(
                out, TEST_OUT_DIR + "/identified_boxes" + str(i) + ".png")
def calibrateCameraFromDir(path):
    objpoints = [] # 3d points in real world space
    imgpoints = [] # 2d points in image plane.

    imgs = image_util.loadImagesRGB(path)
    for img in imgs:
        gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
        # Find the chessboard corners
        ret, corners = cv2.findChessboardCorners(gray, CHESS_BOARD_SHAPE, None)

        # If found, add object points, image points
        if ret == True:
            objpoints.append(objp)
            imgpoints.append(corners)

    # Do camera calibration given object points and image points
    img_size = (img.shape[1], img.shape[0])
    ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(objpoints, imgpoints, img_size,None,None)
    return ret, mtx, dist, rvecs, tvecs
예제 #6
0
 def test_sliding_windows_1(self) :
     imgs = image_util.loadImagesRGB(IMG_FILE_DIR)
     for img in imgs:
         # search with box size 64 * 1 = 64
         ystart = 380
         ystop = 480
         scale = 1.0
         self.draw_sliding_windows(TEST_OUT_DIR+"windows_1.png", img, ystart, ystop, scale)
         
         # search with box size 64 * 1.5 = 96
         ystart = 400
         ystop = 600
         scale = 1.5
         self.draw_sliding_windows(TEST_OUT_DIR+"windows_2.png",img,  ystart, ystop, scale)
         
         
         # search with box size 64 * 2.5 = 160
         ystart = 500
         ystop = 700
         scale = 2.5
         self.draw_sliding_windows(TEST_OUT_DIR+"windows_3.png", img, ystart, ystop, scale)
예제 #7
0
 def test_03_createBeforeAfterImages(self):
     imgs = uut.loadImagesRGB(CAMERA_CAL)
     for i,img in enumerate(imgs):
         uut.saveBeforeAfterImages(img, "before", img, "after", TEST_OUT_DIR+"/before_after_"+str(i)+".png")
예제 #8
0
 def test_02_loadAndSave(self):
     imgs = uut.loadImagesRGB(CAMERA_CAL)
     for i,img in enumerate(imgs):
         print("2" + str(img.shape))
         uut.saveImage(img, TEST_OUT_DIR+"/out"+str(i)+".png")
예제 #9
0
 def test_01_load(self):
     imgs = uut.loadImagesRGB(CAMERA_CAL)
     self.assertEqual(20,len(imgs))
     for img in imgs:
         print("1" + str(img.shape))