code: def objectConfusion(self):
      
      objects = self.getObjects()
  
      if len(objects) == 0:
        return 0.0, 0.0, 0.0
  
      sumCommonLocations = 0
      sumCommonFeatures = 0
      sumCommonPairs = 0
      numObjects = 0
      commonPairHistogram = numpy.zeros(len(objects[0]), dtype=numpy.int32)
      for o1, s1 in objects.iteritems():
        for o2, s2 in objects.iteritems():
          if o1 != o2:
            # Count number of common locations id's and common feature id's
            commonLocations = 0
            commonFeatures = 0
            for pair1 in s1:
              for pair2 in s2:
                if pair1[0] == pair2[0]: commonLocations += 1
                if pair1[1] == pair2[1]: commonFeatures += 1
  
            # print "Confusion",o1,o2,", common pairs=",len(set(s1)&set(s2)),
            # print ", common locations=",commonLocations,"common features=",commonFeatures
  
            if len(set(s1) & set(s2)) == len(s1):
              raise RuntimeError("Two objects are identical!")
  
            sumCommonPairs += len(set(s1) & set(s2))
            sumCommonLocations += commonLocations
            sumCommonFeatures += commonFeatures
            commonPairHistogram[len(set(s1) & set(s2))] += 1
            numObjects += 1
  
      # print "Common pair histogram=", commonPairHistogram
  
      return (sumCommonPairs / float(numObjects),
              sumCommonLocations / float(numObjects),
              sumCommonFeatures / float(numObjects)
              )
docs: Compute overlap between each pair of objects.  Computes the average number
      of feature/location pairs that are identical, as well as the average number
      of shared locations and features.
  
      This function will raise an exception if two objects are identical.
  
      Returns the tuple:
        (avg common pairs, avg common locations, avg common features)