changeset 1032:d0e339359d8a

work in progress
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Tue, 19 Jun 2018 17:07:50 -0400
parents 045cb04ad7b8
children 8ffb3ae9f3d2
files scripts/learn-motion-patterns.py
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/learn-motion-patterns.py	Tue Jun 19 17:07:35 2018 -0400
+++ b/scripts/learn-motion-patterns.py	Tue Jun 19 17:07:50 2018 -0400
@@ -75,11 +75,12 @@
 # the next line can be called again without reinitializing similarities
 if args.learn:
     prototypeIndices = ml.prototypeCluster(trajectories, similarities, args.minSimilarity, similarityFunc, args.optimizeCentroid, args.randomInitialization, initialPrototypeIndices)
-# assignment is done if explicitly passed as argument or if working on the same database (starting prototypes from scratch and assigning them)
 else:
     prototypeIndices = initialPrototypeIndices
 
 if args.assign:
+    if not args.learn and args.minClusterSize >= 1:
+        print('Warning: you did not learn the prototypes and you are using minimum cluster size of {}, which may lead to removing prototypes and assigning them to others'.format(args.minClusterSize))
     prototypeIndices, labels = ml.assignToPrototypeClusters(trajectories, prototypeIndices, similarities, args.minSimilarity, similarityFunc, args.minClusterSize)
     clusterSizes = ml.computeClusterSizes(labels, prototypeIndices, -1)
     print(clusterSizes)
@@ -89,10 +90,11 @@
     for i in prototypeIndices:
         if args.assign:
             nMatchings = clusterSizes[i]-1
-        else:
-            nMatchings = 0
+        #else:
+        #    nMatchings = 0
         if i<len(initialPrototypes):
-            initialPrototypes[i].nMatchings += nMatchings
+            if args.assign:
+                initialPrototypes[i].nMatchings += nMatchings
             prototypes.append(initialPrototypes[i])
         else:
             prototypes.append(moving.Prototype(args.databaseFilename, objects[i-len(initialPrototypes)].getNum(), trajectoryType, nMatchings))