args = vars(ap.parse_args()) db = {} for line in csv.reader(open(args["db"])): db[line[0]] = line[1:] useSIFT = args["sift"] > 0 useHamming = args["sift"] == 0 ratio = 0.7 minMatches = 15 if useSIFT: minMatches = 50 descriptor = DinoDescriptor(useSIFT = useSIFT) dinoMatcher = DinoMatcher(descriptor, glob.glob(args["samples"] + "/*.png"), ratio = ratio, minMatches = minMatches, useHamming = useHamming) dinoResultsHandler = DinoResultsHandler(db) # capture from web cam cap = cv2.VideoCapture(0) while True: ret, queryImage = cap.read() if ret == True: queryImage = utils2.resize(queryImage, width = 1000) # Segment the pink area out segImage = ColorSegmenter.getMagentaBlob(queryImage) # Describe the query image (queryKps, queryDescs, queryKpdRaw) = descriptor.describeQuery(segImage) # It is really important to handle the camera idling time. if len(queryKps) == 0:
if useSIFT: minMatches = 50 inputImage=cv2.imread(args["query"]) # cv2.imshow('Raw', inputImage) # cv2.waitKey(0) segmenter = DinoSegmenter2() segImage = segmenter.segmentImage(inputImage) # cv2.imshow('Segmented', segImage) # cv2.waitKey(0) descriptor = DinoDescriptor(useSIFT = useSIFT) dinoMatcher = DinoMatcher(descriptor, glob.glob(args["samples"] + "/*.png"), ratio = ratio, minMatches = minMatches, useHamming = useHamming) # queryImage = cv2.imread(args["query"]) # capture from webcam # cap = cv2.VideoCapture(0) # while(True): # ret, queryImage = cap.read() # gray = cv2.cvtColor(queryImage, cv2.COLOR_BGR2GRAY) (queryKps, queryDescs) = descriptor.describe(segImage) # To show the key points KpImage = cv2.drawKeypoints(segImage, descriptor.kpsRaw, None) cv2.imshow("Query KP Image", KpImage) cv2.waitKey(0)