From 8ef2ea6aa4949535bfd9feeda2504a071169969f Mon Sep 17 00:00:00 2001 From: Justin Georgi Date: Sun, 15 Sep 2024 16:13:20 -0700 Subject: [PATCH] Fix timing of image refreshing Signed-off-by: Justin Georgi --- src/pages/detect.vue | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/pages/detect.vue b/src/pages/detect.vue index ead910a..0b8a6f5 100644 --- a/src/pages/detect.vue +++ b/src/pages/detect.vue @@ -70,7 +70,7 @@ - + {{ showResults.length - numResults }} @@ -335,6 +335,9 @@ self.reloadModel = false loadSuccess() } + f7.utils.nextFrame(() => { + this.selectChip("redraw") + }) } } @@ -376,6 +379,9 @@ f7.dialog.alert(`ALVINN structure finding error: ${e.message}`) }) } + f7.utils.nextFrame(() => { + this.selectChip("redraw") + }) }, selectAll (ev) { if (ev.target.checked) { @@ -429,7 +435,7 @@ alert(`Camera fail: ${message}`) }, selectChip ( iChip ) { - const [imCanvas, imageCtx] = this.resetView() + const [_, imageCtx] = this.resetView() if (this.selectedChip == iChip) { this.selectedChip = -1 @@ -478,6 +484,11 @@ imageCtx.strokeStyle = 'yellow' imageCtx.lineWidth = 3 if (this.imageLoaded) { + let imageLoc = this.box2cvs({top: 0,left: 0,right: 1,bottom: 1}) + this.imCvsLocation.top = imageLoc[0].cvsTop + this.imCvsLocation.left = imageLoc[0].cvsLeft + this.imCvsLocation.width = imageLoc[0].cvsRight - imageLoc[0].cvsLeft + this.imCvsLocation.height = imageLoc[0].cvsBottom - imageLoc[0].cvsTop imageCtx.drawImage(this.imageView, 0, 0, this.imageView.width, this.imageView.height, this.imCvsLocation.left, this.imCvsLocation.top, this.imCvsLocation.width, this.imCvsLocation.height) } return [imCanvas, imageCtx] @@ -564,9 +575,7 @@ box2cvs(boxInput) { if (!boxInput || boxInput.length == 0) return [] const boxList = boxInput.length ? boxInput : [boxInput] - //const [imCanvas, imageCtx] = this.resetView() const imCanvas = this.$refs.image_cvs - //const imageCtx = imCanvas.getContext("2d") var imgWidth var imgHeight const imgAspect = this.imageView.width / this.imageView.height @@ -587,6 +596,12 @@ } }) return cvsCoords + }, + toggleSettings() { + this.showDetectSettings = !this.showDetectSettings + f7.utils.nextFrame(() => { + this.selectChip("redraw") + }) } } }