You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

OpenCV imshow显示图像时Mac端无关闭按钮,Windows端正常的问题求助

OpenCV imshow显示图像时Mac端无关闭按钮,Windows端正常的问题求助

大家好,我最近碰到个头疼的小问题:在用OpenCV的imshow函数渲染图像时,Windows机器上运行代码完全正常,窗口的关闭按钮能正常显示也能正常使用,但换到Mac机器上,窗口居然看不到关闭按钮!

下面是我用到的代码:

def detect_objects_in_image(image_path: str):
    frame = cv2.imread(image_path)
    if frame is None:
        typer.echo(f"Error: Unable to load image {image_path}.")
        return

    results = model(frame, imgsz=640, conf=0.5)

    for result in results:
        for box in result.boxes:
            x1, y1, x2, y2 = map(int, box.xyxy[0])
            class_id, confidence = int(box.cls[0]), float(box.conf[0])

            cv2.rectangle(frame, (x1, y1), (x2, y2), (0, 255, 0), 2)
            cv2.putText(frame, f"Class {class_id}: {confidence:.2f}", (x1, y1 - 10),
                        cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 255, 0), 2)

    cv2.imshow("Image Analysis", frame)
    cv2.waitKey(0)
    cv2.destroyAllWindows()

有没有朋友遇到过类似的情况?求指点一下怎么解决Mac上窗口没有关闭按钮的问题!

备注:内容来源于stack exchange,提问作者user352290

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.14 09:08:00