Skip to content

Commit

Permalink
try adding labeling annots
Browse files Browse the repository at this point in the history
  • Loading branch information
birm committed Oct 2, 2023
1 parent 6ed68fd commit 21d906a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
1 change: 1 addition & 0 deletions apps/labeling/labelReview.html
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ <h5 class="modal-title" style="font-size: 1.5rem;">Modal title</h5>
<div id="label_review">
<b>Double click a roi to get its details.</b>
</div>
<div id="annot_review"></div>
</div>
</div>
<div id="next" class="foot" style="margin: 0.5rem; display: none">
Expand Down
41 changes: 39 additions & 2 deletions apps/labeling/labelReview.js
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ function setDownloadModalProgress(num) {
}

function labelInfoToHtml(label) {
let text = '';
let text = "<div class='labelHtml'>";

Check failure on line 757 in apps/labeling/labelReview.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Strings must use singlequote

Check failure on line 757 in apps/labeling/labelReview.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Strings must use singlequote
// top level fields

if (false && label.alias) {
Expand Down Expand Up @@ -800,11 +800,42 @@ function labelInfoToHtml(label) {
text += '<br/>';
}
}
text += "</div>"

Check failure on line 803 in apps/labeling/labelReview.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Strings must use singlequote

Check failure on line 803 in apps/labeling/labelReview.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Missing semicolon

Check failure on line 803 in apps/labeling/labelReview.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Strings must use singlequote

Check failure on line 803 in apps/labeling/labelReview.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Missing semicolon
return text;
}

function labelAnnotToHtml(annot){

Check failure on line 807 in apps/labeling/labelReview.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Missing space before opening brace

Check failure on line 807 in apps/labeling/labelReview.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Missing space before opening brace
let text = "<div class='annotHtml'>";

Check failure on line 808 in apps/labeling/labelReview.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Strings must use singlequote

Check failure on line 808 in apps/labeling/labelReview.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Strings must use singlequote
// top level fields

if (annot.create_date) {
text += '<b>Create Date/Time:</b> ';
text += annot.create_date;
text += '<br/>';
}
let skip_props = ['style']

Check failure on line 816 in apps/labeling/labelReview.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Identifier 'skip_props' is not in camel case

Check failure on line 816 in apps/labeling/labelReview.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Identifier 'skip_props' is not in camel case
// now go through properties
for (let propkey in annot.properties) {
if (skip_props.indexOf(propkey) == -1) {
text += '<b>' + propkey.replaceAll('_', ' ') + ':</b> ';
let propdata = annot.properties[propkey];
if (Array.isArray(propdata)) {
text += propdata.join(', ');
} else if (typeof(propdata) == 'object') {
text += 'An object with:';
text +=JSON.stringify(propdata).replaceAll('{', '').replaceAll('}', '');
} else {
text += propdata;
}
text += '<br/>';
}
}
text += "</div>"
return text;
}

// only works for square labels
function getLabelInfo(e) {
async function getLabelInfo(e) {
const img_point = $CAMIC.viewer.viewport.viewportToImageCoordinates($CAMIC.viewer.viewport.pointFromPixel(e.position, true));
let matched_labels = $D.ROIs.filter((label)=>{
if (label.properties.x < img_point.x && label.properties.y < img_point.y) {
Expand All @@ -819,4 +850,10 @@ function getLabelInfo(e) {
});
let texts = matched_labels.map(labelInfoToHtml);
document.getElementById('label_review').innerHTML = texts.join('<br/><hr/><br/>');
// render relevant annotations
let annots = [];
for (let label of matched_labels){
annots = await $CAMIC.store.findLabeling({'creator': $USER, 'parent': label._id.$oid});
}
document.getElementById('annot_review').innerHTML = annots.join('<br/><hr/><br/>');
}

0 comments on commit 21d906a

Please sign in to comment.