mirror of
https://github.com/azaion/ui.git
synced 2026-04-23 04:26:34 +00:00
fix annotation
This commit is contained in:
@@ -6,8 +6,8 @@ function AnnotationList({ annotations, onAnnotationClick }) {
|
|||||||
<h3 className='menu-title'>Annotations</h3>
|
<h3 className='menu-title'>Annotations</h3>
|
||||||
<ul className='annotation-list'>
|
<ul className='annotation-list'>
|
||||||
{annotations.map((annotation, index) => (
|
{annotations.map((annotation, index) => (
|
||||||
<li className='annotation-list-item' key={index} onClick={() => onAnnotationClick(annotation.time)}>
|
<li className='annotation-list-item' key={index} onClick={() => onAnnotationClick(index)}>
|
||||||
Frame {index + 1} - {annotation.annotations.length} objects
|
Frame {index + 1} - {annotation.detections.length} objects
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { detectionTypes } from '../../constants/detectionTypes';
|
|||||||
function AnnotationMain() {
|
function AnnotationMain() {
|
||||||
const [files, setFiles] = useState([]);
|
const [files, setFiles] = useState([]);
|
||||||
const [selectedFile, setSelectedFile] = useState(null);
|
const [selectedFile, setSelectedFile] = useState(null);
|
||||||
const [annotations, setAnnotations] = useState({});
|
const [annotations, setAnnotations] = useState([]);
|
||||||
const [currentTime, setCurrentTime] = useState(0);
|
const [currentTime, setCurrentTime] = useState(0);
|
||||||
const [selectedClass, setSelectedClass] = useState(null);
|
const [selectedClass, setSelectedClass] = useState(null);
|
||||||
const [detections, setDetections] = useState([]);
|
const [detections, setDetections] = useState([]);
|
||||||
@@ -36,7 +36,7 @@ function AnnotationMain() {
|
|||||||
if (!file) return;
|
if (!file) return;
|
||||||
|
|
||||||
setSelectedFile(file);
|
setSelectedFile(file);
|
||||||
setAnnotations({});
|
setAnnotations([]);
|
||||||
setDetections([]);
|
setDetections([]);
|
||||||
setSelectedDetectionIndices([]);
|
setSelectedDetectionIndices([]);
|
||||||
setCurrentTime(0);
|
setCurrentTime(0);
|
||||||
@@ -79,11 +79,12 @@ function AnnotationMain() {
|
|||||||
|
|
||||||
if (imageData) {
|
if (imageData) {
|
||||||
const newAnnotations = {
|
const newAnnotations = {
|
||||||
...annotations,
|
time: currentTime,
|
||||||
[currentTime]: { time: currentTime, annotations: detections, imageData }
|
detections: detections,
|
||||||
|
imageData: imageData
|
||||||
};
|
};
|
||||||
|
|
||||||
setAnnotations(newAnnotations);
|
setAnnotations(prevAnnotation => [...prevAnnotation, newAnnotations]);
|
||||||
|
|
||||||
saveAnnotation(currentTime, detections, imageData);
|
saveAnnotation(currentTime, detections, imageData);
|
||||||
setErrorMessage("");
|
setErrorMessage("");
|
||||||
@@ -106,15 +107,15 @@ function AnnotationMain() {
|
|||||||
setDetections([]);
|
setDetections([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleAnnotationClick = (time) => {
|
const handleAnnotationClick = (index) => {
|
||||||
setCurrentTime(time);
|
const annotation = annotations[index];
|
||||||
const annotation = annotations[time];
|
|
||||||
if (annotation) {
|
if (annotation) {
|
||||||
setDetections(annotation.annotations || []);
|
setCurrentTime(annotation.time);
|
||||||
|
setDetections(annotation.detections || []);
|
||||||
setSelectedDetectionIndices([]);
|
setSelectedDetectionIndices([]);
|
||||||
}
|
}
|
||||||
if (videoRef.current) {
|
if (videoRef.current) {
|
||||||
videoRef.current.currentTime = time;
|
videoRef.current.currentTime = annotation.time;
|
||||||
}
|
}
|
||||||
setIsPlaying(false);
|
setIsPlaying(false);
|
||||||
};
|
};
|
||||||
@@ -244,7 +245,7 @@ function AnnotationMain() {
|
|||||||
|
|
||||||
<div className='side-menu right-menu'>
|
<div className='side-menu right-menu'>
|
||||||
<AnnotationList
|
<AnnotationList
|
||||||
annotations={Object.values(annotations)}
|
annotations={annotations}
|
||||||
onAnnotationClick={handleAnnotationClick}
|
onAnnotationClick={handleAnnotationClick}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user