gpt4 book ai didi

python - cv2.error : OpenCV(4. 5.2) .error : (-215:Assertion failed) ! _src.empty() 函数 'cv::cvtColor'

转载 作者:行者123 更新时间:2023-12-04 12:29:23 32 4
gpt4 key购买 nike

import cv2 #for image processing
import easygui #to open the filebox
import numpy as np #to store image
import imageio #to read image stored at particular path

import sys
import matplotlib.pyplot as plt
import os
import tkinter as tk
from tkinter import filedialog
from tkinter import *
from PIL import ImageTk, Image



top=tk.Tk()
top.geometry('400x400')
top.title('Cartoonify Your Image !')
top.configure(background='white')
label=Label(top,background='#CDCDCD', font=('calibri',20,'bold'))

def upload():
ImagePath=easygui.fileopenbox()
cartoonify(ImagePath)


def cartoonify(ImagePath):

# read the image
originalmage = cv2.imread(ImagePath)

originalmage = cv2.cvtColor(originalmage, cv2.COLOR_BGR2RGB)
#print(image) # image is stored in form of numbers
cv2.error: OpenCV(4.5.2) C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-vi271kac\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'

最佳答案

再次检查图像地址。这通常发生在图像未以任何方式正确加载时。尝试直接给出地址;类似于“C:\\test.jpg”

import cv2
im = cv2.imread("WRONG IMAGE ADDRESS.jpg", 1)
im = cv2.cvtColor(im, cv2.COLOR_RGB2GRAY)
enter image description here

关于python - cv2.error : OpenCV(4. 5.2) .error : (-215:Assertion failed) ! _src.empty() 函数 'cv::cvtColor',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67440510/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com