Only get segments of minimum area

This commit is contained in:
Ruben van de Ven 2020-12-22 14:31:20 +01:00
parent cc505355b3
commit 6dad7eca48
3 changed files with 15 additions and 6 deletions

View File

@ -311,12 +311,12 @@ class COCOStorage:
annotation_id = None
return self.getRandomAnnotation(annotation_id=annotation_id, withZerkine=withZerkine)
def getRandomAnnotation(self, annotation_id=None, category_id=None, withZerkine=False) -> Annotation:
def getRandomAnnotation(self, annotation_id=None, category_id=None, withZerkine=False, min_area=None) -> Annotation:
result = self.getRandomAnnotations(
annotation_id, category_id, withZerkine, limit=1)
annotation_id, category_id, withZerkine, min_area=min_area, limit=1)
return result[0] if len(result) else None
def getRandomAnnotations(self, annotation_id=None, category_id=None, withZerkine=False, limit=None):
def getRandomAnnotations(self, annotation_id=None, category_id=None, withZerkine=False, min_area=None, limit=None):
cur = self.con.cursor()
where = ""
params = []
@ -332,6 +332,12 @@ class COCOStorage:
if withZerkine:
where += " AND zerkine_moment IS NOT NULL"
if min_area:
where += " AND area > ?"
params.append(min_area)
print(where)
sqlLimit = ""
if limit:
sqlLimit = f"LIMIT {int(limit)}"

View File

@ -40,13 +40,16 @@ class AnnotationHandler(tornado.web.RequestHandler):
normalise = self.get_argument('normalise', False)
normalise = int(normalise) if normalise is not False else False
min_area = self.get_argument('min_area', None)
min_area = int(min_area) if min_area is not None else None
# category_id = None if not category_id else int(category_id)
logger.debug(
f'Get annotation id: {annotation_id}, category: {category_id}, normalised: {normalise}')
f'Get annotation id: {annotation_id}, category: {category_id}, normalised: {normalise}, min_area: {min_area}')
annotation = self.storage.getRandomAnnotation(
annotation_id=annotation_id, category_id=category_id)
annotation_id=annotation_id, category_id=category_id, min_area=min_area)
if normalise:
return annotation.getNormalised(normalise, normalise)
return annotation

View File

@ -26,7 +26,7 @@ export class Game {
}
loadAnnotation() {
let json_request = new Request('/annotation.json');
let json_request = new Request('/annotation.json?min_area=500');
fetch(json_request).then(function (response) {
return response.json();