0

I am trying to do a basic emotion recognition with fisherface in python however I can't seem to get past the below error. It is trying to read .jpg files in folders. I have re-installed python and OpenCV(4.1.0) but still same error.

Here is the code that fails:

emotions = ["anger", "neutral", "contempt", "disgust", "happy", "happy", "sadness", "surprise"] #Emotion list
fishface = cv2.face.FisherFaceRecognizer_create() #Initialize fisher face classifier

def get_files(emotion):
    files = glob.glob("C:\\Users\\Noel\\Documents\\Project AI\\Phyton\\dataset\\%s\\*" %emotion)
    random.shuffle(files)

This is the error message:

error: OpenCV(4.1.0) C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'

I tried arranging the path and also tried to move the folder to a new location.

Masoud
  • 1,270
  • 7
  • 12
Noel Bellizzi
  • 15
  • 1
  • 2
  • 7
  • Possible duplicate of [Open Cv Error: (-215:Assertion failed) !\_src.empty() in function 'cv::cvtColor'](https://stackoverflow.com/questions/54121013/open-cv-error-215assertion-failed-src-empty-in-function-cvcvtcolor) Check your filenames and paths. – HansHirse Jun 05 '19 at 04:15
  • check file exists and it is entered correctly. – Dr Yuan Shenghai Jun 05 '19 at 06:25
  • Please paste the relevant source code, Your error states that `cv::cvtColor` is raising the error but there is not `cv::cvtColor` found in the attached snippet. – ZdaR Jun 05 '19 at 09:03
  • `gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) #convert to grayscale training_data.append(gray) #append image array to training data list training_labels.append(emojis.index(emotion))` File exists and is passing through the array list. – Noel Bellizzi Jun 05 '19 at 14:50

0 Answers0