Open m-roberts opened 1 year ago
Turns out OpenCV adds an extra 171 packages accounting for ~300MB of the install size: https://pastebin.com/3czP6DWc
Yes, the requirement to install 3 different image processing frameworks for the ability to power off the device is kind of lame.
I suspect this is due to bad design of the python libraries. Why do you need to import ImageFunctions.convert?
Can't the conversion function be a method on each image object? Then you would call the method of whichever library provided the image, transparently.
@jcapona @olivierwilkinson @angusjfw - any chance of someone taking a look at this? 🤔
Problem or Possibility
Currently OpenCV is installed with the core of the SDK, but it appears to only be used by
ImageFunctions.convert
Removing this dependency from the core would help to reduce install footprint for core functionality.It is used in
pitop.processing
andpitop.camera
, but - most importantly - it does the heavy lifting of the miniscreen'sdisplay_image
function.Proposed Solution
An OpenCV image is unlikely to be passed in without the
cv2
dependency being installed, so it shouldn't even be necessary to invoke theconvert
function anyway.Perhaps the
display_image
function could try to convert if the image format is PIL and raises an exception if it's an OpenCV image without the dependency installed?Alternative Solutions
According to this, this operation should also work:
However, this does not have OpenCV's speed benefit. Perhaps this can be used as a fallback option if OpenCV is not available?
Additional Context