+
+
@@ -107,20 +105,27 @@
this.resultData = fakeData.testData
},
selectImage () {
- this.$refs.image_chooser.click()
- //TODO This really needs to be a promise and resolve system
- this.imageLoaded = true;
- var box = this.$refs.structure_box
+ var loadResult = this.$refs.image_chooser.click()
},
selectChip ( iChip ) {
+ var imgWidth
+ var imgHeight
+
this.selectedChip = iChip
- var box = this.$refs.structure_box
- var img = this.$refs.image_src
- var imgWidth = img.offsetWidth
- var imgHeight = img.offsetHeight
+ const box = this.$refs.structure_box
+ const img = this.$refs.image_src
+ var imgAspect = img.naturalWidth / img.naturalHeight
+ var rendAspect = img.offsetWidth / img.offsetHeight
+ if (imgAspect >= rendAspect) {
+ imgWidth = img.offsetWidth
+ imgHeight = img.offsetWidth / imgAspect
+ } else {
+ imgWidth = img.offsetHeight * imgAspect
+ imgHeight = img.offsetHeight
+ }
box.style.display = "block"
- box.style.left = `calc( 50% - ${imgWidth/2}px + ${this.resultData.detections[iChip].left * imgWidth}px)`
- box.style.top = `${this.resultData.detections[iChip].top * imgHeight}px`
+ box.style.left = `${(img.offsetWidth - imgWidth) / 2 + this.resultData.detections[iChip].left * imgWidth}px`
+ box.style.top = `${(img.offsetHeight - imgHeight) / 2 + this.resultData.detections[iChip].top * imgHeight}px`
box.style.width = `${(this.resultData.detections[iChip].right - this.resultData.detections[iChip].left) * imgWidth}px`
box.style.height = `${(this.resultData.detections[iChip].bottom - this.resultData.detections[iChip].top) * imgHeight}px`
},
@@ -132,6 +137,7 @@
getImage () {
var example = this.$refs.image_chooser.files[0];
this.imageView = URL.createObjectURL(example);
+ this.imageLoaded = true;
}
}
}