Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lightel DI-2000

A small Python interface for the Lightel DI-2000 USB digital inspector.

The public DI-2000 documentation describes a USB video camera but does not publish a command protocol or SDK. This package therefore uses the operating system's camera driver through OpenCV. It supports camera discovery, connection, frame acquisition, image capture, and standard UVC/OpenCV properties.

Installation

pip install .

For development:

pip install -e ".[dev]"
python -m pytest

Usage

from di2000 import Di2000, find_devices

print("Camera indexes:", find_devices())

inspector = Di2000()
inspector.connect(0)
try:
    frame = inspector.read_frame()
    saved_path = inspector.capture_image("inspection.png")
    print(saved_path)
finally:
    inspector.disconnect()

On Windows, Lightel's installed camera driver may work better through DirectShow:

import cv2
from di2000 import Di2000

with Di2000() as inspector:
    inspector.connect(0, backend=cv2.CAP_DSHOW)
    inspector.capture_image("inspection.png")

Standard camera controls can be attempted through OpenCV:

import cv2

inspector.set_autofocus(True)
inspector.set_property(cv2.CAP_PROP_BRIGHTNESS, 100)
print(inspector.get_property(cv2.CAP_PROP_BRIGHTNESS))

Whether a property works depends on the Lightel driver. The probe's physical one-touch autofocus and capture buttons may use vendor-specific controls that are not publicly documented; this package does not guess those commands.

Finding the right camera

find_devices() returns all camera indexes OpenCV can open, not only Lightel devices. Disconnect other cameras or try each returned index and inspect a frame.

Fiber-end inspection

inspection.py builds on top of a connected Di2000 to bring the fiber end into focus, classify whether the shot is front- or back-illuminated (there is no UVC control to read this from hardware, so it's detected from the image), expose for that mode, and flag dirt/debris.

from di2000 import Di2000
from inspection import inspect

with Di2000() as inspector:
    inspector.connect(0)
    result = inspect(inspector)

print(result.illumination.mode, result.defect_area_fraction, result.passed)

The individual stages (locate_fiber_end, autofocus, classify_illumination, autoexpose, detect_defects) are also usable on their own, and all operate on plain numpy frames so they can be tested without a camera.

GUI

gui.py is a small PySide6 app

pip install -e ".[gui]"
python gui.py
# or, after install: lightel-inspect-gui

About

A driver class for the Lightel DI-2000.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages