diff --git a/cpa/classifier.py b/cpa/classifier.py index 34ba448f..11040172 100644 --- a/cpa/classifier.py +++ b/cpa/classifier.py @@ -1671,12 +1671,12 @@ def ClassifyImage(self, imKey): for className, obKeys in classHits.items(): training_keys = [key for key in obKeys if key in training_obKeys] if training_keys: - trainingCoords['training ' + className] = db.GetObjectsCoords(training_keys)[0:2] + trainingCoords['training ' + className] = db.GetObjectsCoords(training_keys) else: trainingCoords['training ' + className] = [] object_keys = [key for key in obKeys if key not in training_obKeys] if object_keys: - classCoords[className] = db.GetObjectsCoords(object_keys)[0:2] + classCoords[className] = db.GetObjectsCoords(object_keys) else: classCoords[className] = [] classCoords.update(trainingCoords) diff --git a/cpa/dbconnect.py b/cpa/dbconnect.py index bf0bdca2..77cf0e35 100755 --- a/cpa/dbconnect.py +++ b/cpa/dbconnect.py @@ -707,20 +707,10 @@ def GetObjectCoords(self, obKey, none_ok=False, silent=False): return res[0] def GetObjectsCoords(self, obKeys, none_ok=False, silent=False): - '''Returns the specified objects' x, y, (and sometimes) z coordinates in an image. - ''' - if p.process_3D: - res = self.execute('SELECT %s, %s, %s, %s, %s FROM %s WHERE %s'%( - p.image_id, p.object_id, p.cell_x_loc, p.cell_y_loc, p.cell_z_loc, p.object_table, - GetWhereClauseForObjects(obKeys)), silent=silent) - reslist = [list(coord) for coord in res] #tuples are immutable so first make tuple of tuples a list of lists - reslist[0][2]=round(reslist[0][2]) #round to get z slice - restup = [tuple(coord) for coord in reslist] #then convert back to list of tuples - res = tuple(restup) #convert to tuple of tuples - else: - res = self.execute('SELECT %s, %s, %s, %s FROM %s WHERE %s'%( - p.image_id, p.object_id, p.cell_x_loc, p.cell_y_loc, p.object_table, - GetWhereClauseForObjects(obKeys)), silent=silent) + # Returns the specified objects' x and y coordinates in an image. + res = self.execute('SELECT %s, %s, %s, %s FROM %s WHERE %s'%( + p.image_id, p.object_id, p.cell_x_loc, p.cell_y_loc, p.object_table, + GetWhereClauseForObjects(obKeys)), silent=silent) if len(res) == 0 or res[0][0] is None or res[0][1] is None: message = ('Failed to load coordinates for object key %s. This may ' 'indicate a problem with your per-object table.\n'