Last answered:

11 Nov 2022

Posted on:

10 Nov 2022

1

error in vs code

I entered exactly the same code as following:
import numpy as np
import cv2
img=cv2.imread('capstone_coins.png',cv2.IMREAD_GRAYSCALE)
original_image=cv2.imread('capstone_coins.png',1)
img=cv2.GaussianBlur(img, (5,5),0)
cv2.imshow ('Detected Coins',original_image)
cv2.waitkey(0)
cv2.destroyAllWindows()

However, it did not work properly with the error:
Cell In [6], line 5  3 img=cv2.imread('capstone_coins.png',cv2.IMREAD_GRAYSCALE)  4 original_image=cv2.imread('capstone_coins.png',1) ----> 5 img= cv2.GaussianBlur(img, (5,5), 0)  6 cv2.imshow ('Detected Coins',original_image)  7 cv2.waitkey(0) error: OpenCV(4.6.0) C:\b\abs_74oeeuevib\croots\recipe\opencv-suite_1664548340488\work\modules\imgproc\src\smooth.dispatch.cpp:617: error: (-215:Assertion failed) !_src.empty() in function 'cv::GaussianBlur'

1 answers ( 0 marked as helpful)
Instructor
Posted on:

11 Nov 2022

1

Hey Arsalan,

Thank you for reaching out!

Could you please add a print-statement right after you declare the img variable, as shown in the screenshot, and share your output. What you should get is a matrix with dimensionality (890, 1920).
image.png

Kind regards,
365 Hristina

Submit an answer