'''Define a function to compute color histogram features ''' def color_hist( self,img,plot_info = False): # Return the feature vector return features # Use cv2.resize().ravel() to create the feature vectorįeatures = cv2. cell_per_block = cell_per_block # cell_per_block=2 def bin_spatial( self,img): pix_per_cell = pix_per_cell # pix_per_cell=8 self. spatial_size =spatial_size # spatial_size=(32, 32) self. hist_bins_range = hist_bins_range # hist_bins_range = (0, 256) self. hist_bins = hist_bins # hist_bins=32 self. # Return the list of bounding boxes return bbox_listĭef _init_( self,hist_bins,hist_bins_range,spatial_size,\ If method in :īottom_right = (top_left w, top_left h)ībox_list. Min_val, max_val, min_loc, max_loc = cv2. # Use cv2.minMaxLoc() to extract the location of the best match # Use cv2.matchTemplate() to search the image # Iterate through template list for temp in template_list: # Define matching method # Other options include: cv2.TM_CCORR_NORMED', 'cv2.TM_CCOEFF', 'cv2.TM_CCORR', # 'cv2.TM_SQDIFF', 'cv2.TM_SQDIFF_NORMED' # Define an empty list to take bbox coords # Define a function to search for template matches # and return a list of bounding boxes def find_matches(img, template_list): # Return the image copy with boxes drawn return imcopy rectangle(imcopy, bbox, bbox, color, thick) # Draw a rectangle given bbox coordinatesĬv2. # Iterate through the bounding boxes for bbox in bboxes: # Here is your draw_boxes function from the previous exercise def draw_boxes(img, bboxes, color =( 0, 0, 255), thick = 6):
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |