Skip to content

Commit

Permalink
Merge pull request #458 from bonn-activity-maps/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
dari1495 authored Apr 20, 2021
2 parents efb7e42 + d246a89 commit 051451d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 18 deletions.
29 changes: 12 additions & 17 deletions src/python/logic/annotationService.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,21 +637,17 @@ def get_sanity_check(self, dataset, scene, user, start_frame, end_frame):
if len(bbox["keypoints"]) > 0:
poly_bbox = ptService.transform_to_poly(bbox["keypoints"])
if video.type == "val":
# --- Every bbox must have a head_bbox inside (or at least half of it, given that head_bbox can be
# outside of the canvas)
# --- Every bbox must have a head_bbox inside within a threshold.
bbox_head = ptService.find(bbox_head_list, "track_id", bbox["track_id"])
poly_bbox_head = ptService.transform_to_poly(bbox_head["keypoints"])
head_inside, prcnt_points_inside = ptService.is_A_in_B(poly_bbox_head, poly_bbox)
# If the bbox_head is not completely inside bbox, check the percentage of points inside
head_inside = ptService.is_bbox_head_in_bbox(bbox_head["keypoints"], bbox["keypoints"])
# If it is considered to be sufficiently out of the bbox, add error
if not head_inside:
# If it's not at least half, it's wrong. Add error
if prcnt_points_inside < 0.5:
errors_detected.append({
"number": bbox["uid"]//100 % 10000,
"track_id": bbox["track_id"],
"type": "bbox_head",
"reason": "bbox_head outside of corresponding bbox."
})
errors_detected.append({
"number": bbox["uid"]//100 % 10000,
"track_id": bbox["track_id"],
"type": "bbox_head",
"reason": "bbox_head outside of corresponding bbox"
})
# If it's an annotable frame, do further checks. These checks are the same in train and val
if annotable_frame:
# --- Every bbox must have a pose inside, unless it is inside an ignore region
Expand All @@ -678,10 +674,9 @@ def get_sanity_check(self, dataset, scene, user, start_frame, end_frame):
# If there is a bbox_head, we must ensure that it is within the bounds of its corresponding bbox
bbox = ptService.find(bbox_list, "track_id", bbox_head["track_id"])
if len(bbox["keypoints"]) > 0:
poly_bbox = ptService.transform_to_poly(bbox["keypoints"])
poly_bbox_head = ptService.transform_to_poly(bbox_head["keypoints"])
bbox_head_inside, prcnt = ptService.is_A_in_B(poly_bbox_head, poly_bbox)
if not bbox_head_inside and prcnt < 0.5:
head_inside = ptService.is_bbox_head_in_bbox(bbox_head["keypoints"], bbox["keypoints"])
# If it is considered to be sufficiently out of the bbox, add error
if not head_inside:
errors_detected.append({
"number": bbox["uid"]//100 % 10000,
"track_id": bbox["track_id"],
Expand Down
23 changes: 23 additions & 0 deletions src/python/logic/ptService.py
Original file line number Diff line number Diff line change
Expand Up @@ -1942,6 +1942,29 @@ def cubify(self, pts):
pt_1, pt_2 = pts
return [pt_1, [pt_1[0], pt_2[1]], pt_2, [pt_2[0], pt_1[1]]]

# Check if bbox_head is sufficiently inside bbox, within a treshhold
def is_bbox_head_in_bbox(self, bbox_head, bbox):
pt1, pt2 = bbox
x1, y1 = pt1
x2, y2 = pt2
# only, if head box is not interpolated
# if bbox_head[0, 0] > -100 and bbox_head[0, 1] > -1:
pt1, pt2 = bbox_head
h_x1, h_y1 = pt1
h_x2, h_y2 = pt2

# we are only interested in the "visible" part of the head box
x_min = max(x1, max(0, h_x1))
y_min = max(y1, max(0, h_y1))

x_max = min(x2, h_x2)
y_max = min(y2, h_y2)

intersection = (x_max - x_min + 1) * (y_max - y_min + 1)
if intersection / ((h_x2 - h_x1 + 1) * (h_y2 - h_y1 + 1)) < 0.8:
return False
return True

# Check if A is in B. If ALL points of A are inside B, return True.
# Otherwise return False and the % of points inside.
# Both inputs must be of type geometry.Polygon
Expand Down
2 changes: 1 addition & 1 deletion src/static/javascript/services/navbarService.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ angular.module('CVGTool')
.factory('navSrvc', ['loginSrvc', '$state', '$rootScope', '$http', '$httpParamSerializer', function(loginSrvc, $state, $rootScope, $http, $httpParamSerializer) {

// Actual version of the tool, THIS IS THE MAIN VARIABLE
var toolVersion = "3.3";
var toolVersion = "3.3.1";

// Function to send message to tell the controller to update
var updateSessionData = function() {
Expand Down

0 comments on commit 051451d

Please sign in to comment.