I'm trying to solve a captcha image I downloaded by editing a code on github

Any help greatly appreciated.

import numpy as np
import cv2
import glob
from imutils import paths
import os
import os.path

print(os.getcwd())
os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0'
captcha_image = ("c:/Users/micha/Documents/PythonProgramming/IG//captcha.jpg")
# Load the image and convert it to grayscale
image = cv2.imread(captcha_image)
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

I keep getting the following error;

Traceback (most recent call last):
File “c:\Users\micha\Documents\PythonProgramming\IG\pytesseract_solver.py”, line 18, in
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cv2.error: OpenCV(4.10.0) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\color.cpp:196: error: (-215:Assertion failed) !_src.empty() in function ‘cv::cvtColor’

crosspost:

this is not an opencv problem
(rather arbitrary python copypasteandnoideawhyitdoesnotwork)

let’s close this !

I’m new to python and am trying everything I can think of

It can read the image it’s just gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) that fails.

I have checked my image loads with this code;

import cv2 as cv
import os

img = cv.imread(“resized.jpg”)

cv.imshow(“Display window”, img)
print(img)
k = cv.waitKey(0)
cv.destroyAllWindows()