python - Finding same /similar matching co-ordinate region in a list of co-ordinates -
i have list of co-ordinates :
co_list : [[408, 760, 239, 696], [574, 759, 405, 695], [574, 759, 405, 695], [575, 759, 406, 695], [575, 760, 406, 696], [1766, 707, 1597, 643]]
i need find if more 1 co-ordinates points similar /same(exact match) region : i.e in case co-ordinates @ position 1,2,3,4 points same co-ordinate.
so far have done finding exact same co-ordinates. below logic:
from collections import counter def most_common(lst): lst = list(lst) return max(set(lst), key=lst.count) cordinate_list= [[408, 760, 239, 696], [574, 759, 405, 695], [574, 759, 405, 695], [575, 759, 406, 695], [575, 760, 406, 696], [1766, 707, 1597, 643]] common_list, appearances = counter([tuple(x) x in cordinate_list]).most_common(1)[0] # note 1 if appearances > 3: print("image match found @ co-ordinate : {0} ".format(common_list)) # ([397, 994, 135, 941], 4) elif appearances==3: print "possible match @ co-ordinate {0}".format(common_list) else: print('no list appears more 3 times!')
this works, when input has same co-ordinates more once , need work if there error of +-5 in co-ordinates .
any or suggestion appreciated
Comments
Post a Comment