File tree 3 files changed +16
-5
lines changed
3 files changed +16
-5
lines changed Original file line number Diff line number Diff line change 10
10
11
11
from typing import Literal
12
12
13
- import cv2
14
13
import numpy as np
15
14
import scipy .ndimage as spi
16
15
import scipy .spatial as spt
@@ -720,6 +719,14 @@ def find_blobs_opencv(
720
719
Returns:
721
720
Coordinates of blobs
722
721
"""
722
+
723
+ # Note:
724
+ # Importing OpenCV inside the function in order to eventually raise an ImportError
725
+ # when the function is called and OpenCV is not installed. This error will be
726
+ # handled by DataLab and the user will be informed that OpenCV is required to use
727
+ # this function.
728
+ import cv2 # pylint: disable=import-outside-toplevel
729
+
723
730
params = cv2 .SimpleBlobDetector_Params ()
724
731
if min_threshold is not None :
725
732
params .minThreshold = min_threshold
Original file line number Diff line number Diff line change 10
10
11
11
import os
12
12
13
- import cv2
14
13
import guidata
15
14
import h5py
16
15
import numpy
@@ -47,9 +46,14 @@ def pytest_report_header(config): # pylint: disable=unused-argument
47
46
f"PythonQwt { qwt .__version__ } , "
48
47
f"{ qtpy .API_NAME } { qtbindings_version } [Qt version: { qtpy .QT_VERSION } ]" ,
49
48
f"NumPy { numpy .__version__ } , SciPy { scipy .__version__ } , "
50
- f"h5py { h5py .__version__ } , "
51
- f"scikit-image { skimage .__version__ } , OpenCV { cv2 .__version__ } " ,
49
+ f"h5py { h5py .__version__ } , scikit-image { skimage .__version__ } " ,
52
50
]
51
+ try :
52
+ import cv2 # pylint: disable=import-outside-toplevel
53
+
54
+ infolist .append (f", OpenCV { cv2 .__version__ } " )
55
+ except ImportError :
56
+ pass
53
57
for vname in ("CDL_DATA" , "PYTHONPATH" , "DEBUG" ):
54
58
value = os .environ .get (vname , "" )
55
59
if value :
Original file line number Diff line number Diff line change @@ -44,7 +44,6 @@ dependencies = [
44
44
" NumPy >= 1.21" ,
45
45
" SciPy >= 1.7" ,
46
46
" scikit-image >= 0.18" ,
47
- " opencv-python-headless >= 4.5" ,
48
47
" pandas >= 1.3" ,
49
48
" PyWavelets >= 1.1" ,
50
49
" psutil >= 5.5" ,
@@ -65,6 +64,7 @@ cdl-tests = "cdl.tests:run"
65
64
66
65
[project .optional-dependencies ]
67
66
qt = [" PyQt5" ]
67
+ opencv = [" opencv-python-headless >= 4.5" ]
68
68
dev = [" ruff" , " pylint" , " Coverage" , " pyinstaller>=6.0" ]
69
69
doc = [
70
70
" PyQt5" ,
You can’t perform that action at this time.
0 commit comments