Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redesign DB layout for shapes #313

Closed
nmanovic opened this issue Feb 6, 2019 · 0 comments · Fixed by #389
Closed

Redesign DB layout for shapes #313

nmanovic opened this issue Feb 6, 2019 · 0 comments · Fixed by #389
Assignees
Labels
enhancement New feature or request

Comments

@nmanovic
Copy link
Contributor

nmanovic commented Feb 6, 2019

Need to improve layout of our database. Better to have only one Shape class instead of BoundingBox, Polygon, Polyline, Points. Probably it will simplify our code.

class ShapeType(str, Enum):
    RECTANGLE = 'rectangle'
    POLYGON = 'polygon'
    POLYLINE = 'polyline'
    POINTS = 'points'

    @classmethod
    def choices(self):
        return tuple((x.name, x.value) for x in self)

class Annotation(models.Model):
    job   = models.ForeignKey(Job, on_delete=models.CASCADE)
    label = models.ForeignKey(Label, on_delete=models.CASCADE)
    frame = models.PositiveIntegerField()
    group_id = models.PositiveIntegerField(default=0)
    client_id = models.BigIntegerField(default=-1)

    class Meta:
        abstract = True

class Shape(models.Model):
    id = models.BigAutoField(primary_key=True)
    type = models.CharField(max_length=16, choices=ShapeType.choices())
    occluded = models.BooleanField(default=False)
    z_order = models.IntegerField(default=0)
    points = models.TextField()

    class Meta:
        default_permissions = ()

class LabeledImage(Annotation):
    pass

class LabeledImageAttributeVal(AttributeVal):
    image = models.ForeignKey(LabeledImage, on_delete=models.CASCADE)

class LabeledShape(Annotation, Shape):
    pass

class LabeledShapeAttributeVal(AttributeVal):
    shape = models.ForeignKey(LabeledShape, on_delete=models.CASCADE)

class ObjectTrack(Annotation):
    id = models.BigAutoField(primary_key=True)

class ObjectPathAttributeVal(AttributeVal):
    track = models.ForeignKey(ObjectTrack, on_delete=models.CASCADE)

class TrackedShape(Shape):
    track = models.ForeignKey(ObjectTrack, on_delete=models.CASCADE)
    frame = models.PositiveIntegerField()
    outside = models.BooleanField(default=False)

    class Meta:
        default_permissions = ()

class TrackedShapeAttributeVal(AttributeVal):
    shape = models.ForeignKey(TrackedShape, on_delete=models.CASCADE)
@nmanovic nmanovic added the enhancement New feature or request label Feb 6, 2019
@nmanovic nmanovic added this to the Backlog milestone Feb 6, 2019
@nmanovic nmanovic self-assigned this Feb 6, 2019
@nmanovic nmanovic mentioned this issue Apr 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant