コード例 #1
0
ファイル: store.py プロジェクト: feilkontroll/objektivaudio1
ap = argparse.ArgumentParser()
args = vars(ap.parse_args())

useSIFT = False
useHamming = True

# initialize the cover descriptor and cover matcher
cd = CoverDescriptor(useSIFT=useSIFT)
conn = sqlite3.connect('db', detect_types=sqlite3.PARSE_DECLTYPES)
cur = conn.cursor()

c = conn.cursor()

for imgPath in glob.glob("newimages/*.png"):

    # load the query image, convert it to grayscale, and
    # extract keypoints and descriptors
    cover = cv2.imread(imgPath)
    gray = cv2.cvtColor(cover, cv2.COLOR_BGR2GRAY)
    (kps, descs) = CoverDescriptor.describe(cd, gray)

    c.execute(
        'INSERT INTO images(filename,keypoints,descriptors) VALUES(?,?,?)',
        (imgPath, kps, descs))

#    print(kps)
#    print(descs)
conn.commit()
conn.close()
コード例 #2
0
ファイル: search.py プロジェクト: 16rl/image-search
db = {}

# loop over the database
for l in csv.reader(open(args["db"])):
	# update the database using the image ID as the key
	db[l[0]] = l[1:]

# initialize the cover descriptor and cover matcher
cd = CoverDescriptor()
cv = CoverMatcher(cd, glob.glob(args["covers"] + "/*.png"))

# load the query image, convert it to grayscale, and extract
# keypoints and descriptors
queryImage = cv2.imread(args["query"])
gray = cv2.cvtColor(queryImage, cv2.COLOR_BGR2GRAY)
(queryKps, queryDescs) = cd.describe(gray)

# try to match the book cover to a known database of images
results = cv.search(queryKps, queryDescs)

# show the query cover
cv2.imshow("Query", queryImage)

# check to see if no results were found
if len(results) == 0:
	print "I could not find a match for that cover!"
	cv2.waitKey(0)

# otherwise, matches were found
else:
	# loop over the results
コード例 #3
0
ファイル: search.py プロジェクト: jasper-cell/OpenCV
if useSIFT:
    minMatches = 50

# initialize the cover descriptor and cover matcher
cd = CoverDescriptor(useSIFT=useSIFT)
cv = CoverMatcher(cd,
                  glob.glob(args["covers"] + "/*.png"),
                  ratio=ratio,
                  minMatches=minMatches,
                  useHamming=useHamming)

# load the query image, convert it to grayscale, and extract
# keypoints and descriptors
queryImage = cv2.imread(args["query"])
gray = cv2.cvtColor(queryImage, cv2.COLOR_BGR2GRAY)
(queryKps, queryDescs) = cd.describe(gray)

# try to match the book cover to a known database of images
results = cv.search(queryKps, queryDescs)

# show the query cover
cv2.imshow("Query", queryImage)

# check to see if no results were found
if len(results) == 0:
    print("I could not find a match for that cover!")
    cv2.waitKey(0)

# otherwise, matches were found
else:
    # loop over the results
コード例 #4
0
ファイル: store.py プロジェクト: feilkontroll/objektivaudio1
# initialize the cover descriptor and cover matcher
cd = CoverDescriptor(useSIFT = useSIFT)
conn = sqlite3.connect('db', detect_types=sqlite3.PARSE_DECLTYPES)
cur = conn.cursor()

c = conn.cursor()


for imgPath in glob.glob("newimages/*.png"):

    # load the query image, convert it to grayscale, and
    # extract keypoints and descriptors
    cover = cv2.imread(imgPath)
    gray = cv2.cvtColor(cover, cv2.COLOR_BGR2GRAY)
    (kps, descs) = CoverDescriptor.describe(cd, gray)

    c.execute('INSERT INTO images(filename,keypoints,descriptors) VALUES(?,?,?)',
             (imgPath, kps, descs))

#    print(kps)
#    print(descs)
conn.commit()
conn.close()