I am trying to load four images into my python file from a directory for further processing.
import cv2 as cv
import pandas as pd
import matplotlib.pyplot as plt
import glob
import numpy as np
cv_img=[]
acne_string=[]
trust_score=[]
def avg(lst):
return sum(lst) / len(lst)
for img in glob.glob("/home/centura/Desktop/Centura Tech/p1-Diseases/New_acne_grades/Transformed images/API-testing/images/*.jpg"):
u = cv.imread(img, cv.IMREAD_COLOR)
smoothing=cv.GaussianBlur(u.copy(),(5,5),cv.BORDER_DEFAULT)
img_grey = cv.cvtColor(smoothing.copy(), cv.COLOR_BGR2GRAY)
plt.imshow(img_grey)
plt.axis("off")
plt.show()
The python script basically does threshold and gray scale conversion. The problem is i am getting an error like this.
File "/home/centura/Desktop/Centura Tech/p1-Diseases/All grades test/t_t.py", line 40, in engine
u = cv.imread(img, cv.IMREAD_COLOR)
AttributeError: 'float' object has no attribute 'imread'
I am using python3 and opencv 3.4.3. I have to use OpenCV for reading in images i cannot use PIL
. Any work around