pageauc / speed-camera

A Unix, Windows, Raspberry Pi Object Speed Camera using python, opencv, video streaming, motion tracking. Includes a Standalone Web Server Interface, Image Search using opencv template match and a whiptail Admin Menu Interface Includes picam and webcam Plugins for motion track security camera configuration including rclone sync script. watch-app allows remotely controller camera configuration from a remote storage service name. Uses sqlite3 and gnuplot for reporting. Recently added openalpr license plate reader support.
Apache License 2.0
987 stars 173 forks source link

Reduce file size of saved jpeg #75

Closed RandallKent closed 3 years ago

RandallKent commented 3 years ago

Allow users to reduce the file size of saved jpeg, by exposing ImwriteFlags in the config to enable togging jpeg optimization and adjusting the quality of the jpeg.

RandallKent commented 3 years ago

@pageauc I see you merged #76 and but also updated the speed-cam.py#1355 to have logic that requires image_jpeg_optimize to be set to True in order for the image_jpeg_quality variable to take effect.

Your logic is incorrect.

Each flag is independent: optimization is different from compression (quality). Each can and should be able to be to configured separately.

The real file size savings comes from image_jpeg_quality therefore, a user should be able to set the quality of an image without setting image_jpeg_optimize to True.

pageauc commented 3 years ago

Yes after looking more closely at the docs I see that optionize parameter can be toggled on or off. I just want to be able to toggle the feature on or off so maybe another boolean to enable or disable the quality/optimization ver of imwrite.

How about image_jpg_custom_on = False # Allow custom jpg settings for quality and image optimization.

This would allow customization of quality or optimization.

On Sun, Mar 7, 2021 at 11:50 AM Randall Kent notifications@github.com wrote:

@pageauc https://github.com/pageauc I see you merged #76 https://github.com/pageauc/speed-camera/pull/76 and but also updated the speed-cam.py#1355 https://github.com/pageauc/speed-camera/blob/master/speed-cam.py#L1355 to have logic that requires image_jpeg_optimize to be set to True in order for the image_jpeg_quality variable to take effect.

Your logic is incorrect.

Each flag is independent: optimization is different from compression (quality). Each can and should be able to be to configured separately.

The real file size savings comes from image_jpeg_quality therefore, a user should be able to set the quality of an image without setting image_jpeg_optimize to True.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pageauc/speed-camera/issues/75#issuecomment-792309736, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNPKZERHYHAHW3ZZSZLCFLTCOVE7ANCNFSM4YWY33CA .

-- YouTube Channel at https://www.youtube.com/user/pageaucp http://www.youtube.com/user/pageaucp GitHub Repository at https://github.com/pageauc

RandallKent commented 3 years ago

By setting the defaults within the speed-camera to match the defaults of OpenCV, we are effectively providing your desired functionality.

In other words, the feature is not toggled on unless it is changed from the default value. If the user leaves the default value, it's as if the feature is "disabled".

pageauc commented 3 years ago

Ok. Thanks for your help. I have reverted change to your previous logic and added comments certainly your solution is simpler and fewer config.py variables.

I learned something today. I have enjoyed working with you and your patience while I got up to speed.

Regards Claude ...

On Sun, Mar 7, 2021 at 12:08 PM Randall Kent notifications@github.com wrote:

By setting the defaults within the speed-camera to match the defaults of OpenCV https://docs.opencv.org/3.4/d8/d6a/group__imgcodecs__flags.html#ga292d81be8d76901bff7988d18d2b42ac, we are effectively providing your desired functionality.

In other words, the feature is not toggled on unless it is changed from the default value. If the user leaves the default value, it's as if the feature is "disabled".

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pageauc/speed-camera/issues/75#issuecomment-792312358, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNPKZF3AUYX5FNWYCKSUNTTCOXJ3ANCNFSM4YWY33CA .

-- YouTube Channel at https://www.youtube.com/user/pageaucp http://www.youtube.com/user/pageaucp GitHub Repository at https://github.com/pageauc

pageauc commented 3 years ago

Testing image optimize feature and image quality to my eye appears to be sharper. Today was sunny. Images were quite clear with no noticeable blur. Will do more testing especially during overcast periods which is quite often at this time of year in Ontario Canada Regards Claude ...

On Sun, Mar 7, 2021 at 12:33 PM Claude Pageau pageauc@gmail.com wrote:

Ok. Thanks for your help. I have reverted change to your previous logic and added comments certainly your solution is simpler and fewer config.py variables.

I learned something today. I have enjoyed working with you and your patience while I got up to speed.

Regards Claude ...

On Sun, Mar 7, 2021 at 12:08 PM Randall Kent notifications@github.com wrote:

By setting the defaults within the speed-camera to match the defaults of OpenCV https://docs.opencv.org/3.4/d8/d6a/group__imgcodecs__flags.html#ga292d81be8d76901bff7988d18d2b42ac, we are effectively providing your desired functionality.

In other words, the feature is not toggled on unless it is changed from the default value. If the user leaves the default value, it's as if the feature is "disabled".

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pageauc/speed-camera/issues/75#issuecomment-792312358, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNPKZF3AUYX5FNWYCKSUNTTCOXJ3ANCNFSM4YWY33CA .

-- YouTube Channel at https://www.youtube.com/user/pageaucp http://www.youtube.com/user/pageaucp GitHub Repository at https://github.com/pageauc

-- YouTube Channel at https://www.youtube.com/user/pageaucp http://www.youtube.com/user/pageaucp GitHub Repository at https://github.com/pageauc