Skip to content

Opencv#7261

Merged
balloob merged 4 commits into
home-assistant:devfrom
Teagan42:opencv
May 3, 2017
Merged

Opencv#7261
balloob merged 4 commits into
home-assistant:devfrom
Teagan42:opencv

Conversation

@Teagan42
Copy link
Copy Markdown
Contributor

@Teagan42 Teagan42 commented Apr 24, 2017

Description:

Adds OpenCV classification processing component. Includes ability to add a camera to show where the detected matches are.

Related issue (if applicable): fixes #

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#2208

Example entry for configuration.yaml (if applicable):

opencv:
  classifier_groups:
    classifier:
      - color: (255, 0, 0)
        file_path: /path/to/classifier
        name: Wife Face
        min_size: (40, 40)
        neighbors: 4
        scale: 1.1
    entity_id: camera.front_door
    name: Front Door Faces
    add_camera: True

Checklist:

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable ([example][ex-requir]).
  • New dependencies are only imported inside functions that use them ([example][ex-import]).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

@mention-bot
Copy link
Copy Markdown

@Teagan42, thanks for your PR! By analyzing the history of the files in this pull request, we identified @balloob, @fabaff and @kellerza to be potential reviewers.

Copy link
Copy Markdown
Member

@pvizeli pvizeli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR is back :)

I think we have say that the camera component should be remove or handle as custom component and not inside core. @balloob

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That exists already inside vol

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will check

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please inheret from ImageProcessingFaceEntity

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it's not necessarily a Face - just the default classifier is

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entity could be anything - if you had a car classifier, it would be a car, not a face, if it was a tree classifier, it's a tree

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are classifiers that people can use (without even getting into making their own):
https://github.com/opencv/opencv/tree/master/data/haarcascades
https://github.com/opencv/opencv/tree/master/data/lbpcascades

Examples include:
Cat, Cat Face, Silverware, Upper Body, Lower Body, Full Body, License Plates

I do not agree with making this a ImageProcessingFaceEntity as that would be misleading to what it can process.

Copy link
Copy Markdown
Member

@balloob balloob May 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the Face entity could actually be easily changed to be a generic Thing detector with a confidence level etc. In fact, that is pretty much what @Teagan42 has here. I think it's fine as is. The important part here is that the base entity from the component is filled in.

@Teagan42
Copy link
Copy Markdown
Contributor Author

Teagan42 commented Apr 25, 2017

What's wrong with the camera component? User has the ability to add or not add the camera if they want, it's not dispatched, it does it's own processing separate from the image_processing component (decoupled)...

@Teagan42
Copy link
Copy Markdown
Contributor Author

What the hell is up with those two unit tests? I rebased with dev and they still fail.

@pvizeli
Copy link
Copy Markdown
Member

pvizeli commented Apr 29, 2017

I think you need make a new branch and copy your work into that. Look like that your branch is broken

@pvizeli
Copy link
Copy Markdown
Member

pvizeli commented Apr 29, 2017

By the way. All image_processing can output picture like that you have made with camera things. I think HomeAssistant should not make that playing stuff inside a official platform. That will be a nice gist or custom platform.

A image_process platform should only make a event for we can do some things with automation. Real processing and pipe things should be done in other library or projects and we are only the endpoint for that.

@balloob
Copy link
Copy Markdown
Member

balloob commented Apr 29, 2017

I don't think that the branch is broken @pvizeli, all tests are passing.

Pascal is right, there is a lot of different platforms and component changes in your PR. Can you fix that?

@homeassistant
Copy link
Copy Markdown
Contributor

Hello @Teagan42,

When attempting to inspect the commits of your pull request for CLA signature status among all authors we encountered commit(s) which were not linked to a GitHub account, thus not allowing us to determine their status(es).

The commits that are missing a linked GitHub account are the following:

Unfortunately, we are unable to accept this pull request until this situation is corrected.

Here are your options:

  1. If you had an email address set for the commit that simply wasn't linked to your GitHub account you can link that email now and it will retroactively apply to your commits. The simplest way to do this is to click the link to one of the above commits and look for a blue question mark in a blue circle in the top left. Hovering over that bubble will show you what email address you used. Clicking on that button will take you to your email address settings on GitHub. Just add the email address on that page and you're all set. GitHub has more information about this option in their help center.

  2. If you didn't use an email address at all, it was an invalid email, or it's one you can't link to your GitHub, you will need to change the authorship information of the commit and your global Git settings so this doesn't happen again going forward. GitHub provides some great instructions on how to change your authorship information in their help center.

    • If you only made a single commit you should be able to run
      git commit --amend --author="Author Name <email@address.com>"
      
      (substituting Author Name and email@address.com for your actual information) to set the authorship information.
    • If you made more than one commit and the commit with the missing authorship information is not the most recent one you have two options:
      1. You can re-create all commits missing authorship information. This is going to be the easiest solution for developers that aren't extremely confident in their Git and command line skills.
      2. You can use this script that GitHub provides to rewrite history. Please note: this should be used only if you are very confident in your abilities and understand its impacts.
    • Whichever method you choose, I will come by to re-check the pull request once you push the fixes to this branch.

We apologize for this inconvenience, especially since it usually bites new contributors to Home Assistant. We hope you understand the need for us to protect ourselves and the great community we all have built legally. The best thing to come out of this is that you only need to fix this once and it benefits the entire Home Assistant and GitHub community.

Thanks, I look forward to checking this PR again soon! ❤️

@homeassistant
Copy link
Copy Markdown
Contributor

Hello @Teagan42,

When attempting to inspect the commits of your pull request for CLA signature status among all authors we encountered commit(s) which were not linked to a GitHub account, thus not allowing us to determine their status(es).

The commits that are missing a linked GitHub account are the following:

