Only get segments of minimum area
This commit is contained in:
parent
cc505355b3
commit
6dad7eca48
3 changed files with 15 additions and 6 deletions
|
@ -311,12 +311,12 @@ class COCOStorage:
|
||||||
annotation_id = None
|
annotation_id = None
|
||||||
return self.getRandomAnnotation(annotation_id=annotation_id, withZerkine=withZerkine)
|
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(
|
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
|
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()
|
cur = self.con.cursor()
|
||||||
where = ""
|
where = ""
|
||||||
params = []
|
params = []
|
||||||
|
@ -332,6 +332,12 @@ class COCOStorage:
|
||||||
if withZerkine:
|
if withZerkine:
|
||||||
where += " AND zerkine_moment IS NOT NULL"
|
where += " AND zerkine_moment IS NOT NULL"
|
||||||
|
|
||||||
|
if min_area:
|
||||||
|
where += " AND area > ?"
|
||||||
|
params.append(min_area)
|
||||||
|
print(where)
|
||||||
|
|
||||||
|
|
||||||
sqlLimit = ""
|
sqlLimit = ""
|
||||||
if limit:
|
if limit:
|
||||||
sqlLimit = f"LIMIT {int(limit)}"
|
sqlLimit = f"LIMIT {int(limit)}"
|
||||||
|
|
|
@ -40,13 +40,16 @@ class AnnotationHandler(tornado.web.RequestHandler):
|
||||||
normalise = self.get_argument('normalise', False)
|
normalise = self.get_argument('normalise', False)
|
||||||
normalise = int(normalise) if normalise is not False else 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)
|
# category_id = None if not category_id else int(category_id)
|
||||||
|
|
||||||
logger.debug(
|
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 = 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:
|
if normalise:
|
||||||
return annotation.getNormalised(normalise, normalise)
|
return annotation.getNormalised(normalise, normalise)
|
||||||
return annotation
|
return annotation
|
||||||
|
|
|
@ -26,7 +26,7 @@ export class Game {
|
||||||
}
|
}
|
||||||
|
|
||||||
loadAnnotation() {
|
loadAnnotation() {
|
||||||
let json_request = new Request('/annotation.json');
|
let json_request = new Request('/annotation.json?min_area=500');
|
||||||
|
|
||||||
fetch(json_request).then(function (response) {
|
fetch(json_request).then(function (response) {
|
||||||
return response.json();
|
return response.json();
|
||||||
|
|
Loading…
Reference in a new issue