def create_features(self): print('CREATING FEATURES') for im in self.im_list: print(os.path.basename(im)) img = cv2.imread(im, 0) #queryimage # left image img, scale = imsz.imRescaleMaxDim(img, self.image_max_dim, boUpscale=False, interpolation=1) kp, des = self.detector.detectAndCompute(img, None) #des=des.astype('float32') self.feats[im] = (kp, des) return
jpg_list = imsz.imagelist_in_depth(im_dir, level=1) i1 = 1 im_file1 = jpg_list[i1] i2 = 2 im_file2 = jpg_list[i2] #im_file1=r'd:\\DATA\\MAV1\\Images\\Selection_20190124_120409_2800_3400\\roi_0_2882.jpg' #im_file2=r'd:\\DATA\\MAV1\\Images\\Selection_20190124_120409_2800_3400\\roi_1_2882.jpg' img1 = cv2.imread(im_file1, 0) #queryimage # left image img2 = cv2.imread(im_file2, 0) #trainimage # right image ## img1, scale = imsz.imRescaleMaxDim(img1, max_dim, boUpscale=False, interpolation=1) img2, scale = imsz.imRescaleMaxDim(img2, max_dim, boUpscale=False, interpolation=1) ## SIFT # sift = cv2.xfeatures2d.SIFT_create(800) detector, matcher = hc.init_feature(det_type, n_feature_point=1000) kp1, des1 = detector.detectAndCompute(img1, None) kp2, des2 = detector.detectAndCompute(img2, None) # draw rich keypoints
################# base_dir = r'd:\DATA\EON_LOCAL\SESSIONS\20200218_092900' #run_id='20180907_103336_sel1' run_id = '20200218_092854964_Agent4_Master' ext = '.jpg' image_max_dim = 1014 im_dir = os.path.join(base_dir, run_id) jpg_list = imsz.imagelist_in_depth(im_dir, level=1) frame_id = 0 wait_time = 100 while True: frame = cv2.imread(jpg_list[frame_id], 0) #queryimage # left image frame, scale = imsz.imRescaleMaxDim(frame, image_max_dim, boUpscale=False, interpolation=1) (H, W) = frame.shape[:2] frame_id += 1 if frame_id > len(jpg_list): break # check to see if we are currently tracking an object if initBB is not None: # grab the new bounding box coordinates of the object (success, box) = tracker.update(frame) # check to see if the tracking was a success if success: (x, y, w, h) = [int(v) for v in box] cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)
refPt_transformed = [] cropping = False i1=0 i2=3 im1=jpg_list[i1] im2=jpg_list[i2] M=hcobj.Ms[im1,im2] img1 = cv2.imread(im1,0) #queryimage # left image img2 = cv2.imread(im2,0) #queryimage # left image image_max_dim=hcobj.image_max_dim img1, scale = imRescaleMaxDim(img1, image_max_dim, boUpscale = False, interpolation = 1) img2, scale = imRescaleMaxDim(img2, image_max_dim, boUpscale = False, interpolation = 1) image_width=img1.shape[1] #img2 = cv2.warpPerspective(img1, M, (img2.shape[1],img2.shape[0])) M[0][2]*=scale M[1][2]*=scale M[2][0]*=scale M[2][1]*=scale def click_and_crop(event, x, y, flags, param): # grab references to the global variables global refPt, refPt_transformed, cropping, M, image_width