@nextmeters/lcd-check
v1.0.0
Published
Package that provides the ability to check lcd segments for quality control purposes
Maintainers
Keywords
Readme
nm-lcd-check
Overview
nm-lcd-check verifies the status of segments on an LCD screen. Given photos of a device, it locates the LCD screen in each image and checks whether each segment is in the expected state (on or off).
Installation
git clone [email protected]:NextCenturyMeters/nm-lcd-check.git
cd nm-lcd-check
npm installHow it works
Verification requires three types of images for each device model:
- Template image — a tight crop of just the LCD screen with all segments off. Used to locate the screen's position in every subsequent photo.
- All-off image — a full, uncropped photo of the device with all segments off. The template is matched against this image to find the screen's coordinates, which are then applied to test images.
- Test images — full, uncropped photos of the device in various states to verify against expected segment states.
Workflow
Step 1 — Take your photos
Take a full photo of the device with all segments off (the all-off image), crop a tight version of just the LCD area from it (the template image), and take full photos of the device in the states you want to verify (test images).
Step 2 — Label segments with the pixel picker
The pixel picker is a Python tool that lets you draw rectangles over segments on the LCD and label them. It outputs a JSON file in the correct format to pass directly as pixelData to the verifier.
Requirements: Python 3.9+, with matplotlib, numpy, and opencv-python installed.
cd pixelPicker
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install matplotlib numpy opencv-pythonOpen picker.py and set imagePath to your template image path, then run:
python picker.pyDraw a rectangle over each segment, type a label, and press Enter to save it. Green rectangles are segments expected to be on; regions with little to no pixel activity are automatically classified as expected-blank. Click Complete when done — this writes picked.json.
To visually verify your selections, run placer.py (set imagePath to a debug/cropped image and inputFile to picked.json).
Step 3 — Run verification
const { LCDVerifier } = require('@nextmeters/lcd-check');
const verifier = new LCDVerifier();
const results = await verifier.verify({
templateImagePath: 'path/to/template.png',
allOffImagePath: 'path/to/allOff.png',
tests: [
{
imagePath: 'path/to/testImage.png',
pixelData: require('./picked.json'),
},
],
debugPath: 'path/to/debugOutput', // optional
});
// results is an array — one entry per test image
results.forEach(result => {
console.log(result.imagePath, result.passed);
if (!result.passed) {
console.log(result.problemRegions); // array of segments that failed
}
});Each entry in results has:
imagePath— the path of the image that was testedpassed—trueif all segments matched expectationsproblemRegions— array of segments that did not match, each with aproblemMessageand the region's coordinates
Debugging
Passing debugPath to verify() writes intermediate images to that directory:
allOff.png— the cropped baseline (all segments off)cropped.png— the cropped test imagediff.png— pixel diff between baseline and testdiff-gray.png— grayscale diff used for segment analysis
