improved similarity search

This commit is contained in:
ville rantanen
2014-05-22 10:30:40 +03:00
parent 8458aaed2c
commit c9bfa7b9e2
2 changed files with 16 additions and 9 deletions

View File

@@ -345,19 +345,20 @@ def find_fingerprint_nearest(sqlfile,cmp):
conn.text_factory=str
db1=conn.cursor()
if is_listed(db1, cmp):
db1.execute("SELECT file,fingerprint,sharpness,width,height FROM list WHERE file=?",(cmp,))
db1.execute("SELECT file,fingerprint,sharpness,width,height,R,G,B FROM list WHERE file=?",(cmp,))
for hit1 in db1:
fp=int(hit1[1])
sp=hit1[2]
dims=hit1[3,4]
dims=hit1[3:5]
colors=hit1[5:8]
else:
fp=int(get_fingerprint(cmp))
sp=get_sharpness(cmp)
dims=get_dims(cmp)
print('"File":"Similarity":"Sharpness":"Width":"Height"')
print('"%s":0:%f:%d:%d' % (cmp, sp,int(dims[0]),int(dims[1])))
db1.execute("SELECT file,fingerprint,sharpness,width,height FROM list ORDER BY file")
this=['',sys.maxint,0,0,0]
colors=get_colors(cmp)[0]
db1.execute("SELECT file,fingerprint,sharpness,width,height,R,G,B FROM list WHERE sharpness > 0 ORDER BY file")
this=['',sys.maxint,0,0,0,0]
for i,hit1 in enumerate(db1):
if hit1[0] == cmp:
continue
@@ -368,8 +369,14 @@ def find_fingerprint_nearest(sqlfile,cmp):
this[2]=hit1[2]
this[3]=int(hit1[3])
this[4]=int(hit1[4])
print('"%s":%i:%f:%d:%d' % (this[0], this[1], this[2],this[3], this[4]))
this[5]=abs( hit1[5] - colors[0] )+abs( hit1[6] - colors[1] )+abs( hit1[7] - colors[2] )
if this[0]=='':
print("No measurements found")
sys.exit(1)
file_len=str(max(len(cmp), len(this[0])))
print( ('{: <'+file_len+'} {: >4} {: >4} {: >4} {: ^5}x{: ^5}').format("File","Diff","CDel","Shrp","Wth","Hgt"))
print( ('{: <'+file_len+'} {: >4} {: >4} {: >4} {: >5}x{: >5}').format(cmp,"","","%.1f" % sp,dims[0],dims[1]))
print( ('{: <'+file_len+'} {: >4} {: >4} {: >4} {: >5}x{: >5}').format(this[0], this[1],"%.2f"%this[5], "%.1f" % this[2],this[3], this[4]))
def append_sharpness(sqlfile):
conn=sqlite3.connect(sqlfile)

View File

@@ -213,7 +213,7 @@ Object Area Perimeter
|+ * + * *** + *** ** * +|
-15 ++----*--+--*----+-**-----+-----**+------*+----*--++
-30 -20 -10 0 10 20 30
$( gnuplot -d -e "set term dumb 60 15 enhanced; set parametric; set trange [0:10*pi]; set yrange[-2*pi:2*pi]; set xrange[-4*pi:4*pi]; plot t*cos(t), t*sin(t);" )
$( gnuplot -e "set term dumb 60 15 enhanced; set parametric; set trange [0:10*pi]; set yrange[-2*pi:2*pi]; set xrange[-4*pi:4*pi]; plot t*cos(t), t*sin(-t);" )
# Hints: ${R}Co${Y}lo${G}rs