Skip to content

Commit

Permalink
Cleaned up code in js file
Browse files Browse the repository at this point in the history
  • Loading branch information
baljit92 committed Jun 30, 2017
1 parent 7a993c8 commit ece65a4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 29 deletions.
Binary file added results/misc/webapp_shot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 4 additions & 19 deletions src/webapp/TrainImage_Annotate/Annotate/static/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function nextBtnInit()
$("#next").click(function()
{
currentImageIndex = parseInt($('#image_index').val())

clearCanvas()
nextImage = (currentImageIndex + 1) % images.length;
currentImageIndex = nextImage;

Expand Down Expand Up @@ -66,8 +66,6 @@ function nextBtnInit()
{
window.location.href = "/draw/download";
});



}

Expand Down Expand Up @@ -197,14 +195,6 @@ function mouseUp(e)
rect.endingX = e.pageX - (this.offsetLeft+offsetLeftAdd);
rect.endingY = e.pageY - (this.offsetTop+offsetTopAdd);


console.log("Being");
console.log("Starting X:", rect.startX);
console.log("Starting Y:", rect.startY);
console.log("Ending X:", rect.endingX);
console.log("Ending X:", rect.endingY);
console.log("Height:", rect.h);

if((rect.startX > rect.endingX) && (rect.startY > rect.endingY))
{
rect.startX = rect.endingX;
Expand All @@ -223,12 +213,7 @@ function mouseUp(e)
{
rect.startX = rect.startX + rect.w;
}
// console.log("After everything");
// console.log("Starting X:", rect.startX);
// console.log("Starting Y:", rect.startY);
// console.log("Ending X:", rect.endingX);
// console.log("Ending X:", rect.endingY);
// console.log("Height:", rect.h);

var tempRectTuple = []
// top-left
tempRectTuple.push(rect.startX);
Expand All @@ -240,8 +225,8 @@ function mouseUp(e)
tempRectTuple.push(Math.abs(rect.w));
//height
tempRectTuple.push(Math.abs(rect.h));
console.log("temprect:", tempRectTuple);
//console.log(sdfs)


var tempStr = "["+tempRectTuple+"]";
rect_tuple.push(tempRectTuple)

Expand Down
30 changes: 20 additions & 10 deletions src/webapp/TrainImage_Annotate/Annotate/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,27 @@ def prepareArrayNMS(filename):
# preparing tuples
for i in range(0,num_rects):

x0 = math.isnan(float(data['bounding_box'][(6*i)+0]))
y0 = math.isnan(float(data['bounding_box'][(6*i)+1]))
x1 = math.isnan(float(data['bounding_box'][(6*i)+2]))
y1 = math.isnan(float(data['bounding_box'][(6*i)+3]))

if not x0 and not x1 and not y0 and not y1:
temp_tuple = (float(data['bounding_box'][(6*i)+0]), float(data['bounding_box'][(6*i)+1]), float(data['bounding_box'][(6*i)+2]), float(data['bounding_box'][(6*i)+3]))
box_coords.append(temp_tuple)
x0_str = len(data['bounding_box'][(6*i)+0])
y0_str = len(data['bounding_box'][(6*i)+1])
x1_str = len(data['bounding_box'][(6*i)+2])
y1_str = len(data['bounding_box'][(6*i)+0])

area = (float(data['bounding_box'][(6*i)+2]) - float(data['bounding_box'][(6*i)+0])) * (float(data['bounding_box'][(6*i)+3]) - float(data['bounding_box'][(6*i)+1]))
box_area.append(area)
if x0_str > 0 and y0_str > 0 and x1_str > 0 and y1_str > 0:
x0 = math.isnan(float(data['bounding_box'][(6*i)+0]))
y0 = math.isnan(float(data['bounding_box'][(6*i)+1]))
x1 = math.isnan(float(data['bounding_box'][(6*i)+2]))
y1 = math.isnan(float(data['bounding_box'][(6*i)+3]))

if not x0 and not x1 and not y0 and not y1:
temp_tuple = (float(data['bounding_box'][(6*i)+0]), float(data['bounding_box'][(6*i)+1]), float(data['bounding_box'][(6*i)+2]), float(data['bounding_box'][(6*i)+3]))
box_coords.append(temp_tuple)

area = (float(data['bounding_box'][(6*i)+2]) - float(data['bounding_box'][(6*i)+0])) * (float(data['bounding_box'][(6*i)+3]) - float(data['bounding_box'][(6*i)+1]))
box_area.append(area)
else:
box_area = []
box_coords = []
continue
else:
box_area = []
box_coords = []
Expand Down
Binary file modified src/webapp/TrainImage_Annotate/Annotate/views.pyc
Binary file not shown.

0 comments on commit ece65a4

Please sign in to comment.