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

Opencv #7261

Merged
merged 4 commits into from May 3, 2017

Conversation

@Teagan42
Contributor

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

This comment has been minimized.

Show comment
Hide comment
@mention-bot

mention-bot Apr 24, 2017

@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.

mention-bot commented Apr 24, 2017

@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.

@pvizeli

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

Show outdated Hide outdated homeassistant/helpers/config_validation.py Outdated
add_devices(devices)
class OpenCVImageProcessor(ImageProcessingEntity):

This comment has been minimized.

@pvizeli

pvizeli Apr 24, 2017

Member

Please inheret from ImageProcessingFaceEntity

@pvizeli

pvizeli Apr 24, 2017

Member

Please inheret from ImageProcessingFaceEntity

This comment has been minimized.

@Teagan42

Teagan42 Apr 25, 2017

Contributor

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

@Teagan42

Teagan42 Apr 25, 2017

Contributor

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

This comment has been minimized.

@Teagan42

Teagan42 Apr 25, 2017

Contributor

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

@Teagan42

Teagan42 Apr 25, 2017

Contributor

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

This comment has been minimized.

@Teagan42

Teagan42 Apr 25, 2017

Contributor

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.

@Teagan42

Teagan42 Apr 25, 2017

Contributor

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.

This comment has been minimized.

@balloob

balloob May 3, 2017

Member

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.

@balloob

balloob May 3, 2017

Member

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

This comment has been minimized.

Show comment
Hide comment
@Teagan42

Teagan42 Apr 25, 2017

Contributor

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)...

Contributor

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 Teagan42 closed this Apr 25, 2017

@Teagan42 Teagan42 reopened this Apr 25, 2017

@Teagan42

This comment has been minimized.

Show comment
Hide comment
@Teagan42

Teagan42 Apr 26, 2017

Contributor

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

Contributor

Teagan42 commented Apr 26, 2017

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

@pvizeli

This comment has been minimized.

Show comment
Hide comment
@pvizeli

pvizeli Apr 29, 2017

Member

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

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

This comment has been minimized.

Show comment
Hide comment
@pvizeli

pvizeli Apr 29, 2017

Member

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.

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

This comment has been minimized.

Show comment
Hide comment
@balloob

balloob Apr 29, 2017

Member

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?

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

This comment has been minimized.

Show comment
Hide comment
@homeassistant

homeassistant May 2, 2017

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 commented May 2, 2017

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

This comment has been minimized.

Show comment
Hide comment
@homeassistant

homeassistant May 2, 2017

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 commented May 2, 2017

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! ❤️

@balloobbot balloobbot removed the core label May 2, 2017

@homeassistant

This comment has been minimized.

Show comment
Hide comment
@homeassistant

homeassistant May 2, 2017

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 commented May 2, 2017

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

This comment has been minimized.

Show comment
Hide comment
@Teagan42

Teagan42 May 2, 2017

Contributor

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)

Contributor

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)

Teagan42 and others added some commits May 2, 2017

Fix

@balloob balloob removed the cla-error label May 3, 2017

Concerns addressed

@balloob

This comment has been minimized.

Show comment
Hide comment
@balloob

balloob May 3, 2017

Member

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.

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

4 checks passed

cla-bot Everyone involved has signed the CLA
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.008%) to 93.466%
Details
hound No violations found. Woof!
@asyncio.coroutine
def async_setup(hass, config):

This comment has been minimized.

@pvizeli

pvizeli May 3, 2017

Member

Please use only setup. Or the fetch will lock all

@pvizeli

pvizeli May 3, 2017

Member

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:

This comment has been minimized.

@pvizeli

pvizeli May 3, 2017

Member

Kill our loop

@pvizeli

pvizeli May 3, 2017

Member

Kill our loop

This comment has been minimized.

@balloob

balloob May 3, 2017

Member

Oh you're right, I missed that.

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

@balloob

balloob May 3, 2017

Member

Oh you're right, I missed that.

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

This comment has been minimized.

@Teagan42

Teagan42 May 3, 2017

Contributor

will address today

@Teagan42

Teagan42 May 3, 2017

Contributor

will address today

This comment has been minimized.

@balloob

balloob May 3, 2017

Member

I already did #7419

@balloob

balloob May 3, 2017

Member

I already did #7419

@pvizeli

This comment has been minimized.

Show comment
Hide comment
@pvizeli

pvizeli May 3, 2017

Member

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

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

This comment has been minimized.

Show comment
Hide comment
@Teagan42

Teagan42 May 3, 2017

Contributor

@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

Contributor

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 referenced this pull request May 5, 2017

Merged

0.44 #7444

@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.