I'm writing the code to process 6 images in the folder 'test_images'. Their name has been stored in the TestImagesArray.
So print(TestImagesArray) gives me:
['solidYellowCurve.jpg', 'whiteCarLaneSwitch.jpg', 'solidWhiteCurve.jpg', 'solidYellowLeft.jpg', 'solidWhiteRight.jpg', 'solidYellowCurve2.jpg']
In the for loop, I try to read from the first to the 6th
Total 6 images
for i in range(0,2):
# Add the folder's name before image name
location = 'test_images/'+TestImagesArray[i];
image = mpimg.imread(location)
gray = grayscale(image)
# Assumption: one kernal size for all images
...
print(i)
When i=0, it works. But when i=1, it returns error.
Traceback (most recent call last): File "p1.py", line 121, in image = mpimg.imread(location) File "/home/cocadas/miniconda3/envs/carnd-term1/lib/python3.5/site-packages/matplotlib/image.py", line 1227, in imread im = pilread(fname) File "/home/cocadas/miniconda3/envs/carnd-term1/lib/python3.5/site-packages/matplotlib/image.py", line 1205, in pilread with Image.open(fname) as image: File "/home/cocadas/miniconda3/envs/carnd-term1/lib/python3.5/site-packages/PIL/Image.py", line 2410, in open fp = builtins.open(filename, "rb") FileNotFoundError: [Errno 2] No such file or directory: 'test_images/whiteCarLaneSwitch.jpg'
In the same directory that runs 'python p1.py'. Verify the location of the file by
cocadas@cocadas-ThinkPad-W540:~/Workspace/carnd/CarND-LaneDection-HT$ ls -al test_images/whiteCarLaneSwitch.jpg
-rw-rw-r-- 1 cocadas cocadas 60676 May 30 13:05 test_images/whiteCarLaneSwitch.jpg
So this tells me that the file is there. It doesn't make sense to me. Do I miss anything?
test_images/relative to where you executed the script, rather than where the script actually is. If you know that the files exist, verify this isn't happening either.print os.getcwd()to get where the script's current working directory