<pre>img_file = 'test2.png' img = cv2.imread(img_file, 1) img = cv2.cvtColor(img,cv2.COLOR_BGR2RGB) print(f"Loaded {img_file} ({img.shape[1]} x {img.shape[0]})" ) # Resize if image larger than 2k pixels on a side if img.shape[1] > 2000 or img.shape[0] > 2000: print(f"Image too big ({img.shape[1]} x {img.shape[0]})") new_size = 800.0 # px if img.shape[1] > img.shape[0]: # resize by width to new limit ratio = new_size / img.shape[1] else: # resize by height ratio = new_size / img.shape[0] print(f"Reducing by factor of {(1./ratio)}" ) # img = cv2.resize(img,(0,0),fx=ratio,fy=ratio) print (f"New size: ({img.shape[1]} x {img.shape[0]})") # See original image plt.imshow(np.asarray(img))
error: OpenCV(4.5.3) C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-sn_xpupm\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'
<pre>--------------------------------------------------------------------------- error Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_7268/4163631807.py in <module> 2 3 img = cv2.imread(img_file, 1) ----> 4 img = cv2.cvtColor(img,cv2.COLOR_BGR2RGB) 5 print(f"Loaded {img_file} ({img.shape[1]} x {img.shape[0]})" ) 6
img = cv2.imread(img_file, 1)
img = cv2.imread(img_file)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)