Skip to content

jimlehner/oms-desktop-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📏 OMS — Object Measurement System

A standalone desktop application for measuring physical objects using a webcam and a quarter as a calibration reference. Built with Python, PyQt5, and OpenCV.


Features

  • 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

Requirements

Python

Python 3.8 or higher

Dependencies

PyQt5
opencv-python
numpy
pandas

Install all dependencies with:

pip install PyQt5 opencv-python numpy pandas

Folder Structure

OMS 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.


Running the App

cd "C:\Users\james\OneDrive\Documents\Object Measurement System\OMS desktop app"
python oms_app.py

Packaging as a Desktop App

To build a standalone .exe:

pip install pyinstaller
pyinstaller --onefile --windowed --icon=images\ruler.ico oms_app.py

The executable will be created at dist\oms_app.exe. Right click it and select Send to > Desktop (create shortcut) to add a desktop icon.


Workflow

Step 1 — Calibration

  1. Click Detect cameras to scan for available cameras
  2. Select your camera from the dropdown and click Start camera
  3. Enter a session name when prompted (defaults to today's date)
  4. 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.

Step 2 — Calibration Capture (new calibration only)

  1. Place a US quarter at each of the 5 indicated positions on screen
  2. Click Capture at each position — 5 frames are captured automatically per location
  3. OMS detects the quarter in each frame and calculates pixels per mm
  4. Review the result at each position — accept or retake

Step 3 — Calibration Summary

  • 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/

Step 4 — Capture Measurements

  1. Place your object in the camera's field of view
  2. Click Capture — OMS detects all objects in the ROI and measures them
  3. Results are displayed in the table and the annotated image is shown alongside the live feed
  4. Repeat for as many measurements as needed
  5. Click Done when finished

Key Constants

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

Output Files

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.


Troubleshooting

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

Credits

Developed by BrokenQuality

About

A desktop application for measuring physical objects using a webcam.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages