Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 error: (-215:Assertion failed)
Hello everyone

I'm getting this error:
error                                     Traceback (most recent call last)
<ipython-input-18-1ea0691ca06e> in <module>
      1 dir1 = os.listdir(r'C:/Users/gonca/Desktop/cityscape')
      2 dir2 = os.listdir(r'C:/Users/gonca/Desktop/landscape')
----> 3 name,img = uploadImg(dir1, dir2)

<ipython-input-17-831c56f87f59> in uploadImg(dir1, dir2)
     11             orig = cv2.imread(r'C:/Users/gonca/Desktop/landscape' + file)
---> 12             orig = cv2.cvtColor(orig, cv2.COLOR_BGR2RGB)
     13             cityscape = cv2.resize(orig,(512,512))
     14             #cityscape_original.append(cityscape)

error: OpenCV(3.4.2) c:\miniconda3\conda-bld\opencv-suite_1534379934306\work\modules\imgproc\src\color.hpp:253: error: (-215:Assertion failed) VScn::contains(scn) && VDcn::contains(dcn) && VDepth::contains(depth) in function 'cv::CvtHelper<struct cv::Set<3,4,-1>,struct cv::Set<3,4,-1>,struct cv::Set<0,2,5>,2>::CvtHelper'
Can you guys helping me?

This is the code i have:
from sklearn.decomposition import NMF
from matplotlib import pyplot as plt
import cv2
import numpy as np
import os
import sys
import statistics

## upload imgs e returns names e imgs
def uploadImg(dir1,dir2):
    cityscape_original = []
    landscape_original = []
    nameList = [[] for _ in range(512)]
    imgList = [[] for _ in range(512)]
    for file in os.listdir(r'C:/Users/gonca/Desktop/landscape'):
        if file.endswith(".jpg"):
            orig = cv2.imread(r'C:/Users/gonca/Desktop/landscape' + file)
            orig = cv2.cvtColor(orig, cv2.COLOR_BGR2RGB)
            cityscape = cv2.resize(orig,(512,512))
    for file in os.listdir(r'C:/Users/gonca/Desktop/cityscape'):
        if file.endswith(".jpg"):
            orig = cv2.imread(r'C:/Users/gonca/Desktop/cityscape' + file)
            orig = cv2.cvtColor(orig, cv2.COLOR_BGR2RGB)

            landscape = cv2.resize(orig,(512,512))
    return nameList,imgList

dir1 = os.listdir(r'C:/Users/gonca/Desktop/cityscape')
dir2 = os.listdir(r'C:/Users/gonca/Desktop/landscape')
name,img = uploadImg(dir1, dir2)
Thanks for the support

Gonçalo Matos
The GitHub for OpenCV has a closed ticket on this. The response was that the base image is likely not a three-channel image and has likely been saved as a single-channel. Other resolutions I've seen recommend a try...except block for it. Perhaps use a try...except with a grayscale to RGB constant instead.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Test Case Assertion Error moga2003 10 801 Mar-18-2019, 01:06 AM
Last Post: moga2003
  Assertion Error Mateoo 2 345 Jan-20-2019, 03:59 PM
Last Post: stullis
  python import sybpydb error: DLL load failed: The specified module could not be found andieDu 3 2,521 Apr-04-2018, 06:58 AM
Last Post: Larz60+

Forum Jump:

Users browsing this thread: 1 Guest(s)