How hibrahimboz/leafvision works
LeafVision is a single-image leaf-boundary segmentation application: a user uploads an image through the web interface, the FastAPI endpoint passes it to the C++ OpenCV pipeline, and the interface receives the seven visualized stages. The graph preserves the documented processing stages and API/UI flow. Source excerpts do not show the HTML’s request handling, so that connection is based on the README; unimplemented roadmap capabilities are excluded.
Main entry points: server.py FastAPI service · index.html Upload interface · leaf_boundary.cpp Python binding
Components 15
Web client
- Upload interface
src/api/static/index.html
API service
- FastAPI service
src/api/server.py - Image decoding
src/api/server.py - Temporary image
src/api/server.py - JPEG encoding
src/api/server.py - Pipeline response
src/api/server.py
Segmentation engine
- Python binding
src/core/leaf_boundary.cpp - Original image
src/core/leaf_boundary.cpp - Color mask
src/core/leaf_boundary.cpp - Cleaned mask
src/core/leaf_boundary.cpp - Distance map
src/core/leaf_boundary.cpp - Foreground seeds
src/core/leaf_boundary.cpp - Watershed markers
src/core/leaf_boundary.cpp - Final boundaries
src/core/leaf_boundary.cpp
Other components
- Image user
Connections 16
- Image user → Upload interface: selects image
- Upload interface → FastAPI service: uploads image
- FastAPI service → Image decoding: reads upload
- Image decoding → Temporary image: writes JPEG
- FastAPI service → Python binding: calls process_leaf
- Python binding → Original image: reads image
- Original image → Color mask: extracts color
- Color mask → Cleaned mask: thresholds and cleans
- Cleaned mask → Distance map: computes distance
- Distance map → Foreground seeds: derives foreground
- Foreground seeds → Watershed markers: builds markers
- Watershed markers → Final boundaries: runs watershed
- FastAPI service → JPEG encoding: encodes pipeline
- JPEG encoding → Pipeline response: builds response
- FastAPI service → Pipeline response: returns JSON
- Pipeline response → Upload interface: displays stages