Replace OpenCV imgcodecs with vendored stb-based lar_io - #69
Merged
Conversation
Add a lar_io leaf library that handles all image I/O (JPEG via vendored
stb, plus a small OpenCV-compatible PFM codec), replacing every
cv::imread/cv::imwrite call site. Only mapping and processing link it, so
tracking-only binaries carry no image-codec code.
- Add thirdparty/stb (stb_image / stb_image_write, pinned) and
lar/io/image_io.{h,cpp}. PFM byte layout verified round-trip compatible
with OpenCV's imread/imwrite; readers return empty Mat on failure to
match cv::imread's contract.
- Move Frame into lar_core and drop the lar_tracking -> lar_mapping link
edge, so tracking's link closure is codec-free by construction.
- Drop imgcodecs (and libjpeg/zlib) from find_package, the SuperBuild
BUILD_LIST, and the xcframework build (--without imgcodecs).
- Add -ffunction-sections/-fdata-sections + linker dead-strip so
unreferenced module code is dropped from final binaries.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… runtime sift_impl_metal.mm (compiled into lar_tracking.a) uses the Objective-C runtime (NSString, @try/@catch), but the Metal block only linked Metal + MetalPerformanceShaders. Executables such as lar_localize previously got libobjc incidentally through opencv_imgcodecs' transitive framework deps; now that image I/O lives in lar_io, that link is gone and lar_localize failed with undefined _objc_* symbols. Link Foundation explicitly, and make the Metal/MPS/Foundation frameworks PUBLIC since the .mm lives in lar_tracking.a and thus every consumer of lar_tracking needs them. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Removes the OpenCV imgcodecs dependency (and the libjpeg/zlib it dragged in) by introducing a small
lar_ioleaf library that owns all image I/O. This is step 1 of gradually reducing our OpenCV surface, and it makes tracking-only binaries codec-free.Changes
lar_iotarget — vendoredstb_image/stb_image_write(pinned) for JPEG + a small OpenCV-compatible PFM codec inlar/io/image_io.{h,cpp}. It's the only module that links an image codec.cv::imread/cv::imwritecall sites swapped (src, apps, tests). Readers return an emptycv::Maton failure to matchcv::imread's contract.Framemoved intolar_core, and thelar_tracking → lar_mappinglink edge removed — so tracking's link closure is{core, tracking, opencv_core/geometry/imgproc/features/flann, g2o, eigen, json}, i.e. codec-free by construction.find_package, the SuperBuildBUILD_LIST(with JPEG/zlib off), and the xcframework build (--without imgcodecs).-ffunction-sections -fdata-sections+--gc-sections/-dead_strip) so unreferenced module code is dropped from final binaries.Verification
make testsshould be run in an OpenCV-5 environment (the machine used here had a stale OpenCV-4 build);mapper_testround-trips the.jpeg/.pfmfixtures and is the natural end-to-end gate.🤖 Generated with Claude Code