Skip to content

Commit

Permalink
lots of minor ui changes
Browse files Browse the repository at this point in the history
  • Loading branch information
johndoherty committed May 20, 2015
1 parent 9a21e7f commit c6bda41
Show file tree
Hide file tree
Showing 9 changed files with 225 additions and 35 deletions.
4 changes: 3 additions & 1 deletion cli.py
Expand Up @@ -147,6 +147,7 @@ def setup(self):
parser.add_argument("--blow-radius", default = 3)
parser.add_argument("--run-initial-tracking", action="store_true")
parser.add_argument("--homography")
parser.add_argument("--pointmode", action="store_true", default=False)
return parser

def title(self, args):
Expand Down Expand Up @@ -242,7 +243,8 @@ def __call__(self, args, group):
trainwith = trainer,
isfortraining = args.for_training,
blowradius = args.blow_radius,
homographylocation = homographydir)
homographylocation = homographydir,
pointmode = args.pointmode)

if args.for_training:
video.trainvalidator = qa.tolerable(args.for_training_overlap,
Expand Down
1 change: 1 addition & 0 deletions models.py
Expand Up @@ -36,6 +36,7 @@ class Video(turkic.database.Base):
trainvalidator = Column(PickleType, nullable = True, default = None)
blowradius = Column(Integer, default = 5)
homographylocation = Column(String(250), nullable = True, default = None)
pointmode = Column(Boolean, default = False)

def __getitem__(self, frame):
path = Video.getframepath(frame, self.location)
Expand Down
2 changes: 2 additions & 0 deletions public/job.js
Expand Up @@ -19,6 +19,7 @@ function Job(data)
this.onlinetrackers = [];
this.bidirectionaltrackers = [];
this.multiobjecttrackers = [];
this.pointmode = null;

this.frameurl = function(i)
{
Expand Down Expand Up @@ -51,6 +52,7 @@ function job_import(data)
job.bidirectionaltrackers = data["trackers"]["bidirectional"];
job.multiobjecttrackers = data["trackers"]["multiobject"];
job.nextid = parseInt(data["nextid"]);
job.pointmode = parseInt(data["pointmode"]) ? true : false;

console.log("Job configured!");
console.log(" Slug: " + job.slug);
Expand Down
132 changes: 123 additions & 9 deletions public/objectui.js
Expand Up @@ -27,7 +27,9 @@ function TrackEditor(shortcuts, videoframe)
pos.ybr = y + (0.5 * pos.height);
pos.xtl = x - (0.5 * pos.width);
pos.ytl = y - (0.5 * pos.height);
pos.generated = false;
me.track.moveboundingbox(pos);
if (pos.outside) me.track.setoutside(false);
});
}

Expand Down Expand Up @@ -108,7 +110,7 @@ function TrackEditor(shortcuts, videoframe)
this.initializeshortucts();
}

