Skip to content

Commit

Permalink
Backend unit tests (scalabel#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
seanremy authored and fyu committed Jul 16, 2018
1 parent e9607b4 commit e5ddc4d
Show file tree
Hide file tree
Showing 12 changed files with 811 additions and 613 deletions.
10 changes: 3 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@
# don't upload macOS folder info
*.DS_Store

# don't upload the data directory
data/*

# don't upload node_modules from npm test
node_modules/*
package-lock.json

# don't upload the server config, as it will vary.
# (we still upload the example config)
config.yml

# potential files generated by golang
bin/

# don't upload items directory
items/
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
language: python
language: go
python:
- "3.5"
- "3.6"
go:
- "1.10"
go_import_path: github.com/ucbdrive/sat
before_install:
- sudo apt-get update
- sudo apt-get install -y npm
- npm install -g eslint eslint-config-google
install:
- pip install pycodestyle
- sudo pip install --upgrade pip
- sudo pip install pycodestyle
- go get gopkg.in/yaml.v2
- npm install
script:
Expand Down
74 changes: 2 additions & 72 deletions app/src/js/point_cloud/box3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,89 +13,19 @@ function Box3d(sat, id) {

Box3d.prototype = Object.create(SatLabel.prototype);

Box3d.prototype.color = function() {
let color = SatLabel.prototype.color.call(this);
let newColor = [];
for (let i = 0; i < color.length; i++) {
newColor.push(color[i] / 255.0);
}
return newColor;
};

Box3d.prototype.setColor = function(hexColor, faces=null) {
let inputArray = typeof hexColor == 'object';
if (faces != null) {
for (let i = 0; i < faces.length; i++) {
if (inputArray) {
this.box.geometry.faces[faces[i]].color.fromArray(hexColor);
} else {
this.box.geometry.faces[faces[i]].color.set(hexColor);
}
this.box.geometry.faces[faces[i]].color.setHex(hexColor);
}
} else {
for (let i = 0; i < this.box.geometry.faces.length; i++) {
if (inputArray) {
this.box.geometry.faces[i].color.fromArray(hexColor);
} else {
this.box.geometry.faces[i].color.set(hexColor);
}
this.box.geometry.faces[i].color.setHex(hexColor);
}
}
this.box.geometry.colorsNeedUpdate = true;
};

Box3d.prototype.createBox = function(position) {
let box = new THREE.Mesh(
new THREE.BoxGeometry( 1, 1, 1 ),
new THREE.MeshBasicMaterial({color: 0xffffff,
vertexColors: THREE.FaceColors,
transparent: true,
opacity: 0.5})
);

let outline = new THREE.LineSegments(
new THREE.EdgesGeometry(box.geometry),
new THREE.LineBasicMaterial({color: 0xffffff}));

box.outline = outline;
box.label = this;

this.box = box;

if (this.data) {
box.position.x = this.data['position'][0];
box.position.y = this.data['position'][1];
box.position.z = this.data['position'][2];
box.outline.position.copy(box.position);

box.rotation.x = this.data['rotation'][0];
box.rotation.y = this.data['rotation'][1];
box.rotation.z = this.data['rotation'][2];
box.outline.rotation.copy(box.rotation);

box.scale.x = this.data['scale'][0];
box.scale.y = this.data['scale'][1];
box.scale.z = this.data['scale'][2];
box.outline.scale.copy(box.scale);
} else {
box.scale.z = 0.01;

this.data = {};
this.data['position'] = [position.x, position.y, position.z];
this.data['rotation'] = [box.rotation.x, box.rotation.y,
box.rotation.z];
this.data['scale'] = [box.scale.x, box.scale.y, box.scale.z];

box.position.copy(position);
box.outline.position.copy(box.position);
box.outline.scale.copy(box.scale);
}

this.setColor(this.color());

return box;
};

Box3d.prototype.moveBoxAlongViewPlane = function(viewPlaneNormal,
viewPlaneOffset,
boxMouseOverPoint,
Expand Down
62 changes: 52 additions & 10 deletions app/src/js/point_cloud/sat_point_cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ function SatPointCloud(sat, index, url) {
this.EDITING = 2;

this.selectionState = this.STANDBY;
this.SELECTION_COLOR = 0xff0000;
this.ADJUSTING_COLOR = 0xff8000;

this.MOVING_BOX = 1;
this.ROTATING_BOX = 2;
Expand Down Expand Up @@ -581,7 +579,7 @@ SatPointCloud.prototype.handleMouseUp = function() {
if (this.selectionState == this.EDITING) {
this.selectionState = this.ADJUSTING;
if (this.editState != this.MOVING_BOX) {
this.selectedLabel.setColor(this.ADJUSTING_COLOR);
this.selectedLabel.setColor(0xff0000);
}
this.editState = this.MOVING_BOX;
}
Expand Down Expand Up @@ -676,7 +674,6 @@ SatPointCloud.prototype.handleKeyDown = function(e) {
} else if (this.selectionState == this.STANDBY) {
if (this.selectedLabel != null) {
this.selectionState = this.ADJUSTING;
this.selectedLabel.setColor(this.ADJUSTING_COLOR);
}
}
break;
Expand Down Expand Up @@ -709,20 +706,65 @@ SatPointCloud.prototype.handleKeyUp = function() {
this.editState = this.MOVING_BOX;
}
if (this.selectionState == this.ADJUSTING) {
this.selectedLabel.setColor(this.ADJUSTING_COLOR);
this.selectedLabel.setColor(0xff0000);
}
};

SatPointCloud.prototype.addBoundingBox = function(label, select=false) {
let box = label.createBox(this.target);
let box = new THREE.Mesh(
new THREE.BoxGeometry( 1, 1, 1 ),
new THREE.MeshBasicMaterial({color: 0xffffff,
vertexColors: THREE.FaceColors,
transparent: true,
opacity: 0.5})
);

let outline = new THREE.LineSegments(
new THREE.EdgesGeometry(box.geometry),
new THREE.LineBasicMaterial({color: 0xffffff}));

box.outline = outline;
box.label = label;
this.bounding_boxes.push(box);

label.box = box;

if (label.data) {
box.position.x = label.data['position'][0];
box.position.y = label.data['position'][1];
box.position.z = label.data['position'][2];
box.outline.position.copy(box.position);

box.rotation.x = label.data['rotation'][0];
box.rotation.y = label.data['rotation'][1];
box.rotation.z = label.data['rotation'][2];
box.outline.rotation.copy(box.rotation);

box.scale.x = label.data['scale'][0];
box.scale.y = label.data['scale'][1];
box.scale.z = label.data['scale'][2];
box.outline.scale.copy(box.scale);
} else {
box.scale.z = 0.01;

label.data = {};
label.data['position'] = [this.target.x, this.target.y,
this.target.z];
label.data['rotation'] = [box.rotation.x, box.rotation.y,
box.rotation.z];
label.data['scale'] = [box.scale.x, box.scale.y, box.scale.z];

box.position.copy(this.target);
box.outline.position.copy(box.position);
box.outline.scale.copy(box.scale);
}

this.addLabelToList(label);

if (select) {
this.selectedLabelNewBox = true;
this.select(label);
this.selectionState = this.ADJUSTING;
label.setColor(this.ADJUSTING_COLOR);
this._changeSelectedLabelCategory();
}

Expand Down Expand Up @@ -809,7 +851,7 @@ SatPointCloud.prototype.select = function(label) {
// If selecting same thing, then only deselect
if (temp != label) {
this.selectedLabel = label;
this.selectedLabel.setColor(this.SELECTION_COLOR);
this.selectedLabel.setColor(0xff0000);

this.info_card.style.display = 'block';

Expand Down Expand Up @@ -886,7 +928,7 @@ SatPointCloud.prototype.select = function(label) {

SatPointCloud.prototype.deselect = function() {
if (this.selectedLabel != null) {
this.selectedLabel.setColor(this.selectedLabel.color());
this.selectedLabel.setColor(0xffffff);
this.selectedLabel = null;
this.info_card.style.display = 'none';
this.deactivateLabelList();
Expand Down Expand Up @@ -969,7 +1011,7 @@ SatPointCloud.prototype.highlightMousedOverBox = function(mX, mY) {
// Highlight current box
if (intersects.length > 0) {
this.boxMouseOver = intersects[0].object;
this.boxMouseOver.outline.material.color.set(this.SELECTION_COLOR);
this.boxMouseOver.outline.material.color.set(0xff0000);
this.boxMouseOverPoint = intersects[0].point;
}
};
Expand Down
File renamed without changes.
Loading

0 comments on commit e5ddc4d

Please sign in to comment.