Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Blobs: build the blob hierarchy as a pgraph graph instead of hand-rolled parent/children + exporters

未關閉
#128 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
5/5
預估耗時
一週以上
新手友好度
35/100
Issue 類型
重構
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
python

研究方向

Start with src/machinevisiontoolbox/ImageBlobs.py and the existing test_graph_* tests in tests/test_image_blobs.py; compare the current graph output with the pgraph 1.0 exporters and check compatibility with pgraph 0.6.x. Decide how Blob.parent and Blob.children and filtering behave, then preserve the public signatures and output formats while replacing the hand-written exporters.

由索引模型根據 Issue 內容生成。

描述

tech-debt

Current state

Blobs (src/machinevisiontoolbox/ImageBlobs.py) represents the blob hierarchy with ad-hoc parent / children references on each Blob, built from OpenCV's findContours hierarchy array. Blobs.graph() (and dotfile()) then re-implements graph export by hand: DOT, Mermaid, fenced Mermaid, GraphML and ELK JSON, roughly 150 lines of string building.

pgraph is already a core dependency (it is only used by BundleAdjust today), and pgraph 1.0 ships exporters for exactly these formats (pgraph.exporters.dot/mermaid/graphml/elk, Graph.export(), Graph.dotfile()), plus rendering to images via GraphViz.

Proposal

  • Build the blob tree as a pgraph.DGraph (parent -> child edges), with Blob instances as vertices (or vertices holding them).
  • Replace the hand-written exporters in Blobs.graph() / dotfile() with the pgraph ones, keeping the public signatures and output formats.
  • Decide whether Blob.parent / Blob.children stay as thin views over the graph or remain stored references (public API, so don't break it).
  • Gain for free: tree traversal, components, plotting and rendered images, and one place to fix export bugs.

Things to check

  • Output compatibility with the existing test_graph_* tests in tests/test_image_blobs.py (node labels, ordering, attributes in GraphML/ELK).
  • Must work with both pgraph 0.6.x (no Vertex, edges() is a set, no exporters module) and 1.0, or the minimum pgraph version has to be raised in pyproject.toml. The exporters exist only in 1.0.
  • Filtering a Blobs set can leave dangling parent/child references (see the warning in the __getitem__/filter docs); a graph representation should either handle or make explicit this.

Related: pgraph test coverage review (BundleAdjust is currently the only pgraph user).

主要語言
Python
星號
224
分支
31
平均合併
1 天 6 小時
30 天內合併 PR
19

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

petercorke/machinevision-toolbox-python 的其他 Issue

查看 petercorke/machinevision-toolbox-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。