ratio diff

This commit is contained in:
q
2014-05-23 08:57:22 +03:00
parent 24baa6230a
commit 1ecbc9edba

View File

@@ -402,7 +402,7 @@ def find_fingerprint_nearest(opts):
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=['',thr,0,0,0,0]
this=['',thr,0,0,0,0,0]
hit1=None
for i,hit1 in enumerate(db1):
if hit1[0] == cmp:
@@ -415,6 +415,7 @@ def find_fingerprint_nearest(opts):
this[3]=int(hit1[3])
this[4]=int(hit1[4])
this[5]=abs( hit1[5] - colors[0] )+abs( hit1[6] - colors[1] )+abs( hit1[7] - colors[2] )
this[6]= (this[3]/float(this[4])) / (float(dims[0])/float(dims[1]))
if hit1==None:
print("No measurements found")
sys.exit(1)
@@ -422,9 +423,9 @@ def find_fingerprint_nearest(opts):
print("No similar images for "+cmp+", up to threshold "+str(thr))
return
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("File","Diff","CD","RoR","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]))
print( ('{: <'+file_len+'} {: >4} {: >4} {: >4} {: >4} {: >5}x{: >5}').format(this[0], this[1],"%.2f"%this[5],"%.3f"%this[6], "%.1f" % this[2],this[3], this[4]))
if opts.viewer:
subprocess.call(opts.viewer.replace('%f', " ".join((cmp,this[0]))), stderr=subprocess.STDOUT, shell=True)