Removed numpy and PIL top-level imports that could break the HTTP server if not installed on the system

This commit is contained in:
Fabio Manganiello 2020-03-24 10:25:25 +01:00
parent 4ece49bfe7
commit 7ce5efaf2e

View file

@ -5,9 +5,6 @@ import threading
import time import time
from typing import Optional, List from typing import Optional, List
import numpy as np
from PIL import Image
from platypush import Config from platypush import Config
from platypush.context import get_bus from platypush.context import get_bus
from platypush.message.event.qrcode import QrcodeScannedEvent from platypush.message.event.qrcode import QrcodeScannedEvent
@ -105,7 +102,8 @@ class QrcodePlugin(Plugin):
results = pyzbar.decode(img) results = pyzbar.decode(img)
return QrcodeDecodedResponse(results) return QrcodeDecodedResponse(results)
def _convert_frame(self, frame) -> Image: def _convert_frame(self, frame):
import numpy as np
assert isinstance(frame, np.ndarray), \ assert isinstance(frame, np.ndarray), \
'Image conversion only works with numpy arrays for now (got {})'.format(type(frame)) 'Image conversion only works with numpy arrays for now (got {})'.format(type(frame))
mode = 'RGB' mode = 'RGB'