IuAyala / Self-Driving-Cars-Course

This repository stores code for my Self-Driving Cars Course!
MIT License
6 stars 8 forks source link

error: OpenCV(4.7.0) /io/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor' #3

Closed CountryCousin closed 1 year ago

CountryCousin commented 1 year ago

I am getting this error despite the fact I have a mirror of the cloned repo, what could be wrong here,

I searched for solution online, other people have gotten the error and attributed it to path, but I am working with the repo, what is happening??

[ WARN:0@1.148] global loadsave.cpp:244 findDecoder imread_('image.png'): can't open/read file: check file path/integrity
---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
Cell In[1], line 113
    110 yellow_pixel = np.array([25, 127, 127])
    111 error = np.array([5, 255, 255])
--> 113 binary_image = colour_threshold_cv2(image, yellow_pixel, error)
    114 normalized_column, average_column = calculate_normalized_average_col(binary_image)
    116 cv2.imshow("binary image", binary_image)

Cell In[1], line 58, in colour_threshold_cv2(image, colour, error)
     57 def colour_threshold_cv2(image, colour, error):
---> 58     hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
     60     lower = colour - error / 2
     61     higher = colour + error / 2

error: OpenCV(4.7.0) /io/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'
IuAyala commented 1 year ago

This error message is indicating that the image file cannot be found or read by the program, despite the fact that you have a mirror of the cloned repository. There could be a few possible causes for this error:

  1. The file path for the image file is incorrect. Double check that the file path for the image file is correct in your code and that the file is located in the expected location in your cloned repository.
  2. The image file may be corrupted or missing from the cloned repository. Make sure that the image file is present and not corrupted in your cloned repository.
  3. The file format of the image file may be unsupported. Make sure that the image file is in a format that is supported by the OpenCV library, such as PNG or JPG.
  4. The image file may not be loaded correctly. Make sure that you are loading the image file correctly in your code.
  5. Make sure that you have the right version of the OpenCV installed, it may be that the version of OpenCV you are using is not compatible with the image file format.

It is recommended to check these points and also you can look for more specific solutions for this error message as it could be caused by other issues not mentioned here.

If you have problems like that, something that I have very helpful is to use ChatGPT (is free to use, you only need an OpenAI account). If you simply copy your error message there, it will tell you what you should do and help you navigate the issue.

I hope it helps!

IuAyala commented 1 year ago

Hi vikkydataseo,

Thanks for reaching out for help. I hope the suggestions I've provided have been helpful in resolving the issue with the error message you are encountering. If you are still facing any issues, feel free to reach out again.

Best regards