core icon indicating copy to clipboard operation
core copied to clipboard

Expose annotation option for camera snapshot

Open eddiewebb opened this issue 3 years ago • 5 comments

Proposed change

Adds an annotation attribute to camera.snapshot service's acceptable data, enabling text annotation to snapshot images.

The change modifies snapshot service to manipulate image with PIL after saving initial bytes.

Type of change

  • [ ] Dependency upgrade
  • [ ] Bugfix (non-breaking change which fixes an issue)
  • [ ] New integration (thank you!)
  • [x] New feature (which adds functionality to an existing integration)
  • [ ] Deprecation (breaking change to happen in the future)
  • [ ] Breaking change (fix/feature causing existing functionality to break)
  • [ ] Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request: https://github.com/home-assistant/home-assistant.io/pull/24588

Checklist

  • [x] The code change is tested and works locally.
  • [x] Local tests pass. Your PR cannot be merged unless tests pass
  • [x] There is no commented out code in this PR.
  • [x] I have followed the development checklist
  • [x] The code has been formatted using Black (black --fast homeassistant tests)
  • [ ] Tests have been added to verify that the new code works.

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

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

  • [x] The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • [x] New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • [ ] For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • [x] Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

  • [ ] I have reviewed two other open pull requests in this repository.
  • [x] https://github.com/home-assistant/core/pull/79689#pullrequestreview-1143306224

eddiewebb avatar Oct 16 '22 15:10 eddiewebb

Hi eddiewebb

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

home-assistant[bot] avatar Oct 16 '22 15:10 home-assistant[bot]

Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (camera) you are listed as a code owner for? Thanks!

home-assistant[bot] avatar Oct 16 '22 15:10 home-assistant[bot]

(I would note I originally planned to do this as my own add-on to just listen and augment images but does not seem this emits events to listen to)

eddiewebb avatar Oct 16 '22 15:10 eddiewebb

(I would note I originally planned to do this as my own add-on to just listen and augment images but does not seem this emits events to listen to)

My best suggestion for this would be an integration that exposes a service call that reads an input file from local disk and writes out another file on local disk. That service can be invoked after the snapshot call succeeds.

allenporter avatar Oct 25 '22 03:10 allenporter

@allenporter I wonder if it is possible for an 2nd integration to directly overlay some text on the still image of a first integration.

So you'd have what looks like a second camera entity, but really it's just displaying a modified version of the image from the first one.

The concern I have with modifying a file on disc is that you need to synchronise the file read/writes somehow.

davet2001 avatar Oct 27 '22 16:10 davet2001

Yeah i feel like maybe the webrtc custom component was wrapping or delegating to an existing camera like that...

allenporter avatar Oct 28 '22 02:10 allenporter

The high level point I like about your suggestion is thinking about a way to compose things together to get this functionality rather than baking into the core camera integration.

allenporter avatar Oct 28 '22 02:10 allenporter