'Bilateral Filter Error In OpenCV for Some Images
I have a dataset of memes' URLs which I wanna extract their texts from them. I have this function:
def image2text(path_x):
with requests.get(path_x, stream=True) as r:
request_x=r.content
r.close()
img=Image.open(BytesIO(request_x))
bilat_x=cv2.bilateralFilter(np.array(img),5, 55,60)
img.close()
request_x=None
cv2_x=cv2.cvtColor(bilat_x, cv2.COLOR_BGR2GRAY)
_,img = cv2.threshold(cv2_x, 240, 255, 1)
meme_text=pytesseract.image_to_string(img, lang='eng')
return meme_text
image2text('https://i.redd.it/r9lw184zky881.png')
I receive the following error:
error: OpenCV(4.1.2) /io/opencv/modules/imgproc/src/bilateral_filter.dispatch.cpp:166: error: (-215:Assertion failed) (src.type() == CV_8UC1 || src.type() == CV_8UC3) && src.data != dst.data in function 'bilateralFilter_8u'
BTW, the code is mainly copied from this source
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