Unfortunately, we are unable to accept this pull request until this situation is corrected.

Here are your options:

  1. If you had an email address set for the commit that simply wasn't linked to your GitHub account you can link that email now and it will retroactively apply to your commits. The simplest way to do this is to click the link to one of the above commits and look for a blue question mark in a blue circle in the top left. Hovering over that bubble will show you what email address you used. Clicking on that button will take you to your email address settings on GitHub. Just add the email address on that page and you're all set. GitHub has more information about this option in their help center.

  2. If you didn't use an email address at all, it was an invalid email, or it's one you can't link to your GitHub, you will need to change the authorship information of the commit and your global Git settings so this doesn't happen again going forward. GitHub provides some great instructions on how to change your authorship information in their help center.

    • If you only made a single commit you should be able to run
      git commit --amend --author="Author Name <email@address.com>"
      
      (substituting Author Name and email@address.com for your actual information) to set the authorship information.
    • If you made more than one commit and the commit with the missing authorship information is not the most recent one you have two options:
      1. You can re-create all commits missing authorship information. This is going to be the easiest solution for developers that aren't extremely confident in their Git and command line skills.
      2. You can use this script that GitHub provides to rewrite history. Please note: this should be used only if you are very confident in your abilities and understand its impacts.
    • Whichever method you choose, I will come by to re-check the pull request once you push the fixes to this branch.

We apologize for this inconvenience, especially since it usually bites new contributors to Home Assistant. We hope you understand the need for us to protect ourselves and the great community we all have built legally. The best thing to come out of this is that you only need to fix this once and it benefits the entire Home Assistant and GitHub community.

Thanks, I look forward to checking this PR again soon! ❤️

@homeassistant
Copy link
Copy Markdown
Contributor

Hello @Teagan42,

When attempting to inspect the commits of your pull request for CLA signature status among all authors we encountered commit(s) which were not linked to a GitHub account, thus not allowing us to determine their status(es).

The commits that are missing a linked GitHub account are the following:

Unfortunately, we are unable to accept this pull request until this situation is corrected.

Here are your options:

  1. If you had an email address set for the commit that simply wasn't linked to your GitHub account you can link that email now and it will retroactively apply to your commits. The simplest way to do this is to click the link to one of the above commits and look for a blue question mark in a blue circle in the top left. Hovering over that bubble will show you what email address you used. Clicking on that button will take you to your email address settings on GitHub. Just add the email address on that page and you're all set. GitHub has more information about this option in their help center.

  2. If you didn't use an email address at all, it was an invalid email, or it's one you can't link to your GitHub, you will need to change the authorship information of the commit and your global Git settings so this doesn't happen again going forward. GitHub provides some great instructions on how to change your authorship information in their help center.

    • If you only made a single commit you should be able to run
      git commit --amend --author="Author Name <email@address.com>"
      
      (substituting Author Name and email@address.com for your actual information) to set the authorship information.
    • If you made more than one commit and the commit with the missing authorship information is not the most recent one you have two options:
      1. You can re-create all commits missing authorship information. This is going to be the easiest solution for developers that aren't extremely confident in their Git and command line skills.
      2. You can use this script that GitHub provides to rewrite history. Please note: this should be used only if you are very confident in your abilities and understand its impacts.
    • Whichever method you choose, I will come by to re-check the pull request once you push the fixes to this branch.

We apologize for this inconvenience, especially since it usually bites new contributors to Home Assistant. We hope you understand the need for us to protect ourselves and the great community we all have built legally. The best thing to come out of this is that you only need to fix this once and it benefits the entire Home Assistant and GitHub community.

Thanks, I look forward to checking this PR again soon! ❤️

@Teagan42
Copy link
Copy Markdown
Contributor Author

Teagan42 commented May 2, 2017

I should have looked at the files changed - that's what I get for coding high late at night. I removed the camera but left the configuration option and will add a gist for the camera component (will link on the doc PR) so it's nice and easily loaded. Unless I need to get rid of the camera configuration option (which should just fail gracefully if you don't have the cutom_component)

@balloob balloob removed the cla-error label May 3, 2017
@balloob balloob dismissed pvizeli’s stale review May 3, 2017 04:31

Concerns addressed

@balloob
Copy link
Copy Markdown
Member

balloob commented May 3, 2017

I just removed the last pieces for the camera discovery, since it's not part of this PR. Will merge it once tests pass 🐬 🎉 Thanks @Teagan42 !

I think that it's fine to have a camera feed, as long as the camera feed implements OpenCV directly.

@balloob balloob merged commit b321e0e into home-assistant:dev May 3, 2017


@asyncio.coroutine
def async_setup(hass, config):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use only setup. Or the fetch will lock all

http = urllib3.PoolManager()
request = http.request('GET', CASCADE_URL, preload_content=False)

with open(DEFAULT_CLASSIFIER_PATH, 'wb') as out:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kill our loop

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh you're right, I missed that.

@Teagan42 we should not do any I/O inside an asynchronous context without yielding. See Async 101

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will address today

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already did #7419

@pvizeli
Copy link
Copy Markdown
Member

pvizeli commented May 3, 2017

Can you convert the output of openvc to a usable output with fore events like all other platform does?

@Teagan42
Copy link
Copy Markdown
Contributor Author

Teagan42 commented May 3, 2017

@pvizeli What would you suggest? It returns something like:

CLASSIFIER_NAME: {
  (REGION),
  (REGION)
},
CLASSIFIER_NAME: {
  (REGION),
  (REGION)
}

So, if you have a classifier group, that has "Teagan Face", "Grace Face", "Dog", you can determine which ones were matched and where

@balloob balloob mentioned this pull request May 5, 2017
@home-assistant home-assistant locked and limited conversation to collaborators Aug 12, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants