-
Notifications
You must be signed in to change notification settings - Fork 0
Description
There is sometimes a mismatch between libraries used by different OpenCV versions on your computer.
For instance I originally had 4.1.0 and the following code for loading image works fine:
import cv2
print(cv2.__version__)
a = cv2.imread('./assets/simple_blobs/bloby_478.png')
print(type(a))
4.1.0
numpy.ndarray
However, when I created a new virtual environment with conda-forge::opencv=4.1.2 the png image won't load. The same code produces
4.1.2
NoneType
Without raising any errors.
However when running the same code in REPL we can see the warning that explains everything:
libpng warning: Application built with libpng-1.4.12 but running with 1.6.37
Different versions of opencv are built with different versions of png libraries but they are somehow forced to use the same version, or are outright broken.
That causes first cell in Task B to fail with the following error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-1-147208002c1c> in <module>
16 image_size = 64 # in pixels
17 number_of_classes = 2 #2-6 - normal blobs. 7-11 more difficult
---> 18 problem = generateBlobsData(imageDir, number_of_classes, number_of_samples, image_size, noiseSize=20)
~/repos/learnmachine/tasks/utils/practice_data.py in generateBlobsData(imageDir, noClasses, trainSamples, imSize, noiseSize, colour)
106 #add noise
107 if noiseSize>0:
--> 108 row,col,ch= blob_image.shape
109 gauss = np.random.normal(0,noiseSize,(row,col,ch))
110 gauss = gauss.reshape(row,col,ch)
AttributeError: 'NoneType' object has no attribute 'shape'
If you encounter it, try re-setting environment with different version of OpenCV.