function TrackObjectUI(button, container, videoframe, job, player, tracks, shortcuts, autotracker)
function TrackObjectUI(button, container, copypastecontainer, videoframe, job, player, tracks, shortcuts, autotracker)
{
var me = this;

Expand All @@ -121,10 +123,10 @@ function TrackObjectUI(button, container, videoframe, job, player, tracks, short
this.shortcuts = shortcuts;
this.autotracker = autotracker;

this.copypastehandler = new CopyPasteHandler();
this.copypastehandler = new CopyPasteHandler(copypastecontainer, this.job);
this.trackeditor = new TrackEditor(this.shortcuts, this.videoframe);

this.drawer = new BoxDrawer(videoframe);
this.drawer = new BoxDrawer(videoframe, {"width":10, "height":10}, this.job.pointmode);

this.counter = job.nextid;

Expand All @@ -135,6 +137,93 @@ function TrackObjectUI(button, container, videoframe, job, player, tracks, short

this.selectedobject = null;

this.defaultsize = function(container) {
$("<input type=checkbox id=usedefaultsize />" +
"<label for=usedefaultsize>Default bounding box size</label>").appendTo(container);

var sizeeditor = $("<div>").appendTo(container);
var testbox = $("<div id=testbox>").css({
"border": "solid 2px blue",
"width": this.drawer.defaultsize["width"] + "px",
"height": this.drawer.defaultsize["height"] + "px",
"margin-bottom": "10px",
"margin-top": "20px"
})

$("<label for=defaultwidth>Width:</label>").appendTo(sizeeditor);
$("<div id=defaultwidth>")
.slider({
min: 0,
max: 200,
value: this.drawer.defaultsize ["width"],
slide: function (event, ui) {
testbox.css({width: ui.value});
}
})
.css({"width":"200px"})
.appendTo(sizeeditor);

$("<label for=defaultheigh>Height:</label>").appendTo(sizeeditor);
$("<div id=defaultheight>")
.slider({
min: 0,
max: 200,
value: this.drawer.defaultsize ["height"],
slide: function (event, ui) {
testbox.css({height: ui.value});
}
})
.css({"width":"200px"})
.appendTo(sizeeditor);

testbox.appendTo(sizeeditor);

if (this.drawer.oneclick) {
$("#usedefaultsize").attr('checked', 'checked');
} else {
sizeeditor.hide();
}

$("#usedefaultsize").change(function() {
if ($(this).is(":checked")) {
sizeeditor.show();
} else {
sizeeditor.hide();
}
});
}

this.defaultclass = function(container) {
var html = "<p>Select default class</p>";
for (var i in job.labels)
{
html += "<div class='label'>" +
"<input type='radio' name='classification' id='classification" + i + "' value='" + i + "'>" +
"<label for='classification" + i + "'>" + job.labels[i] + "</label></div>";
}

this.classifyinst = $("<div>" + html + "</div><br />").appendTo(container);

}

this.defaultsdialog = function(container) {
this.defaultclass(container);
if (!this.job.pointmode) {
this.defaultsize(container);
}
}

this.savedefaults = function() {
if (!this.job.pointmode) {
if (!this.job.pointmode) this.drawer.oneclick = $("#usedefaultsize").attr('checked');
this.drawer.defaultsize["width"] = $('#defaultwidth').slider("option", "value");
this.drawer.defaultsize["height"] = $('#defaultheight').slider("option", "value");
}

alert($("input[name=classification]:checked").val());

}

this.deselectcurrentobject = function()
{
this.selectedobject = null;
Expand Down Expand Up @@ -204,6 +293,7 @@ function TrackObjectUI(button, container, videoframe, job, player, tracks, short
console.log("Received new track object drawing");

var track = tracks.add(player.frame, position, this.currentcolor[0], false);
if (this.job.pointmode) this.tracks.resizable(false);

this.drawer.disable();
ui_disable();
Expand All @@ -227,7 +317,7 @@ function TrackObjectUI(button, container, videoframe, job, player, tracks, short
this.setupnewobject(this.currentobject);

this.tracks.draggable(true);
if ($("#annotateoptionsresize:checked").size() == 0)
if (!this.job.pointmode && $("#annotateoptionsresize:checked").size() == 0)
{
this.tracks.resizable(true);
}
Expand All @@ -238,6 +328,7 @@ function TrackObjectUI(button, container, videoframe, job, player, tracks, short

this.tracks.dim(false);
this.currentobject.track.highlight(false);
this.selectobject(this.currentobject);

this.button.button("option", "disabled", false);

Expand Down Expand Up @@ -722,10 +813,10 @@ function TrackObject(job, player, container, color, copypastehandler, autotracke
me.track.tracktopreviouskeyframe();
});
$("#trackobject" + this.id + "cutend").click(function() {
me.copypastehandler.cut(me.track, me.player.frame);
me.copypastehandler.cut(me, me.player.frame);
});
$("#trackobject" + this.id + "paste").click(function() {
me.copypastehandler.paste(me.track);
me.copypastehandler.paste(me);
});

this.player.onupdate.push(function() {
Expand Down Expand Up @@ -1105,23 +1196,46 @@ function TrackObject(job, player, container, color, copypastehandler, autotracke
}
}

function CopyPasteHandler()
function CopyPasteHandler(container, job)
{
var me = this;

this.annotations = null;
this.cut = function(track, frame) {
this.job = job;
this.container = container;
this.container.hide();

this.cut = function(trackobject, frame) {
var track = trackobject.track;
this.annotations = track.annotationstoend(frame);

this.container.empty();
this.container.append("<div class='title'>Clipboard</div>");
this.container.append("<strong>Cut: </strong>" + this.annotations.length + " frames<br />");
this.container.append("<strong>From: </strong> " + this.job.labels[track.label] + " " + track.id + "<br />");
$("<input type=button value='Clear' />")
.appendTo(this.container)
.click(function() {
me.annotations = null;
me.container.slideUp(null, function() {me.container.empty();});
});

this.container.slideDown();
track.cleartoend(frame);
}

this.paste = function(track) {
this.paste = function(trackobject) {
if (!this.annotations) {
alert("Nothing to paste");
return;
}

var track = trackobject.track;
var range = this.framerange();
track.clearbetweenframes(range['min'], range['max']);
track.addannotations(this.annotations);
trackobject.toggletooltip(false);
setTimeout(function() {trackobject.hidetooltip();}, 3000);
}

this.framerange = function() {
Expand Down
17 changes: 17 additions & 0 deletions public/stylesheet.css
Expand Up @@ -145,6 +145,23 @@ canvas
width : 80px;
}

#copypastecontainer
{

font-family : Arial;
font-size : 14px;
background-color: yellow;
padding: 5px;
border-bottom: 2px solid black;
}

#copypastecontainer .title
{
text-align: center;
font-weight: bold;
margin-bottom: 3px;
}

#newobjectcontainer
{
text-align : center;
Expand Down
25 changes: 20 additions & 5 deletions public/tracks.js
@@ -1,10 +1,13 @@
/*
* Allows the user to draw a box on the screen.
*/
function BoxDrawer(container)
function BoxDrawer(container, defaultsize, oneclick)
{
var me = this;

this.defaultsize = defaultsize;
this.oneclick = oneclick;

this.onstartdraw = [];
this.onstopdraw = []

Expand Down Expand Up @@ -79,7 +82,18 @@ function BoxDrawer(container)
{
if (this.enabled)
{
if (!this.drawing)
if (this.oneclick)
{
this.drawing = true;
var minx = xc - (this.defaultsize["width"] / 2);
var miny = yc - (this.defaultsize["height"] / 2);
var maxx = xc + (this.defaultsize["width"] / 2);
var maxy = yc + (this.defaultsize["height"] / 2);
this.startx = minx;
this.starty = miny;
this.finishdrawing(maxx, maxy);
}
else if (!this.drawing)
{
this.startdrawing(xc, yc);
}
Expand Down Expand Up @@ -186,7 +200,7 @@ function BoxDrawer(container)
}

this.drawing = false;
this.handle.remove();
if (this.handle) this.handle.remove();
this.startx = 0;
this.starty = 0;
}
Expand Down Expand Up @@ -694,6 +708,7 @@ function Track(player, topviewplayer, color, position, runtracking)
this.journal.mark(this.player.frame, pos);
this.journal.artificialright = this.journal.rightmost();
this.journal.cleartonextkeyframe(this.player.frame);
this.journal.artificialright = this.journal.rightmost();
this.draw(this.player.frame, pos);
}

Expand Down Expand Up @@ -1365,7 +1380,7 @@ function Journal(start, blowradius)
var item = this.annotations[t];
itemtime = parseInt(t);

if (itemtime > frame)
if (itemtime > frame && !item.generated)
{
if (next == null || itemtime < nexttime)
{
Expand All @@ -1388,7 +1403,7 @@ function Journal(start, blowradius)
var item = this.annotations[t];
itemtime = parseInt(t);

if (itemtime < frame)
if (itemtime < frame && !item.generated)
{
if (previous == null || itemtime > previoustime)
{
Expand Down

0 comments on commit c6bda41

Please sign in to comment.