We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2f69d12 commit 66ad003Copy full SHA for 66ad003
1 file changed
edge_impulse_linux/image.py
@@ -1,13 +1,23 @@
1
#!/usr/bin/env python
2
3
import numpy as np
4
-import cv2
+opencv_installed = True
5
+
6
+try:
7
+ import cv2
8
+except ModuleNotFoundError as e: # can alternatively drop the boolean check for NameError exception when cv2 is called
9
+ opencv_installed = False
10
11
12
from edge_impulse_linux.runner import ImpulseRunner
13
import math
14
import psutil
15
16
class ImageImpulseRunner(ImpulseRunner):
17
def __init__(self, model_path: str):
18
+ if not opencv_installed: # can alternatively drop the boolean check for NameError exception when cv2 is called
19
+ raise Exception("OpenCV Not found. To use ImageImpulseRunner, ensure opencv-python>=4.5.1.48 is installed.")
20
21
super(ImageImpulseRunner, self).__init__(model_path)
22
self.closed = True
23
self.labels = []
0 commit comments