How ildaron/laser_control works
Project type and purpose
• This is an embedded computer-vision & control system.
• Purpose: detect objects (mosquitoes, weeds, cockroaches) via camera(s), compute their 3D position, convert that into galvanometer mirror angles, and steer a (low-power) laser pointer to neutralize or mark the target.
File structure – main directories
• 1.Motor_driver: electrical schematics for the galvanometer driver boards.
• 2.Jetson_code/2.1_mirror_control: Python SPI code (mcp4922 DAC) to drive the analog mirror controller.
• 3.YoloV4: scripts for object detection (YOLOv4-tiny) on video streams.
• 7.Darknet: build and configure Darknet (including TensorRT) for optimized inference.
README – architecture clues
• Cameras → digital video input → onboard SBC (Raspberry Pi or Jetson Nano)
• Two processing paths:
a) X,Y detection via deep learning (YOLOv4-tiny)
b) Z (depth) via stereo vision
• Coordinate fusion → compute required mirror angles α (using geometric formulas)
• Control path: SPI → MCP4922 DAC → amplifier → galvanometer driver boards → galvanometer mirrors → laser beam direction
• Safety & future modules: human detection, audio sensors, uplink/downlink over Wi-Fi.
Sketch the system’s main components
a. Hardware layer
• Stereo Cameras (left + right)
• Jetson Nano / Raspberry Pi SBC
• SPI interface → MCP4922 DAC
• Analog amplifier board → ±12 V outputs
• Galvanometer driver boards → galvanometer mirrors
• Laser pointer module
• Power supply unit
• (Optional) Security sensors: additional cameras, audio, thermal
b. Software & processing layer
• Video capture & pre-processing (OpenCV)
• Object detection module (YOLOv4-tiny / Darknet)
• Stereo-vision module (depth map & Z calculation)
• Coordinate fusion & angle computation
• Mirror control module (DAC SPI commands)
• Laser control trigger
• Configuration & calibration scripts (My_project)
c. Optional / future/external services
• Remote control UI (over Wi-Fi)
• PC-hosted detection service
• PCB-based galvanometer controller
Relationships & data flow
1. Stereo Cameras capture frames →
2. SBC runs two parallel pipelines:
– Stereo depth calculation → Z
3. Fusion module combines (X,Y,Z) → computes mirror angles αx, αy
4. Mirror control module sends SPI commands to MCP4922 → generates analog voltages
5. Amplifier board ups voltages to ±12 V → galvanometer driver boards
6. Galvanometers tilt mirrors → laser beam directed at target
7. Laser module is (optionally) triggered on target lock
8. Feedback loop: cameras continuously monitor and update target position
Architectural patterns & design principles
• Layered design: separates sensor I/O, CV/ML, control, and hardware actuation
• Modular code: distinct folders for detection (YoloV4), control (Jetson_code), hardware specs (Motor_driver)
• Parallel processing: simultaneous inference & depth mapping
• Hardware-in-the-loop: real-time SPI control of analog electronics
Technologies, frameworks & libraries
• Python + OpenCV for image capture & stereo vision
• Darknet (C/C++), TensorRT, tkDNN for YOLOv4-tiny inference
• SPI Python bindings for MCP4922 DAC
• NumPy for depth / ROI averaging
• Makefiles & custom cfg for model build (in Darknet/my_files)
• Digital processing (blue)
• Control / SPI (green)
• Analog / power (orange)
• Laser / actuation (red)
– Annotations for protocols/interfaces (e.g., “SPI,” “USB,” “GPIO,” “I2C”).
– Optional side-blocks for safety modules or remote UI pointing to the central SBC.