0

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

Ha Bom
  • 2,787
  • 3
  • 15
  • 29
Danish Xavier
  • 1,225
  • 1
  • 10
  • 21
  • I just edited some of indent errors in your code. I can run your code normally. Could you provide some images? – Ha Bom Nov 15 '18 at 09:06
  • @HaBom i found the fault, my code is about 400 lines in between the code i have accidentally assigned cv as another variable.So python read it with the new value instead of image. – Danish Xavier Nov 15 '18 at 10:07

0 Answers0