求助各位大佬了!!!求助python错误

# 坐标库
ROI = utils.ROI()
# 路径库
path = utils.Path()


# 选择序列
def hit_button_a():
    path.init(tkinter.filedialog.askdirectory(title="Select Folder"))
    # 显示路径
    if path.img_path != "":
        show_path.set("文件路径:" + str(path.img_path)[:-1] + "\n序列总数:" + str(path.sum))
    else:
        show_path.set("路径错误!")


button_a = tkinter.Button(root, text="选择序列", font=("KaiTi", 15), height=2, command=hit_button_a)
button_a.pack()
canvas.create_window(400, 200, height=20, window=button_a)


# ROI
def hit_button_b():
    # 读取首帧图像
    first_image = cv2.imread(path.pics_list[0])
    # ROI
    ROI.init_window(cv2.selectROI(windowName="ROI", img=first_image, showCrosshair=True, fromCenter=False))
    cv2.destroyAllWindows()


button_b = tkinter.Button(root, text="标记目标", font=("KaiTi", 15), heigh=2, command=hit_button_b)
button_b.pack()
canvas.create_window(400, 250, height=20, window=button_b)

上面是原来的代码

但是运行之后出现错误

Traceback (most recent call last):
  File "E:\Python\lib\tkinter\__init__.py", line 1702, in __call__
    return self.func(*args)
  File "C:/Users/黄常杰/PycharmProjects/pythonProject2/main.py", line 68, in hit_button_b
    ROI.init_window(cv2.selectROI(windowName="ROI", img=first_image, showCrosshair=True, fromCenter=False))
cv2.error: OpenCV(4.5.3) C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-uzca7qz1\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'

这一段出现错误提示求助应该怎么解决呜呜呜呜

# ROI
def hit_button_b():
    # 读取首帧图像
    first_image = cv2.imread(path.pics_list[0])
    # ROI
    ROI.init_window(cv2.selectROI(windowName="ROI", img=first_image, showCrosshair=True, fromCenter=False))
    cv2.destroyAllWindows()

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值