Skip to content

Performance Issue with custom annotator #25

@Cutuchiqueno

Description

@Cutuchiqueno

Basically because HSV is not derived from a color awareness model like CIE-Lab is but in comparison to CIE-Lab defines more meaningful axis I wanted to build a custom annotator that turns the input RGB (it is RGB, right? Not openCVs BGR?) into CIE-LCH (Luminance, Chroma, Hue), a color awareness appropriate version of HSV. (Instead of a histogramm I calculate the median value for each channel, but that is not important here). openCV, unfortunately, does not provide a conversion to CIE-LCH, but scikit-image does. In principle everything works out, BUT for a 110 minute movie such as Il Divo with this custom annotator dvt requires 7h30m!!! Considering, that the demo project, on my computer, requires just 30-45 minutes to annotate everything it can (the color annotator and the dominant colors annotator included), I wondered if I got something completely wrong.

My annotator looks like this:

class LchAnnotator(FrameAnnotator):

    name = 'lch'

    def annotate(self, batch):

        img = batch.get_batch()
        fnames = batch.get_frame_names()

        luminance = list()
        chroma = list()
        hue = list()

        for i in img:

            img_lab = rgb2lab(i)
            img_lch = lab2lch(img_lab)

            lch = img_lch.reshape(-1, 3)

            luminance.append(median(lch[:, 0]))
            chroma.append(median(lch[:, 1]))
            hue.append(median(lch[:, 2]))

        output = {'frame': fnames,
                  'luminance': luminance,
                  'chroma': chroma,
                  'hue': hue}

        return output

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions