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

Splitter tool #21

Open
wants to merge 4 commits 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
2 changes: 1 addition & 1 deletion annotation_tools/db_dataset_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def main():
elif action == 'export':
dataset = export_dataset(db, denormalize=args.denormalize)
with open(args.output_path, 'w') as f:
json.dump(dataset, f)
json.dump(dataset, f, indent=4)

if __name__ == '__main__':

Expand Down
413 changes: 1 addition & 412 deletions annotation_tools/static/app.bundle.js

Large diffs are not rendered by default.

49 changes: 45 additions & 4 deletions client/views/leaflet_annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ export class LeafletAnnotation extends React.Component {
let S_KEY = 83; // Save annotations
let N_KEY = 78; // New instance
let V_KEY = 86; // Toggle visibility
let ONE_KEY = 49
let TWO_KEY = 50
let THREE_KEY = 51


switch(e.keyCode){
Expand Down Expand Up @@ -236,6 +239,27 @@ export class LeafletAnnotation extends React.Component {
case V_KEY:
this.toggleKeypointVisibility();
break;
// Remove the nose
case ONE_KEY:
console.log("Heere")
console.log(this.current_annotationIndex)
if (this.current_annotationIndex != null) {
this.handleKeypointVisibilityChange(this.current_annotationIndex, 0, 0, true);
}
break;
// Remove the left eye
case TWO_KEY:
if (this.current_annotationIndex != null) {
this.handleKeypointVisibilityChange(this.current_annotationIndex, 1, 0, true);
}
break;
// Remove the right eye
case THREE_KEY:
if (this.current_annotationIndex != null) {
this.handleKeypointVisibilityChange(this.current_annotationIndex, 2, 0, true);
}
break;

}

}
Expand Down Expand Up @@ -636,8 +660,10 @@ export class LeafletAnnotation extends React.Component {
* We can queue up keypoint annotations and iterate through them.
*/
checkKeypointAnnotationQueue(){
console.log("Annotation keypoint queue", this.annotation_keypoint_queue)
// When a new instance is created we can queue up the keypoints to annotate
if (this.annotation_keypoint_queue.length > 0){

let anno = this.annotation_keypoint_queue.shift();
this.handleKeypointVisibilityChange(anno['annotationIndex'], anno['keypointIndex'], 2);
}
Expand All @@ -659,22 +685,25 @@ export class LeafletAnnotation extends React.Component {
* @param {*} keypointIndex
* @param {*} visibility
*/
handleKeypointVisibilityChange(annotationIndex, keypointIndex, visibility){
//console.log("annotation " + annotationIndex + " keypoint " + keypointIndex + " vis " + visibility);
handleKeypointVisibilityChange(annotationIndex, keypointIndex, visibility, force_delete = false){
console.log("annotation " + annotationIndex + " keypoint " + keypointIndex + " vis " + visibility);

// If we are in the middle of annotating something else, then ignore this request
if (this.state.annotating){
if (!(this.current_annotationIndex == annotationIndex && this.annotating_keypoint && this.current_keypointIndex == keypointIndex)){
if (!force_delete && !(this.current_annotationIndex == annotationIndex && this.annotating_keypoint && this.current_keypointIndex == keypointIndex)){
return;
}
}

let prev_visibility = this.state.annotations[annotationIndex]['keypoints'][keypointIndex * 3 + 2];

console.log("Here698")
if (visibility == 0){

console.log("Here700")
// Are we currently annotating?
if (this.state.annotating){
if (this.state.annotating && !force_delete){
console.log("Here704")
// Are we currently annotating this keypoint?
if (this.current_annotationIndex == annotationIndex && this.annotating_keypoint && this.current_keypointIndex == keypointIndex){
// cancel the drawer
Expand All @@ -686,9 +715,15 @@ export class LeafletAnnotation extends React.Component {
else{
// was this keypoint visible?
if (prev_visibility > 0){
console.log("Here714")
// remove the keypoint layer
let keypoint_layer = this.annotation_layers[annotationIndex]['keypoints'][keypointIndex];
this.annotationFeatures.removeLayer(keypoint_layer);

if (force_delete) {
this.annotation_layers[annotationIndex]['keypoints'][keypointIndex] = null;
}
console.log('annotation layer' + this.annotation_layers[annotationIndex]['keypoints'][keypointIndex])
}

this.setState(function(prevState, props){
Expand Down Expand Up @@ -733,6 +768,7 @@ export class LeafletAnnotation extends React.Component {

// Does a layer exist for this keypoint?
var keypoint_layer = this.annotation_layers[annotationIndex]['keypoints'][keypointIndex];
console.log('keypoint_layer ' + keypoint_layer)
if(keypoint_layer != null){
if (prev_visibility == 0){
// just render the existing layer
Expand All @@ -758,6 +794,7 @@ export class LeafletAnnotation extends React.Component {

}
else{
console.log("789")
// we need to annotate this keypoint
let annotation = this.state.annotations[annotationIndex];
let category = this.categoryMap[annotation['category_id']];
Expand Down Expand Up @@ -1211,11 +1248,14 @@ export class LeafletAnnotation extends React.Component {
*/
handleAnnotateKeypoints(annotationIndex){

console.log("handle annotate keypoints")
if (this.state.annotating){
// ignore
return;
}

this.current_annotationIndex = annotationIndex

let annotation = this.state.annotations[annotationIndex];
let annotation_layer = this.annotation_layers[annotationIndex];

Expand All @@ -1231,6 +1271,7 @@ export class LeafletAnnotation extends React.Component {
for (var j=0; j < category.keypoints.length; j++){
let index = j * 3;
let visibility = annotation.keypoints[index + 2];
console.log('j ' + j + 'visibility ' + visibility)
if (visibility == 0){
this.annotation_keypoint_queue.push({
'annotationIndex' : annotationIndex,
Expand Down
Loading