def data_noshift(mission, img_path, json_path, lamda_shift,lamda_scale,min_scale,max_scale): json_file = open(json_path) str = json_file.read() data = json.loads(str,encoding="GB2312") x_value_curr = [data[u'plate_0'][u'PosPt0X'],data[u'plate_0'][u'PosPt1X'],data[u'plate_0'][u'PosPt2X'],data[u'plate_0'][u'PosPt3X']] y_value_curr = [data[u'plate_0'][u'PosPt0Y'],data[u'plate_0'][u'PosPt1Y'],data[u'plate_0'][u'PosPt2Y'],data[u'plate_0'][u'PosPt3Y']] x1 = (min(x_value_curr))/10#x bottom left y1 = (min(y_value_curr))/10#y bottom left x2 = (max(x_value_curr))/10#x top right y2 = (max(y_value_curr))/10#y top right print num_img, ' bbox:',x1,y1,x2,y2 bbox = BoundingBox(x1,y1,x2,y2) image = cv2.imread(img_path) bbox_curr_gt = bbox rand_search_region, rand_search_location , edge_spacing_x, edge_spacing_y = cropPadImage(bbox_curr_gt, image) bbox_gt_recentered = BoundingBox(0, 0, 0, 0) bbox_gt_recentered = bbox_curr_gt.recenter(rand_search_location, edge_spacing_x, edge_spacing_y, bbox_gt_recentered) bbox_gt_recentered.scale(rand_search_region) bbox_gt_scaled = bbox_gt_recentered bbox_curr_y = [bbox_gt_scaled.x1, bbox_gt_scaled.y1, bbox_gt_scaled.x2, bbox_gt_scaled.y2] cv2.imwrite('/home/huaxin/data_3T/license_dataset/license_track/Dataset_0/' + mission + '/image_unprocess_'+format(num_img, '05d')+'.jpg', rand_search_region) # train_y_bbox_curr.append(bbox_curr_y) return bbox_curr_y
image_index = num_img img_path = train_x_path_curr[image_index] image = cv2.imread(img_path) # if num_img == 0: # cv2.imshow("first", image) # cv2.waitKey(0) bbox = train_y_bbox_curr[num_img] bbox_curr_gt = bbox bbox_curr_shift = BoundingBox(0, 0, 0, 0) bbox_curr_shift = bbox_curr_gt.shift(image, lamda_scale, lamda_shift, min_scale, max_scale, True, bbox_curr_shift) rand_search_region, rand_search_location, edge_spacing_x, edge_spacing_y = cropPadImage( bbox_curr_shift, image) rand_search_x = preprocess(rand_search_region) bbox_estimate = sess.run(logits, feed_dict={ x_cur: [rand_search_x], y: [[1, 1, 1, 1]], keep_prob: 1 }) bbox_estimate = BoundingBox(bbox_estimate[0, 0], bbox_estimate[0, 1], bbox_estimate[0, 2], bbox_estimate[0, 3]) # Inplace correction of bounding box print 'height', rand_search_region.shape[
# Capture frame-by-frame frame = cam.get_image() frame_numpy = pygame.surfarray.array3d(frame) frame_numpy = np.fliplr(frame_numpy) frame_numpy_90 = np.rot90(frame_numpy, 1) b, g, r = cv2.split(frame_numpy_90) # get b, g, r frame_input = cv2.merge([r, g, b]) # switch it to r, g, b image_curr_input = frame_input # cur_search_region, search_location, edge_spacing_x, edge_spacing_y = cropPadImage(bbox_curr_prior_tight, image_curr_input) bbox_curr_gt = bbox_curr_prior_tight # bbox_curr_shift = BoundingBox(0, 0, 0, 0) # bbox_curr_shift = bbox_curr_gt.shift(image_curr_input, lamda_scale, lamda_shift, min_scale, max_scale, True, bbox_curr_shift) cur_search_region, search_location, edge_spacing_x, edge_spacing_y = cropPadImage( bbox_curr_gt, image_curr_input) curr_search_x = preprocess(cur_search_region) bbox_estimate = sess.run(logits, feed_dict={ x_cur: [curr_search_x], y: [[1, 1, 1, 1]], keep_prob: 1 }) bbox_estimate = BoundingBox(bbox_estimate[0, 0], bbox_estimate[0, 1], bbox_estimate[0, 2], bbox_estimate[0, 3]) # Inplace correction of bounding box print 'height', cur_search_region.shape[ 0], 'width', cur_search_region.shape[1]