Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added padding code for videos #117

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions annotator/static/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,20 @@ class Player {
if (this.annotations.length === 0 && !confirm('Confirm that there are no objects in the video?')) {
return;
}

// account for offset of 5% set in initPaper()
for (let annotation of this.annotations) {
for (let keyframe of annotation.keyframes) {
let video = $(".player-video");
let offset_width = video.outerWidth() * 0.05;
let offset_height = video.outerHeight() * 0.05;
keyframe.bounds.xMin -= offset_width;
keyframe.bounds.xMax -= offset_width;
keyframe.bounds.yMin -= offset_height;
keyframe.bounds.yMax -= offset_height;
}
}

DataSources.annotations.save(this.videoId, this.annotations, this.metrics, window.mturk).then((response) => {
// only show this if not running on turk
if (!window.hitId)
Expand Down
24 changes: 16 additions & 8 deletions annotator/static/views/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,24 +115,30 @@ class PlayerView {
initPaper() {
// Depends on this.videoReady for this.video.videoWidth/Height
this.videoReady().then(() => {
var {videoWidth, videoHeight, viewWidth, viewHeight} = this.video;
this.$paper = Raphael(this.$('paper')[0], videoWidth, videoHeight);
var {videoWidth, videoHeight} = this.video;
let playerPaper = $(".player-paper");
let paper_height = playerPaper.outerHeight();
let paper_width = playerPaper.outerWidth();
this.$paper = Raphael(this.$('paper')[0], paper_width, paper_height);

var css = {
position: 'absolute',
top: 0,
left: 0,
'width': `${viewWidth}px`,
'height': `${viewHeight}px`,
'width': `${paper_width}px`,
'height': `${paper_height}px`,
};

$(this.video.videoElement).css({top:videoHeight*0.05, left:videoWidth*0.05});

$(this.$paper.canvas).attr({
viewBox: `0 0 ${videoWidth} ${videoHeight}`
viewBox: `0 0 ${paper_width} ${paper_height}`
}).removeAttr(
'width'
).removeAttr(
'height'
).css(css);

this.creationRect = this.makeAndAttachRect(CreationRect);
this.rects = [];

Expand Down Expand Up @@ -162,11 +168,13 @@ class PlayerView {
// if we just toggled scale to fit the video properties are not up to date yet
if (this.$paper) {
setTimeout(() => {
var {viewWidth, viewHeight} = this.video;
let playerPaper = $(".player-paper");
let paper_height = playerPaper.outerHeight();
let paper_width = playerPaper.outerWidth();
$(this.$paper.canvas)
.css({
'width': `${viewWidth}px`,
'height': `${viewHeight}px`,
'width': `${paper_width}px`,
'height': `${paper_height}px`,
});
}, 10);
}
Expand Down