Skip to content
This repository was archived by the owner on Mar 19, 2023. It is now read-only.

Add image scale option #201

Merged
merged 3 commits into from
Jan 22, 2021
Merged

Add image scale option #201

merged 3 commits into from
Jan 22, 2021

Conversation

jodur
Copy link
Contributor

@jodur jodur commented Jan 17, 2021

With this change it is possible to scale the received image from a camera entity with a factor (ratio is preserved)

Note: Scale is done before transmitting to deepstack.

Advantages:

  • Smaller snapshot file
  • Faster processing by deepstack

It is now possible to scale the image with a factor (ratio is preserved) that is received from the camera entity.
Advantages:
- Smaller snapshot file
- Faster processing by deepstack
@robmarkcole
Copy link
Owner

@jodur have you tried https://www.home-assistant.io/integrations/proxy/ ? This allows downsizing images

Deepstack resizes the images before processing them. This integration saves the full sized image with annotations

@jodur
Copy link
Contributor Author

jodur commented Jan 18, 2021

Yes I am aware of the proxy component. It is a overkill and a loss of unnecessary resources to use the proxy camera, just for rescaling a single snapshot. Every frame from the original cam will be rescaled when the stream from the proxy is accessed. Also an extra delay will be introduced with the proxy for the image processing in relation to realtime motion signals.
The scale property is optional in this case and the extra code for scaling is only processed when a scaling factor different then 1.0 is used. The annotations will also work on the scaled images, so the user “sees”no difference.

@robmarkcole
Copy link
Owner

@jodur RE faster processing did you perform a benchmark measurement to estimate the speed improvement? What % improvement is it?

RE PR can you add the new arg to the README and also perform black formatting, thanks

@robmarkcole robmarkcole self-requested a review January 20, 2021 05:07
self._image_width, self._image_height = Image.open(
io.BytesIO(bytearray(image))
).size
_LOGGER.debug((f"Open image"))
Copy link
Owner

Choose a reason for hiding this comment

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

"Open image" - can you add to this?


#resize image if different then default
if self._scale!=DEAULT_SCALE:
try:
Copy link
Owner

Choose a reason for hiding this comment

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

How often does this fail?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right this was a left for catching wrong scale factors given by the user. Later on i added min and max validation for the scale factor, so this wouldn't be nessecary anymore. I will remove the exception handeling

@jodur jodur closed this Jan 20, 2021
@jodur
Copy link
Contributor Author

jodur commented Jan 20, 2021

I changed the PR with your remarks:

  • deleted exception handeling for rescaling
  • code formatting using black
  • updated the readme

@jodur jodur reopened this Jan 20, 2021
@robmarkcole
Copy link
Owner

LGTM, nice work

@robmarkcole robmarkcole merged commit df9765f into robmarkcole:master Jan 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants