A standalone desktop application for measuring physical objects using a webcam and a quarter as a calibration reference. Built with Python, PyQt5, and OpenCV.
- Live camera feed at ~30fps via OpenCV
- Automated calibration using a US quarter (24.26mm diameter) as a reference object
- Automatic object detection using Otsu thresholding and contour analysis
- Per-object measurements — width, height, area, and angle
- Annotated result images with measurement overlays
- Running measurement table showing all captures in the current session
- Auto-save after every capture — latest data is always on disk
- Session naming — user-defined session name with full timestamp retained in data
- Calibration file management — save, load, and review past calibrations
Python 3.8 or higher
PyQt5
opencv-python
numpy
pandas
Install all dependencies with:
pip install PyQt5 opencv-python numpy pandasOMS desktop app\
├── oms_app.py
├── images\
│ ├── bq_logo.png
│ └── ruler.png
├── data\
│ ├── calibration\
│ └── results\
└── README.md
Data folders are created automatically on first run if they do not exist.
cd "C:\Users\james\OneDrive\Documents\Object Measurement System\OMS desktop app"
python oms_app.pyTo build a standalone .exe:
pip install pyinstaller
pyinstaller --onefile --windowed --icon=images\ruler.ico oms_app.pyThe executable will be created at dist\oms_app.exe. Right click it and select Send to > Desktop (create shortcut) to add a desktop icon.
- Click Detect cameras to scan for available cameras
- Select your camera from the dropdown and click Start camera
- Enter a session name when prompted (defaults to today's date)
- Either load an existing calibration from the list or click Run new calibration
Note: OMS should be recalibrated for each new measurement setup. To maximize measurement quality, ensure even lighting and minimize vertical distance between the camera lens and the measurement object.
- Place a US quarter at each of the 5 indicated positions on screen
- Click Capture at each position — 5 frames are captured automatically per location
- OMS detects the quarter in each frame and calculates pixels per mm
- Review the result at each position — accept or retake
- Displays mean pixels per mm, standard deviation, and coefficient of variation (CV)
- CV below 2% is shown in green; above 2% is shown in amber as a quality warning
- Calibration is saved automatically to
data/calibration/
- Place your object in the camera's field of view
- Click Capture — OMS detects all objects in the ROI and measures them
- Results are displayed in the table and the annotated image is shown alongside the live feed
- Repeat for as many measurements as needed
- Click Done when finished
| Constant | Value | Description |
|---|---|---|
QUARTER_DIAMETER_MM |
24.26 | Diameter of a US quarter in mm |
MIN_CONTOUR_AREA |
100 | Minimum contour area in pixels to detect as an object |
DECIMAL_PLACES |
3 | Decimal places shown in measurements |
CAPTURES_PER_LOCATION |
5 | Frames captured per calibration location |
CAPTURE_DELAY_MS |
400 | Delay between calibration frames in ms |
CV_WARNING_THRESHOLD |
2.0 | CV% above which a calibration quality warning is shown |
PREVIEW_W / PREVIEW_H |
640 / 480 | Live feed preview resolution |
All output is saved to data/results/session_<name>\:
| File | Description |
|---|---|
results.csv |
All measurement data with timestamps |
raw_<n>.png |
Raw captured image for each measurement |
result_<n>.png |
Annotated result image for each measurement |
Calibration files are saved to data/calibration/ as .json files containing timestamp, pixels per mm, and CV.
Camera not detected
- Click Detect cameras again
- Try a different camera index in the dropdown
- Ensure no other application is using the camera
High calibration CV
- Ensure the quarter is flat and fully visible
- Improve lighting — avoid shadows and glare
- Reduce distance between camera and surface
Objects not detected
- Ensure good contrast between objects and background
- A plain white or black background works best
- Check that objects are within the green ROI boundary shown on screen
Developed by BrokenQuality