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 摘要。