{
  "id": "opencv/highgui-window-name-duplicate",
  "signature": "cv::error: (-215:Assertion failed) !winname.empty() && namedWindow(winname, flags) == 0 in function 'imshow'",
  "signature_zh": "cv::error: (-215:断言失败) !winname.empty() && namedWindow(winname, flags) == 0 在函数 'imshow' 中",
  "regex": "Assertion failed.*winname.empty\\(\\)",
  "domain": "opencv",
  "category": "assertion_error",
  "subcategory": null,
  "root_cause": "imshow() is called with an empty window name or a window name that conflicts with an existing named window due to duplicate creation without proper flags.",
  "root_cause_type": "generic",
  "root_cause_zh": "imshow() 调用时使用了空窗口名称，或者由于未使用正确标志重复创建而导致窗口名称冲突。",
  "versions": [
    {
      "version": "4.5.5",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "4.6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "4.7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "4.8.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "4.9.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Calling namedWindow with a different flag like WINDOW_NORMAL every time",
      "why_fails": "If the window name already exists, namedWindow returns non-zero but doesn't fail; imshow still sees the conflict.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using imshow without namedWindow at all",
      "why_fails": "imshow internally calls namedWindow, so the same assertion can trigger if the name is empty.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Destroying window with destroyWindow before each imshow",
      "why_fails": "If the window name is empty, destroyWindow does nothing and imshow still fails.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Always provide a non-empty, unique window name: cv::imshow(\"Display Window\", img); or use cv::namedWindow(\"MyWindow\", cv::WINDOW_AUTOSIZE); cv::imshow(\"MyWindow\", img);",
      "success_rate": 0.95,
      "how": "Always provide a non-empty, unique window name: cv::imshow(\"Display Window\", img); or use cv::namedWindow(\"MyWindow\", cv::WINDOW_AUTOSIZE); cv::imshow(\"MyWindow\", img);",
      "condition": "",
      "sources": []
    },
    {
      "action": "Check if window exists before creating: if (cv::getWindowProperty(\"MyWindow\", cv::WND_PROP_VISIBLE) < 0) { cv::namedWindow(\"MyWindow\", cv::WINDOW_AUTOSIZE); }",
      "success_rate": 0.85,
      "how": "Check if window exists before creating: if (cv::getWindowProperty(\"MyWindow\", cv::WND_PROP_VISIBLE) < 0) { cv::namedWindow(\"MyWindow\", cv::WINDOW_AUTOSIZE); }",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Always provide a non-empty, unique window name: cv::imshow(\"Display Window\", img); or use cv::namedWindow(\"MyWindow\", cv::WINDOW_AUTOSIZE); cv::imshow(\"MyWindow\", img);",
    "Check if window exists before creating: if (cv::getWindowProperty(\"MyWindow\", cv::WND_PROP_VISIBLE) < 0) { cv::namedWindow(\"MyWindow\", cv::WINDOW_AUTOSIZE); }"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.opencv.org/4.x/d7/dfc/group__highgui.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2023-04-28",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}