ошибка: -215: утверждение failedsize.empty () в функции cv :: resize - PullRequest
0 голосов
/ 21 апреля 2020

так как я новичок в cv2, плз, помогите мне исправить эту ошибку

для training_name в train_labels: # присоединитесь к пути обучающих данных и к папке с обучением каждого вида dir = os.path.join (r 'C : \ Users \ Aiswarya \ image -ification \ dataset \ train, 'bluebell', 'buttercup', 'colitsfoot', 'cowslip', 'crocus', 'daffodil', 'daisy', 'одуванчик', 'fritillary' , 'iris', 'lilyvalley', 'pansy', 'snowdrop', 'sunflower', 'tigerlily', 'tulip')

# get the current training label
current_label = 'bluebell', 'buttercup', 'colitsfoot', 'cowslip', 'crocus', 'daffodil', 'daisy', 'dandelion', 'fritillary', 'iris', 'lilyvalley', 'pansy', 'snowdrop', 'sunflower', 'tigerlily', 'tulip'

# loop over the images in each sub-folder
for x in range(1,images_per_class+1):
    # get the image file name
    file = dir + "/" + str(x) + ".jpg"

    # read the image and resize it to a fixed-size
    image = cv2.imread(file)
    image = cv2.resize(image,fixed_size)

    ####################################
    # Global Feature extraction
    ####################################
    fv_hu_moments = fd_hu_moments(image)
    fv_haralick   = fd_haralick(image)
    fv_histogram  = fd_histogram(image)

    ###################################
    # Concatenate global features
    ###################################
    global_feature = np.hstack([fv_histogram, fv_haralick, fv_hu_moments])

    # update the list of labels and feature vectors
    labels.append(current_label)
    global_features.append(global_feature)

print("[STATUS] processed folder: {}".format(current_label))

print ("[STATUS] завершено Глобальное извлечение признаков .. . ")

error

error                                     Traceback (most recent call last)
<ipython-input-10-24457b2e2916> in <module>
     14         # read the image and resize it to a fixed-size
     15         image = cv2.imread(file)
---> 16         image = cv2.resize(image,fixed_size)
     17 
     18         ####################################

error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\imgproc\src\resize.cpp:4045: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'
...