You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.2 KiB

  1. import { AnnotationApplicationService } from '../annotationApplicationService'
  2. import { SegmentationDTO } from './segmentationData'
  3. import { Segment } from '@/domain/models/tasks/segmentation'
  4. export class SegmentationApplicationService extends AnnotationApplicationService<Segment> {
  5. public async list(projectId: string, exampleId: number): Promise<SegmentationDTO[]> {
  6. const items = await this.repository.list(projectId, exampleId)
  7. return items.map((item) => new SegmentationDTO(item))
  8. }
  9. public async create(
  10. projectId: string,
  11. exampleId: number,
  12. uuid: string,
  13. label: number,
  14. points: number[]
  15. ): Promise<void> {
  16. const item = new Segment(0, uuid, label, points)
  17. try {
  18. await this.repository.create(projectId, exampleId, item)
  19. } catch (e: any) {
  20. console.log(e.response.data.detail)
  21. }
  22. }
  23. public async update(
  24. projectId: string,
  25. exampleId: number,
  26. annotationId: number,
  27. item: SegmentationDTO
  28. ): Promise<void> {
  29. const bbox = new Segment(item.id, item.uuid, item.label, item.points)
  30. try {
  31. await this.repository.update(projectId, exampleId, annotationId, bbox)
  32. } catch (e: any) {
  33. console.log(e.response.data.detail)
  34. }
  35. }
  36. }