Created
January 26, 2012 17:10
-
-
Save kscottz/1683840 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #cluster overlapping template matches | |
| finalfs = FeatureSet() | |
| finalfs.append(fs[0]) | |
| for f in fs: | |
| match = False | |
| for f2 in finalfs: | |
| if( f2.overlaps(f) ): #if they overlap | |
| f2.consume(f) #merge them | |
| match = True | |
| break | |
| if( not match ): | |
| finalfs.append(f) | |
| for f in finalfs: #rescale the resulting clusters to fit the template size | |
| f.rescale(template_image.width,template_image.height) | |
| fs = finalfs | |
| # spread = 0.2*clusters # search +/- 20% of guess | |
| # bestk = 0 | |
| # best = 0 | |
| # bestc = [] | |
| # for k in range(clusters-spread,clusters+spread): | |
| # result = scv.kmeans(fs.coordinates(),k) #do the kmeans and maximize the fit | |
| # if( result[1] > best ): | |
| # best = result[1] | |
| # bestk = k | |
| # bestc = result[0] | |
| # print bestk | |
| # [bestc,derp] = scv.kmeans2(fs.coordinates(),bestk,iter=100,minit='points') | |
| # fs = FeatureSet() | |
| # for centroid in bestc: | |
| # fs.append(TemplateMatch(self,template_image.getBitmap(), centroid, 1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment