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
960 stars 169 forks source link

image_jpeg_optimize = True #139

Closed carterw closed 11 months ago

carterw commented 11 months ago

I was looking at the image storage code and noticed that the cv2.imwrite() section around line 1576 in speed-cam.py is always throwing an exception. It is caught and the image write always happens with no optimizations. The code looks like this;

cv2.imwrite( filename, big_image, [ int(cv2.IMWRITE_JPEG_QUALITY), image_jpeg_quality, int(cv2.IMWRITE_JPEG_OPTIMIZE), image_jpeg_optimize, ]

The problem appears to be that cv2.IMWRITE_JPEG_OPTIMIZE wants to see a 0 or 1 argument, and what is being passed in through _image_jpegoptimize is the value True. Setting it to 1 results in success.

pageauc commented 11 months ago

Pushed ver 12.06 that looks like it fixed issue. Honestly I could not see image improvement. My default config is normally set to Not optimized and run machines headless and speed-cam.py in background. Originally put image_jpeg_optimize as imwrite parameter since True and 1 are normally the same. I did not see exception during original testing quit a few years ago so maybe openCV changed behavior, Anyway you are the first to point this out. Thanks for your issue. Let me know if new version works OK for you. Regards Claude.

carterw commented 11 months ago

I don't know if image_jpeg_optimize helps either, I just happened to be stepping through that section of code and noticed the exception.