Last answered:

08 Jul 2022

Posted on:

07 Jul 2022

1

Resolved: When I run that code it gives me an error

The code is the 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()

But this gives me the following error:

[ WARN:0@0.019] global D:\bld\libopencv_1656375874586\work\modules\imgcodecs\src\loadsave.cpp (239) cv::findDecoder imread_('capstone_coins.png'): can't open/read file: check file path/integrity
[ WARN:0@0.020] global D:\bld\libopencv_1656375874586\work\modules\imgcodecs\src\loadsave.cpp (239) cv::findDecoder imread_('capstone_coins.png'): can't open/read file: check file path/integrity
Traceback (most recent call last):
  File "c:\Users\Alega\Desktop\Cartelle\Mie\Webinar, corsi e video generici\365 Data Science Course\Career tracks\Data scientist\4 - Python Programmer Bootcamp\File creati da Visual Studio Code\capstone_solution.py", line 6, in <module>
    img=cv2.GaussianBlur(img,(5,5),0)
cv2.error: OpenCV(4.5.5) D:\bld\libopencv_1656375874586\work\modules\imgproc\src\smooth.dispatch.cpp:617: error: (-215:Assertion failed) !_src.empty() in function 'cv::GaussianBlur'

I already have capstone_coins.png and capstone_solution.py in the same folder, too

2 answers ( 1 marked as helpful)
Posted on:

07 Jul 2022

3

I think I have solved this problem: the first time we use Visual Studio Code, we should have on the left side a button with the wording "Open folder". We have to click on that folder and to select the folder in which we have the image and the .py file. I hope this can be useful to other people.

Instructor
Posted on:

08 Jul 2022

1

Hey Alessandro,

Thank you for these comments, they could definitely help other students.

Kind regards,
365 Hristina

Submit an answer