Sources.py: quick wins, split into a package, and API unification
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- opencv, python
- Lĩnh vực
- api, backend, computer-vision
Hướng nghiên cứu
Start with the ordered quick wins in src/machinevisiontoolbox/Sources.py; each is scoped as a separate small PR, and the file itself is the entry point. For the package split, first land the quick wins, then move the classes into the named modules and preserve public exports and private availability flags. Verify imports and run tests/test_image_sources.py and tests/test_ros.py (the latter needs the ros extra); the API unification items need discussion before work starts.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
src/machinevisiontoolbox/Sources.py is about 4250 lines and holds every image source class: VideoFile, VideoCamera, WebCam, EarthView, FileCollection, FileArchive, ImageSequence, TensorStack, PointCloudSequence, LabelMeReader, and the ROS classes (ROSTopic, SyncROSStreams, ROSBag). The ROS code alone is roughly 40% of the file, and depends one-way on the rest. This issue collects the work to tidy it up. Contributions are welcome: items are ordered, and the first group needs no design decisions.
The RealSense ROSBag decoding bug is tracked separately (#151), because it is a user-facing defect and can be fixed independently.
1. Quick wins (no API change, one small PR each is fine)
-
VideoFile: raise a clear error when the file cannot be opened, instead of failing later withAttributeErroron aNonecapture. -
LabelMeReader: raise on bad input instead ofreturn None. -
ImageSource: thehasattr(self, "__len__")checks (in__init__and the iteration setup) are dead code, since the class defines the attribute; replace them with a real test. - Add timeouts to
urllib.request.urlretrieve/urlopen(ROSBagURL download,LabelMeReader) and to theEvent.wait()calls inROSTopic, so a stalled connection cannot hang forever. - Delete the unused
_PC2_DTYPEtable and theif __name__ == "__main__":block at the bottom. - Fix docstring errors:
prop/propertyin the camera-property methods, the duplicatedshow_allowedentry inROSBag.print,tol/tolerance, and the "coolumn" typo. -
docs/source/sources.rstdocuments aread()method that does not exist;docs/source/ros.rstcall signatures need checking against the code. - Collapse the repeated
colororderbranching (about ten copies) into one helper that wraps an array as anImage. -
ROSBag: replaceprint()withlogging(about 30printcalls in the file).
2. Split into a package (pure move, its own PR, no behaviour change)
git mv Sources.py Sources/__init__.py, then move classes into _base.py (ImageSource and shared helpers), video.py, files.py, archive.py, web.py, tensor.py, labelme.py, pointcloud.py and ros.py.
-
__init__.pymust re-export every public name and the private availability flags that tests read viagetattr. - Update test patch targets that name
Sources.safe_plt_show, and check the Sphinxcurrentmoduledirectives. - Verify with an import of every public name from both
machinevisiontoolboxandmachinevisiontoolbox.Sources, thentests/test_image_sources.pyandtests/test_ros.py(needs therosextra). - Optional follow-up: lazy-import
rosbags/roslibpysoimport machinevisiontoolboxstops paying for them.
Please do the split after the quick wins, in a PR containing nothing else, so it is easy to review as a pure move. Other work (for example making optional data files downloadable on demand) will also edit this file's call sites, so landing the split first avoids painful rebases.
3. API unification (changes behaviour, needs design discussion first)
- Shared
loop,rgb/colororder,dtypeand start/stop/step options on the base class. -
__iter__returns a fresh iterator each time. - One live-source API:
close()plus context-manager support everywhere, retiregrab(). - Lock
ROSTopic's latest-frame and timestamp state.
Any of these should come with deprecation warnings for the old behaviour. Please open a discussion or comment here before starting.
4. After the split
- Annotate the split modules (the parameter annotations for
Sources.pyare tracked in #60; about 50 are missing today). - Add mocked tests for
VideoCamera,WebCamandEarthView.
Notes for contributors
- Branch from
mainand open a PR; titles follow Conventional Commits (fix:,refactor:,docs:). - Please keep each PR to one of the items above.
- Related open work: #125 is fixed by PR #149 (
EarthViewkey lookup), which touches this file; it should land first.
- Ngôn ngữ chính
- Python
- Star
- 224
- Fork
- 31
- Merge trung bình
- 1 ngày 20 giờ
- Pull request đã merge (30 ngày)
- 28
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của petercorke/machinevision-toolbox-python
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
petercorke/machinevision-toolbox-python#152 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ROSBag: RealSense bags have a 4-byte depth-units trailer that is guessed, not parsedCó thể đã có người làm @theluckystrike đã nhận hôm nay. Đang mởbug help wanted
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
petercorke/machinevision-toolbox-python#151 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 43/100
petercorke/machinevision-toolbox-python#148 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
tech-debt
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 30/100
petercorke/machinevision-toolbox-python#147 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Revert JupyterLite deps=False workaround once spatialmath #250 is released (review by 2026-10-28)Đang mởtech-debt
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 20/100
petercorke/machinevision-toolbox-python#137 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của petercorke/machinevision-toolbox-python
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
[Bug] to_ical lexicographical/default sorting moves URL property between two X-WR- propertiesĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
collective/icalendar#1968 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Deferred from #1869: Complete the companion pytest guardrail update noted in the PR description...Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Custom provider API keys collide on one host: env slot keyed on host:port only, not URL pathĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
NousResearch/hermes-agent#140958 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug triage/confirmed
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 85/100
agentscope-ai/agentscope#3355 ·
Maintainer thường phản hồi trong vòng 2 ngày