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

Performance Issue with custom annotator #25

Open
Cutuchiqueno opened this issue Apr 27, 2020 · 0 comments
Open

Performance Issue with custom annotator #25

Cutuchiqueno opened this issue Apr 27, 2020 · 0 comments

Comments

@Cutuchiqueno
Copy link

Cutuchiqueno commented Apr 27, 2020

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant