How rolandasrazma/rrpeeanalyzer works
1. Project shape
- This is a single iOS app, built in Xcode with CocoaPods, centered on capturing photos of urine test strips and analyzing their color pads.
- The app is not a generic camera app: the hardware setup in the README is part of the system boundary. The phone is mounted in a box with controlled lighting so image processing becomes reliable.
2. Top-level runtime
- The app starts from main.m into RRAppDelegate, then into a storyboard-driven UI under Resources/Base.lproj/Main.storyboard.
- The main execution path is a standard iOS app lifecycle, but the core domain logic lives in the model layer and is invoked from view controllers.
3. UI / interaction layer
- RRCaptureViewController is the capture workflow entry point: it likely manages live camera view, taking snapshots, and presenting results.
- RRStripSetupViewController and RRTestColorSetupViewController are calibration/setup screens. These suggest the app has explicit configuration steps for strip geometry and expected color references rather than fully automatic analysis only.
4. Capture and session management
- RRCaptureSession is the key capture abstraction. It likely wraps camera/session state, frame acquisition, and timing, so controllers don’t talk directly to low-level camera APIs.
- This forms the boundary between UIKit-driven screens and the image-processing pipeline.
5. Analysis engine
- RRStripAnalyzer is the core domain component. It is implemented in RRStripAnalyzer.mm, which means Objective-C++ is used so the app can bridge between Cocoa objects and C++/OpenCV-style processing.
- Based on the README, this engine detects the test-strip squares/rectangles and compares sampled colors to known values to derive the medical strip readings.
6. Image-processing support
- The Support folder contains several UIImage categories and C++ helpers that likely normalize image input, convert between UIKit images and OpenCV/cv::Mat representations, and perform drawing/transform/color utility work.
- UIImage+OpenCVAdditions.mm and RRCVAdditions.cpp/.hpp are the most important bridging files: they indicate the project depends on OpenCV-style processing even though the app UI is native iOS.
7. Calibration and domain data
- Resources/DUS10/DUS10.plist appears to hold reference data for a specific test-strip product or color model.
- This is an important data boundary: analysis is not purely algorithmic; it is parameterized by strip-specific calibration/reference values stored as app resources.
8. Data flow through the system
- User mounts the strip in the physical jig, opens the app, and captures an image.
- The image passes through the capture/session layer, then into the analyzer, which identifies strip regions, transforms the image if needed, and compares each pad’s color against configured references.
- Results are then surfaced back through the view controllers for display or review.
9. Hardware assumptions that affect architecture
- The README makes clear the app depends on controlled, repeatable lighting and a fixed strip position. That means the software architecture is intentionally coupled to a physical enclosure.
- This reduces the need for complex general-purpose computer vision, because the camera position, strip location, and illumination are constrained.
10. Persistence and test assets
- The Images/Samples folder contains time-series sample captures, which likely served as development/test inputs for tuning the analyzer.
- The RRStripAnalyzerTest target indicates there is at least some unit-test coverage around the analyzer logic, reinforcing that the analysis pipeline is a separable subsystem.
11. External dependencies / tooling
- CocoaPods is used, and OpenCV is the major external technology implied by the code and README.
- The important architectural implication is that this app is a hybrid native iOS + OpenCV image-processing application, not a purely UIKit-driven app.
12. How to draw the architecture
- A good diagram should show four main blocks: iOS UI controllers, capture/session management, OpenCV-based strip analysis, and calibration/resource data.
- The hardware enclosure and lighting should be shown as an external physical dependency feeding the camera input, because the app’s accuracy depends on it as much as on the code.
Main entry points: RRStripAnalyzer.mm Strip analyzer · RRCaptureViewController.m Capture screen · Main.storyboard Main storyboard · RRCaptureSession.m Capture session
Components 18
Physical setup
External enclosure and lighting that constrain capture conditions.
- Light box · Controlled enclosure and fixed lighting used to make strip images repeatable.
UIKit flow
Storyboard-driven screens and app lifecycle.
- main.m · iOS application entry point.
RRPeeAnalyzer/RRPeeAnalizer/main.m - App delegate · Application startup and lifecycle coordination.
RRPeeAnalyzer/RRPeeAnalizer/Classes/RRAppDelegate.m - Main storyboard · Storyboard defining the primary screen flow.
RRPeeAnalyzer/RRPeeAnalizer/Resources/Base.lproj/Main.storyboard - Capture screen · Entry point for capture, snapshot, and result display.
RRPeeAnalyzer/RRPeeAnalizer/Classes/Controller/RRCaptureViewController.m - Strip setup · Calibration screen for strip geometry and placement.
RRPeeAnalyzer/RRPeeAnalizer/Classes/Controller/RRStripSetupViewController.m - Color setup · Calibration screen for expected color references.
RRPeeAnalyzer/RRPeeAnalizer/Classes/Controller/RRTestColorSetupViewController.m
Capture boundary
Camera/session coordination between UI and analysis.
- Capture session · Wraps camera state, frame acquisition, and capture timing.
RRPeeAnalyzer/RRPeeAnalizer/Classes/Model/RRCaptureSession.m
Strip analysis
OpenCV-backed image processing and strip interpretation.
- Strip analyzer · Objective-C++ core that detects pads and compares colors.
RRPeeAnalyzer/RRPeeAnalizer/Classes/Model/RRStripAnalyzer/RRStripAnalyzer.mm - Analyzer test · Target-specific test coverage for the analysis pipeline.
RRPeeAnalyzer/RRPeeAnalizer/Classes/Model/RRStripAnalyzer/RRStripAnalyzerTest.m
Support code
Image conversion, transforms, drawing, and color helpers.
- CV additions · C++ helper layer for OpenCV-oriented processing.
RRPeeAnalyzer/RRPeeAnalizer/Classes/Support/RRCVAdditions/RRCVAdditions.cpp - UIImage+OpenCV · Converts between UIKit images and OpenCV-friendly representations.
RRPeeAnalyzer/RRPeeAnalizer/Classes/Support/UIImage Additions/UIImage+OpenCVAdditions.mm - UIImage transforms · Image transformation utilities used by the analysis flow.
RRPeeAnalyzer/RRPeeAnalizer/Classes/Support/UIImage Additions/UIImage+RRTransformsAdditions.m - UIImage drawing · Drawing utilities for overlays and diagnostics.
RRPeeAnalyzer/RRPeeAnalizer/Classes/Support/UIImage Additions/UIImage+RRDrawingAddition.m - UIImage color · Color-related helpers for sampling and comparison support.
RRPeeAnalyzer/RRPeeAnalizer/Classes/Support/UIImage Additions/UIImage+UIColorAdditions.m - UIImage strings · String-related image helper category.
RRPeeAnalyzer/RRPeeAnalizer/Classes/Support/UIImage Additions/UIImage+NSStringAdditions.m
Calibration data
Strip-specific reference resources and sample captures.
- DUS10 plist · Reference values for a specific test-strip product or color model.
RRPeeAnalyzer/RRPeeAnalizer/Resources/DUS10/DUS10.plist - Sample images · Captured example images used for development and tuning.
Images/Samples
Connections 20
- Light box → Capture screen: feeds images · Controlled lighting and fixed positioning make capture reliable.
- main.m → App delegate: starts · Standard iOS entry into the app lifecycle.
- App delegate → Main storyboard: loads · App startup is storyboard-driven.
- Main storyboard → Capture screen: opens · Primary workflow begins in the capture screen.
- Main storyboard → Strip setup: opens · Setup flow for strip geometry calibration.
- Main storyboard → Color setup: opens · Setup flow for color reference calibration.
- Capture screen → Capture session: uses · Controller delegates camera/session work to the capture abstraction.
- Capture screen → Strip analyzer: invokes · Captured images are passed to the analysis engine.
- Strip setup → Strip analyzer: configures · Setup screens tune strip detection parameters.
- Color setup → Strip analyzer: configures · Setup screens tune expected color references.
- Capture session → UIImage+OpenCV: converts · Frames are adapted for OpenCV-style processing.
- Strip analyzer → CV additions: relies on · Core analysis uses C++ helper functions.
- Strip analyzer → UIImage transforms: transforms · Images are normalized and rectified before sampling.
- Strip analyzer → UIImage drawing: annotates · Debug or result overlays may be drawn on images.
- Strip analyzer → UIImage color: samples · Pad colors are extracted and compared.
- Strip analyzer → DUS10 plist: reads refs · Analysis is parameterized by strip-specific calibration data.
- Strip analyzer → Sample images: tuned by · Reference captures support development and tuning.
- Strip analyzer → Analyzer test: validated by · Unit tests exercise the separable analysis subsystem.
- Capture session → Capture screen: serves · Provides capture state and frames back to the UI.
- Strip analyzer → Capture screen: returns results · Analysis results are surfaced to the user interface.