Image.draw_* fail on images from Image.Read: pixel data is not C-contiguous (cv2 line/circle/putText layout error)
メンテナーはふだん 1 日以内に返信
関連するプルリクエストがすでにマージされています。
- #162 @petercorke による — マージ済み
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- opencv, python
調査の方向性
Start in base/graphics.py, where draw_point calls cv2.putText, and inspect the other draw_* functions that pass the image to OpenCV drawing calls. Reproduce with the issue's Image.Read("monalisa.png") example and check the array's contiguity; add the requested regression test for drawing text on an image read this way. Done when the drawing call succeeds on OpenCV 5 and the regression test passes; pull request #162 is already open.
索引モデルが issue の本文から書いたものです。
説明
On OpenCV 5.0, Image.draw_point(..., text) raises when the image comes straight from Image.Read. This breaks the example in its own docstring, so the published docs show a traceback.
Reproduce
OpenCV 5.0.0 (also 5.0.0.93 from PyPI), origin/main at 77a3da9c:
from machinevisiontoolbox import Image
img = Image.Read("monalisa.png")
img.draw_point((270, 194), "+", "eye", fontsize=1, color="yellow")
File ".../machinevisiontoolbox/base/graphics.py", line 782, in draw_point
cv2.putText(
cv2.error: OpenCV(5.0.0) :-1: error: (-5:Bad argument) in function 'putText'
> Overload resolution failed:
> - Layout of the output array img is incompatible with cv::Mat
> - Expected Ptr<cv::UMat> for argument 'img'
Likely cause
The array that Image.Read returns is not C-contiguous. For monalisa.png it has shape (700, 677, 3), strides (677, 1, 473900) and flags["C_CONTIGUOUS"] == False: the memory is planar (channel-first) and the Image holds a transposed view. cv2.putText on 5.0 rejects an output array in that layout.
Not yet checked:
- whether OpenCV 4 accepts it (the test machines used here all had OpenCV 5.0.0);
- why
Image.Readproduces a planar layout; - whether the other
draw_*functions inbase/graphics.pythat pass the image tocv2drawing calls fail the same way.
Fix ideas
- Make the
draw_*functions work on a contiguous copy and write the result back (or return it), or - have
Image.Read/Imageconstruction keep arrays C-contiguous, which is the more general fix but touches more code.
Whichever is chosen, add a regression test that draws text onto an Image.Read image on OpenCV 5 (the existing suite passes on 4 and 5, so it does not exercise this path).
Found while investigating broken examples in the docs build; see the tech-debt issue #159.
- 主要言語
- Python
- スター
- 224
- フォーク
- 35
- 平均マージ
- 1日 20時間
- マージ済み PR(30日)
- 34
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
petercorke/machinevision-toolbox-python のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 76/100
petercorke/machinevision-toolbox-python#160 ·
メンテナーはふだん 1 日以内に返信
-
tech-debt
難易度 4/5 3〜5日 初心者へのやさしさ 39/100
petercorke/machinevision-toolbox-python#159 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 42/100
petercorke/machinevision-toolbox-python#157 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
petercorke/machinevision-toolbox-python#152 ·
メンテナーはふだん 1 日以内に返信
-
ROSBag: RealSense bags have a 4-byte depth-units trailer that is guessed, not parsed再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンbug help wanted
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
petercorke/machinevision-toolbox-python#151 ·
メンテナーはふだん 1 日以内に返信
petercorke/machinevision-toolbox-python の issue をすべて見る
似ている issue
-
resource-submission validation-passed
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
hesreallyhim/awesome-claude-code#3214 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
room-commons replace accepts an empty old string and silently prepends the new text to the pageオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
doobidoo/mcp-memory-service#1650 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 82/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
ml-explore/mlx-lm#2002 ·
メンテナーはふだん 2 日以内に返信