提交代码

This commit is contained in:
jiang 2024-11-28 17:30:25 +08:00
parent 65c63d3317
commit 1faa3b88cc
1 changed files with 22 additions and 46 deletions

View File

@ -5,8 +5,8 @@
</template>
<script>
import LabelStudio from 'label-studio';
import 'label-studio/build/static/css/main.css';
import LabelStudio from 'label-studio'
import 'label-studio/build/static/css/main.css'
export default {
name: 'CustomLabelStudio',
@ -25,7 +25,7 @@ export default {
name: "自定义按钮",
icon: "🔍",
action: () => {
console.log("自定义按钮被点击了!");
console.log("自定义按钮被点击了!")
}
}
],
@ -40,6 +40,7 @@ export default {
"RELATIONS": "关系",
"REGIONS": "区域",
"RESULTS": "结果",
// ...
},
labelConfig: `
<View>
@ -50,9 +51,12 @@ export default {
</RectangleLabels>
</View>
`,
previousAnnotations: [] //
};
previousAnnotations: [] //
}
},
watch:{
}
mounted() {
this.initLabelStudio();
},
@ -75,53 +79,30 @@ export default {
firstName: "James",
lastName: "Dean"
},
task: JSON.parse(this.task),
task:JSON.parse( this.task),
locale: 'zh_CN',
messages: this.chineseLocalization,
onLabelStudioLoad: (LS) => {
console.log("Label Studio 已加载", LS);
var c = LS.annotationStore.addAnnotation({
//
setInterval(() => {
this.checkAnnotations(LS);
}, 1000); //
//
const annotation = LS.annotationStore.addAnnotation({
userGenerate: true
});
LS.annotationStore.selectAnnotation(c.id);
//
LS.annotationStore.events.on('addAnnotation', this.handleAddAnnotation);
LS.annotationStore.events.on('updateAnnotation', this.handleUpdateAnnotation);
//
this.startAnnotationCheck(LS);
//
const box = annotation.geometry;
}
});
},
//
handleAddAnnotation(annotation) {
console.log("新增标注框:", annotation);
},
//
handleUpdateAnnotation(annotation) {
console.log("更新标注框:", annotation);
},
//
startAnnotationCheck(LS) {
this.checkAnnotationsInterval = setInterval(() => {
this.checkAnnotations(LS);
}, 1000); //
},
//
stopAnnotationCheck() {
if (this.checkAnnotationsInterval) {
clearInterval(this.checkAnnotationsInterval);
}
},
//
checkAnnotations(LS) {
const currentAnnotations = LS.annotationStore.data; //
//
if (this.hasAnnotationsChanged(currentAnnotations)) {
console.log('标注数据发生变化:', currentAnnotations);
@ -131,20 +112,15 @@ export default {
//
hasAnnotationsChanged(currentAnnotations) {
//
if (currentAnnotations.length !== this.previousAnnotations.length) {
return true; //
}
// ID
//
for (let i = 0; i < currentAnnotations.length; i++) {
const current = currentAnnotations[i];
const previous = this.previousAnnotations[i];
if (current.id !== previous.id) {
return true; // ID
}
// true
if (JSON.stringify(current.geometry) !== JSON.stringify(previous.geometry)) {
return true;
@ -154,7 +130,7 @@ export default {
return false;
}
}
};
}
</script>
<style scoped>