Giter Site home page Giter Site logo

cvat_reader's Introduction

cvat_reader

Package to read cvat training set zip file into numpy array image and annotations.

The cvat format is usefull because it contains the original video file. The original video file has two main advantage over image files:

  1. The original video file is much better compressed than a bunch of image files.
  2. The image files are re-compressed versions of the video file and therefore lower in quality

Install

pip install cvat_reader

Example

import cv2

from cvat_reader import open_cvat


with open_cvat("training.zip") as dataset:
    print(dataset.labels)

    labels = {}
    for label in dataset.labels:
        h = label['color'].lstrip('#')
        labels[label['name']] = tuple(int(h[i:i + 2], 16) for i in (0, 2, 4))

    for frame in dataset:
        if frame.annotations:
            img = frame.image.copy()

            for label in dataset.labels:
                for annotation in frame.annotations:
                    color = labels[annotation.label]

                    (x1, y1), (x2, y2) = annotation.bounding_box
                    cv2.rectangle(img, (x1, y1), (x2, y2), color)

            cv2.imshow('image', img)
            cv2.waitKey(0)

By default the video is loaded and all image data is put in the frame.image attribute. When you are only interested in the data, or have an other way to process the video you can pass load_video=False to open_cvat and the images are not loaded. When you pass load_video=False this library does not depend on cv2 or numpy.

from cvat_reader import open_cvat

def process_annotations(frame_id, annotations):
    ...

with open_cvat("training.zip", load_video=False) as dataset:
    print(dataset.labels)

    for frame in dataset:
        """
        >>> frame.image
        None
        """
        if frame.annotations:
            process_annotations(frame.frame_id, frame.annotations)
            

Support

cvat_reader currently supports the following types of annotations:

  • BoundingBox

Media types supported: all types cv2 supports

Changelog

0.3.1 (2021-12-03)

Bugfix:

  • Fix typing

0.3.0 (2021-12-03)

Feature:

  • Add occluded, outside and attributes to Annotation. When Annotation is interpolated the occluded, outside and attributes fields are copied from the first non-interpolated annotation.

0.2.1 (2021-11-04)

Bugfix:

  • Include last frame
  • Include video_file in Dataset

0.2.0 (2021-11-04)

Feature:

  • Add load_video flag to open_cvat to specify if video should be loaded too. This removes the dependecy on cv2/numpy when you don't need the video, or use another tool for processing.

0.1.2 (2021-10-26)

Bugfix:

  • Stop iteration when last frame is reached

0.1.1 (2021-10-25)

Bugfix:

  • data directory sometimes contains non-video files. Those files should not be picked as video files. This bugfix solves this by verifying if cv2 can load the file.

0.1.0 (2021-10-22)

Feature:

  • Properly read tracks and interpolate

cvat_reader's People

Contributors

j-wilhelm avatar koenvo avatar koenvossen avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

cvat_reader's Issues

Dependencies are not installed automatically

Not sure if this issue pertains to the repository itself, but when installing the package on a Linux server, the dependencies are not automatically installed.

pip install cvat_reader
System info: Linux

Automatic creation of images_directory

When running load_cvat_task with an images directory that does not yet exist, the images directory is not created but just gives an error. Automatic folder creation would be a nice feature

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.