The source code is as follows:
import os
import cv2
import random
import numpy as np
from tqdm import tqdm
from matplotlib import pyplot as plt
# View two pictures
img_path1 = "cat2.jpg"
img_check1 = cv2.imread(img_path1, cv2.IMREAD_GRAYSCALE)
img_path2 = "cat3.jpg"
img_check2 = cv2.imread(img_path2, cv2.IMREAD_GRAYSCALE)
# Show picture
fig, axes = plt.subplots(nrows=1, ncols=2,figsize=(13,7))
axes[0].imshow(img_check1,'gray')
axes[1].imshow(img_check2,'gray')
plt.show()
When the program is running, it always reports an error in the code marked with red. It takes a long time to find that it has made a very stupid error: the path is wrong (at the same time, the path contains Chinese). Although the path is wrong, it always reports another error, so it is difficult to find this problem
So when you have the same error, you can check whether the path contains a Chinese name or the path is wrong. Solutions for reference only, if there is a better solution, welcome to leave a message
Similar Posts:
- AttributeError: module ‘cv2’ has no attribute ‘CV_HAAR_SCALE_IMAGE’
- Image data type conversion uint8 and double in MATLAB
- Python OpenCV BUG: all the input arrays must have same number of dimensions
- python from scipy.misc import imread:ImportError: cannot import name imread
- AttributeError: module ‘cv2’ has no attribute ‘SIFT’ [How to Solve]
- attributeError: ‘NoneType’ object has no attribute ‘shape’
- attributeError: ‘NoneType’ object has no attribute ‘shape’
- R6010 -abort() has been called error analysis and solutions
- How to Solve Libpng warning ICCP error
- [Solved] ImportError: cannot import name ‘imread’