From dbef71eea57d38e11c15ef6e00863a99def3cb45 Mon Sep 17 00:00:00 2001 From: Wasif Mehmood Date: Sun, 24 Sep 2023 02:25:08 +0500 Subject: [PATCH 1/4] PR#18: Intercept reloading with confirmation box --- ybat.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ybat.js b/ybat.js index 5a47816..20e650c 100644 --- a/ybat.js +++ b/ybat.js @@ -85,6 +85,10 @@ alert("Restore function is not supported. If you need it, use Chrome or Firefox instead.") } + window.onbeforeunload = function(){ + return 'Are you sure you want to leave the page?'; + }; + // Start everything document.onreadystatechange = () => { if (document.readyState === "complete") { From 82de67befe1557adf66027b566e2b103233d31c8 Mon Sep 17 00:00:00 2001 From: Wasif Mehmood Date: Sun, 24 Sep 2023 02:25:52 +0500 Subject: [PATCH 2/4] PR#24: Edit segmentation in function listenBboxCocoSave --- ybat.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ybat.js b/ybat.js index 20e650c..cc63b54 100644 --- a/ybat.js +++ b/ybat.js @@ -1152,12 +1152,12 @@ for (let i = 0; i < bboxes[imageName][className].length; i++) { const bbox = bboxes[imageName][className][i] - const segmentation = [ + const segmentation = [[ bbox.x, bbox.y, bbox.x, bbox.y + bbox.height, bbox.x + bbox.width, bbox.y + bbox.height, bbox.x + bbox.width, bbox.y - ] + ]] result.annotations.push({ segmentation: segmentation, From 57c284fe739a6d61d29b1a099b76fe7ccb86f111 Mon Sep 17 00:00:00 2001 From: Wasif Mehmood Date: Sun, 24 Sep 2023 02:28:29 +0500 Subject: [PATCH 3/4] similar bgcolor for the same class is implemented for all images. --- ybat.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ybat.js b/ybat.js index cc63b54..821af48 100644 --- a/ybat.js +++ b/ybat.js @@ -28,6 +28,7 @@ let images = {} let classes = {} let bboxes = {} + const bboxBgColorStore = new Map(); const extensions = ["jpg", "jpeg", "png", "JPG", "JPEG", "PNG"] @@ -160,10 +161,15 @@ for (let className in currentBboxes) { currentBboxes[className].forEach(bbox => { + if(!bboxBgColorStore.has(bbox.class)) { + bboxBgColorStore.set(bbox.class, bbox?.bgColor); + } setFontStyles(context, bbox.marked) - context.fillText(className, zoomX(bbox.x), zoomY(bbox.y - 2)) + if (currentBbox !== null && currentBbox.index === i && bbox.marked) { + context.fillText(className, zoomX(bbox.x), zoomY(bbox.y - 2)) + } - setBBoxStyles(context, bbox.marked) + setBBoxStyles(context, bbox.marked, bboxBgColorStore.get(bbox.class)) context.strokeRect(zoomX(bbox.x), zoomY(bbox.y), zoom(bbox.width), zoom(bbox.height)) context.fillRect(zoomX(bbox.x), zoomY(bbox.y), zoom(bbox.width), zoom(bbox.height)) From 362713a4e9a3aa1296f89ca81a8c8b3846691257 Mon Sep 17 00:00:00 2001 From: Wasif Mehmood Date: Sun, 24 Sep 2023 02:30:51 +0500 Subject: [PATCH 4/4] copy/paste bbox with ctrl c and v --- ybat.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ybat.js b/ybat.js index 821af48..a61a2b4 100644 --- a/ybat.js +++ b/ybat.js @@ -1201,10 +1201,31 @@ const listenKeyboard = () => { const imageList = document.getElementById("imageList") const classList = document.getElementById("classList") + let copiedBbox; document.addEventListener("keydown", (event) => { const key = event.keyCode || event.charCode + // Copying event capture + if ((event.ctrlKey || event.metaKey) && event.key === 'c') { + if(!currentBbox) return; + + copiedBbox = {...currentBbox.bbox} + copiedBbox.marked = false; + } + + // Pasting event capture + if ((event.ctrlKey || event.metaKey) && event.key === 'v') { + if(!copiedBbox) return; + + copiedBbox.x = mouse.realX + copiedBbox.y = mouse.realY + if(!bboxes[currentImage.name] || !bboxes[currentImage.name][copiedBbox.class]) { + bboxes[currentImage.name] = {...bboxes[currentImage.name], [copiedBbox.class]: []} + } + bboxes[currentImage.name][copiedBbox.class].push({...copiedBbox}) + } + if (key === 46 || (key === 8 && event.metaKey === true)) { if (currentBbox !== null) { bboxes[currentImage.name][currentBbox.bbox.class].splice(currentBbox.index, 1)