|
@@ -7,13 +7,17 @@
|
|
|
|
|
|
<annotation-box v-if="current"
|
|
|
:image="image"
|
|
|
- :position="current"/>
|
|
|
+ :position="current"
|
|
|
+ :immutable="true"/>
|
|
|
|
|
|
<annotation-box v-for="(result, index) in predictions"
|
|
|
type="server"
|
|
|
:key="index"
|
|
|
:image="image"
|
|
|
- :position="result"/>
|
|
|
+ :position="result"
|
|
|
+ :socket="socket"
|
|
|
+ :immutable="false"
|
|
|
+ :box-url="mediaUrl + '/' + result.id"/>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -24,7 +28,7 @@ export default {
|
|
|
name: "annotated-image",
|
|
|
components: {AnnotationBox},
|
|
|
props: ['project', 'data', 'socket'],
|
|
|
- mounted: function() {
|
|
|
+ mounted: function () {
|
|
|
window.addEventListener("resize", this.resizeEvent);
|
|
|
|
|
|
if (this.$refs.image.complete)
|
|
@@ -36,12 +40,12 @@ export default {
|
|
|
window.removeEventListener("resize", this.resizeEvent);
|
|
|
},
|
|
|
watch: {
|
|
|
- data: function() {
|
|
|
+ data: function () {
|
|
|
this.current = false;
|
|
|
this.resizeEvent();
|
|
|
}
|
|
|
},
|
|
|
- data: function() {
|
|
|
+ data: function () {
|
|
|
return {
|
|
|
sizes: [600, 800, 1200, 1600, 2000, 3000],
|
|
|
image: {
|
|
@@ -80,7 +84,7 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- resizeEvent: function() {
|
|
|
+ resizeEvent: function () {
|
|
|
const element = this.$refs.image.getBoundingClientRect();
|
|
|
const parent = this.$refs.image.parentElement.getBoundingClientRect();
|
|
|
|
|
@@ -89,7 +93,7 @@ export default {
|
|
|
this.image.width = element.width;
|
|
|
this.image.height = element.height;
|
|
|
},
|
|
|
- get: function(event) {
|
|
|
+ get: function (event) {
|
|
|
if ('clientX' in event)
|
|
|
return event;
|
|
|
if ('touches' in event && event.touches.length > 0)
|
|
@@ -97,15 +101,15 @@ export default {
|
|
|
if ('changedTouches' in event && event.changedTouches.length > 0)
|
|
|
return event.changedTouches[0];
|
|
|
},
|
|
|
- getX: function(event) {
|
|
|
+ getX: function (event) {
|
|
|
const bcr = this.$refs.image.getBoundingClientRect();
|
|
|
return (this.get(event).clientX - bcr.left) / bcr.width;
|
|
|
},
|
|
|
- getY: function(event) {
|
|
|
+ getY: function (event) {
|
|
|
const bcr = this.$refs.image.getBoundingClientRect();
|
|
|
return (this.get(event).clientY - bcr.top) / bcr.height;
|
|
|
},
|
|
|
- buildRectangle: function(x1, y1, x2, y2) {
|
|
|
+ buildRectangle: function (x1, y1, x2, y2) {
|
|
|
const lx = Math.max(Math.min(x1, x2), 0);
|
|
|
const hx = Math.min(Math.max(x1, x2), 1);
|
|
|
const ly = Math.max(Math.min(y1, y2), 0);
|
|
@@ -118,7 +122,7 @@ export default {
|
|
|
h: hy - ly
|
|
|
}
|
|
|
},
|
|
|
- press: function(event) {
|
|
|
+ press: function (event) {
|
|
|
this.start = {
|
|
|
x: this.getX(event),
|
|
|
y: this.getY(event)
|
|
@@ -131,12 +135,13 @@ export default {
|
|
|
|
|
|
this.current = this.buildRectangle(this.start.x, this.start.y, x, y);
|
|
|
}
|
|
|
-
|
|
|
},
|
|
|
release: function () {
|
|
|
- this.socket.post(this.mediaUrl, this.current);
|
|
|
- this.start = false;
|
|
|
- this.current = false;
|
|
|
+ if (this.start) {
|
|
|
+ this.socket.post(this.mediaUrl, this.current);
|
|
|
+ this.start = false;
|
|
|
+ this.current = false;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|