def test_hotspot(self): # Read in a pickle file with bboxes saved # Each item in the "all_bboxes" list will contain a # list of boxes for one of the images shown above box_list = pickle.load(open("bbox_pickle.p", "rb")) # Read in image similar to one shown above image = mpimg.imread(IMG_FILE) image_with_boxes = draw_boxes(image, box_list) heat = np.zeros_like(image[:, :, 0]).astype(np.float) # Add heat to each box in box list heat = uut.add_heat(heat, box_list) # Apply threshold to help remove false positives heat = uut.apply_threshold(heat, 1) # Visualize the heatmap when displaying heatmap = np.clip(heat, 0, 255) # Find final boxes from heatmap using label function labels = label(heatmap) draw_img = uut.draw_labeled_bboxes(np.copy(image), labels) final_image = image_util.arrangeImages( [image, image_with_boxes, heatmap, draw_img], ["Original", "Boxes that detected car", "Heatmap", "labeld boxes"], 2) image_util.saveImage(final_image, TEST_OUT_DIR + "/hotspot.jpg")
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")
def draw_sliding_windows(self, filename, img, y_start, y_stop, scale): xy_window = (int(64*scale),int(64*scale)) boxes = slide_window(img, y_start_stop=[y_start, y_stop], xy_window=xy_window, xy_overlap=(0.75, 0.75)) img = draw_boxes(img,boxes) img = cv2.rectangle(img,(0,y_start),(xy_window[0],y_start+xy_window[1]), (255,0,0), 6) print (len(boxes)) print (img.shape) image_util.saveImage(img, filename)
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 test_02_example_labeled_data(self): vehicle_img = image_util.loadImageRGB(self.vehicles[0]) non_vehicle_img = image_util.loadImageRGB(self.non_vehicles[0]) img = image_util.arrangeImages([vehicle_img, non_vehicle_img], ["vehicle","non vehicle"]) image_util.saveImage(img, TEST_OUT_DIR + "/vehicle_non_vehicle.png")
def visualize_hog(self, img, prefix, orientations, pix_per_cell, cell_per_block, color ): ch1, ch2, ch3, hog_image_c1, hog_image_c2, hog_image_c3 = self.hogChannels(img, orientations=orientations, pix_per_cell=pix_per_cell, cell_per_block=cell_per_block, color=color ) img = image_util.arrangeImages([img, ch1, ch2, ch3, hog_image_c1, hog_image_c2, hog_image_c3], ["original", "c1", "c2", "c3", "hog c1","hog c2","hog c3"], figsize=(7,1)) image_util.saveImage(img, TEST_OUT_DIR + "/"+ prefix +"_orient"+str(orientations)+"_pix_per_cell"+str(pix_per_cell)+"_cell_per_block"+str(cell_per_block)+"_"+str(color)+".png")
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")