[general]
name=GeoOSAM
qgisMinimumVersion=3.16
qgisMaximumVersion=3.99
description=AI-powered segmentation for QGIS — SAM2.1 & SAM3 with text prompts, similar object detection, vector ROI, and professional GIS workflow features
about=GeoOSAM brings Meta's SAM 2.1 and SAM3 to QGIS with a streamlined 4-tab UI (Segment, Detect, Results, Filters). Point-click or draw a bounding box on any raster to instantly segment objects. SAM3 users unlock the Detect tab: run text-prompt auto-segmentation ("find all vehicles"), click a reference object to find similar ones across the scene, or use any existing polygon as an exemplar via Similar from Selection. Pro users can run these modes over entire rasters with automatic tiling and restrict processing to a vector polygon ROI. Includes 12 pre-defined classes with color coding, custom class creation, real-world size and shape filters (GSD-based), multi-point segmentation (Shift/Ctrl+click), multi-format export (GeoPackage, Shapefile, GeoJSON), undo support, and persistent output folder. Optimized for NVIDIA GPU, Apple Silicon, and multi-core CPU with automatic hardware detection and model selection.

version=1.4.0
author=Ofer Butbega
email=geoosamplugin@gmail.com

tracker=https://github.com/espressouk/GeoOSAM/issues
repository=https://github.com/espressouk/GeoOSAM
homepage=https://github.com/espressouk/GeoOSAM

# Detailed tags for discoverability
tags=python,segmentation,AI,SAM,SAM2,SAM2.1,SAM2.1_B,Ultralytics,machine learning,deep learning,computer vision,remote sensing,satellite imagery,urban planning,environmental monitoring,geospatial analysis,object detection,semantic segmentation,GPU acceleration,CUDA,Apple Silicon,pytorch,raster analysis,GIS,intelligent model selection,performance optimization

category=Raster
icon=icon.png

# Plugin status
experimental=False
deprecated=False
approved=False

# Server and processing
hasProcessingProvider=no
server=False

# Plugin dependencies and requirements
plugin_dependencies=

# Changelog (REQUIRED for updates)
changelog=1.4.0 - UI Redesign & Workflow Improvements (2026-05-09)
    - NEW: 4-tab flat UI (Segment, Detect, Results, Filters) with Settings as gear overlay
    - NEW: Similar from Selection — use any segmented feature as exemplar
    - NEW: Vector extent ROI for Entire Raster — restrict Pro tiled processing to a polygon area
    - NEW: Cancel and Undo buttons on Detect tab
    - NEW: Find Similar toggleable — click again to exit

    1.3.6 - Code Quality & Security Fixes (2026-04-22)
    - FIXED: Flake8 code quality issues cleared (unused imports, bare excepts, ambiguous names, f-strings)
    - FIXED: Status label color styles now correctly applied (broken f-string in stylesheet)

    1.3.5 - Security Fix (2026-04-22)
    - FIXED: Removed eval from checkpoint download script (flagged by QGIS plugin repository security scanner)
    - FIXED: torch.load now uses weights_only=True (safer checkpoint loading)
    - FIXED: Bandit B310 false positives suppressed on urllib calls using hardcoded https:// URLs
    - FIXED: Removed unused HuggingFace Hub download functions from build_sam.py (dead code in plugin context)
    - FIXED: Excluded dev-only shell scripts and .bat files from plugin package (pb_tool.cfg)
    - FIXED: Removed unused imports flagged by QGIS code quality scanner (F401, F811)
    - FIXED: Ambiguous variable name 'l' renamed (E741)

    1.3.4 - Settings Tab, Size & Shape Filters, GSD Support (2026-04-06)
    - NEW: Tabbed UI — Segmentation and Settings tabs for cleaner layout
    - NEW: GSD / Resolution card with auto-detect from raster metadata and manual entry
    - NEW: Real-world size filtering — min/max diameter (cm) and area (m²) with live pixel hints
    - NEW: Shape filters — min circularity, min compactness, max aspect ratio
    - NEW: Class-level max_size defaults (Vessels: 2000px, Vehicle: 500px)
    - NEW: area_m2, diameter_cm, circularity attributes exported per feature
    - NEW: Per-mask progress bar during text/similar mode processing
    - IMPROVED: Font sizes increased for laptop-screen readability
    - IMPROVED: HTML tooltips with explicit white background (QGIS compatible)
    - IMPROVED: Active filter summary shown inline in status label

    1.3.3 - Multi-Point, Export Formats & Fixes (2026-02-07)
    - NEW: Multi-point segmentation with Shift+click (add) and Ctrl+click (subtract) point accumulation
    - NEW: Visual +/- markers on map showing accumulated positive/negative points
    - NEW: Multi-format export support (GeoPackage, Shapefile, GeoJSON, FlatGeobuf)
    - NEW: GeoPackage as default export format
    - FIXED: License activation connectivity issue
    - FIXED: SAM3 multi-point predictions returning separate objects instead of combined result
    - FIXED: "NoneType has no attribute write" crash on Windows when sys.stderr is None during QGIS startup

    1.3.2 - Bug Fix (2026-02-06)
    - FIXED: MD5 hash security flag (added usedforsecurity=False)

    1.3.1 - Bug Fix (2026-02-06)
    - FIXED: Exemplar mask normalization in SAM3 similar object detection (float masks now correctly scaled to uint8)

    1.3.0 - SAM3 Integration & Pro Licensing (2025-12-28)
    - NEW: SAM3 auto-segmentation ✅ WORKING (tested 2025-12-26)
    - NEW: SAM3 text prompts ✅ WORKING (CLIP tokenizer fixed with runtime patch!)
    - NEW: SAM3 similar object detection ✅ WORKING (CLIP tokenizer fixed!)
    - NEW: SAM3 Pro licensing system with device limits and offline validation
    - NEW: Free tier (extent/AOI) + Pro tier (entire raster) for SAM3 text/similar modes
    - NEW: Cancel button for tiled operations - abort long-running processes anytime
    - NEW: Scope selector (AOI vs full raster) with tiled processing for large rasters
    - NEW: Model selection dropdown with size variants per hardware (GPU/CPU)
    - NEW: SAM3 download flow with Hugging Face token prompt
    - FIXED: CLIP tokenizer bug preventing SAM3 text/exemplar modes (runtime patch applied)
    - FIXED: Similar mode bbox handling and mask result processing
    - FIXED: Threaded tiled processing stability and progress reporting
    - ENHANCED: Automatic model detection and availability checks
    - ENHANCED: Improved UI state updates for model changes

    1.2.2 - Threading Configuration Fix
    - FIXED: PyTorch threading initialization error when other plugins pre-configure threads
    - FIXED: "cannot set number of interop threads" RuntimeError on plugin startup
    - Enhanced thread configuration with graceful fallback for pre-initialized environments
    - Improved compatibility with other PyTorch-based QGIS plugins

    1.2.1 - Online Tile Layer Support
    - NEW: Support for online tile services (XYZ, WMS, WMTS)
    - NEW: Automatic tile caching with proper georeferencing

    1.2.0 - Multi-spectral UAV Support with Comprehensive Object Detection
    - NEW: Native multi-spectral UAV/satellite imagery support (5+ bands)
    - NEW: Automatic NDVI calculation for vegetation detection using NIR/Red bands
    - NEW: Dual processing path - RGB for SAM2, full spectral for vegetation analysis

    1.2.2 - Threading Configuration Fix
    - FIXED: PyTorch threading initialization error when other plugins pre-configure threads
    - FIXED: "cannot set number of interop threads" RuntimeError on plugin startup
    - Enhanced thread configuration with graceful fallback for pre-initialized environments
    - Improved compatibility with other PyTorch-based QGIS plugins

    1.2.1 - Online Tile Layer Support
    - NEW: Support for online tile services (XYZ, WMS, WMTS)
    - NEW: Works with ESRI, Google Satellite, Bing Aerial
    - NEW: Automatic tile caching with proper georeferencing
    
    1.2.0 - Multi-spectral UAV Support with Comprehensive Object Detection
    - NEW: Native multi-spectral UAV/satellite imagery support (5+ bands)
    - NEW: Automatic NDVI calculation for vegetation detection using NIR/Red bands
    - NEW: Enhanced batch processing with up to 100 objects for vegetation
    - NEW: Intelligent shape filtering to reject roads/tracks in vegetation detection
    - NEW: Dual processing path - RGB for SAM2, full spectral for vegetation analysis
    - NEW: Specialized detection helpers for Agriculture, Road, Vehicle, Water, Vessels, and General classes
    - NEW: Non-blocking queue system - submit multiple requests without waiting
    - NEW: Class-specific validation and detection algorithms optimized for each object type
    - FIXED: High-resolution reflectance value preservation (0-1 range) and data type truncation
    - FIXED: SAM2 tensor mismatch errors with multi-spectral input
    - FIXED: Vessels detection shoreline noise with strict size validation (>5000px rejection)
    - FIXED: Oversized mask validation (rejects masks >10%% of image area)
    - FIXED: Crash prevention with robust processing state management
    - FIXED: Shape attribute renamed from 'class_name' to 'class' for consistency
    - FIXED: Mathematical warnings in texture calculation
    - ENHANCED: Vegetation detection with aspect ratio and solidity filtering
    - ENHANCED: Sequential processing with queue status feedback and position tracking
    - ENHANCED: Point and batch mode validation consistency
    - IMPROVED: Comprehensive logging for debugging high-resolution imagery issues
    - IMPROVED: User experience with rapid clicking support and clear status messages
    
    1.1.0 - Major Bug Fixes and GUI Improvements
    - FIXED: Multiple raster layer support - segmentation now works with selected raster layer
    - FIXED: Resolved "point is out of raster bounds" exception with multiple rasters loaded (must be same CRS)
    - FIXED: Panel focus management - controls properly lose focus after use
    - FIXED: Space key no longer re-triggers last clicked button
    - FIXED: Added close/minimize button to control panel header
    - FIXED: Font display issues on Hi-DPI screens
    - FIXED: Enabled bounding box selection mode for rectangular area prompts
    - NEW: Refined GUI with improved user interface design
    - NEW: Flexible panel width for better screen adaptation
    - Enhanced panel layout and control positioning
    - Improved keyboard event filtering and focus handling
    - Better multi-raster workflow support
    - Enhanced user experience with cleaner interface elements
    - Improved cross-platform UI compatibility
    - General stability and usability improvements
    
    1.0.0 - Major Update with Intelligent Model Selection
    - Intelligent model selection: SAM 2.1 for GPU, Ultralytics SAM2.1_B for CPU
    - Exceptional CPU performance: Sub-second segmentation on high-core systems (24+ cores)
    - Enhanced CPU performance with Ultralytics SAM2.1_B integration (5-30x speedup)
    - Automatic device detection (CUDA/Apple Silicon/CPU) with optimal model selection
    - SAM 2.1 support with improved accuracy for small objects and occlusion handling
    - Intelligent threading optimization: High-core CPUs (16+) use 75%% of cores for maximum throughput
    - Multi-threaded processing for responsive UI during inference
    - Point and BBox segmentation modes with adaptive processing
    - 12 pre-defined classes + custom class creation with color coding
    - Vehicle and Ship classes for transportation and maritime analysis
    - Undo functionality for mistake correction with polygon-level tracking
    - Custom output folder selection with user-configurable paths
    - Optional debug mask saving (disabled by default for performance)
    - Automatic raster layer re-selection for streamlined workflow
    - Professional shapefile export with detailed attributes and metadata
    - Performance optimization based on zoom level and hardware capabilities
    - Comprehensive error handling and user feedback system
    - Professional workflow features optimized for GIS analysis
    - Updated dependencies: torch, torchvision, ultralytics, opencv-python, rasterio, shapely, hydra-core
    - Automatic model downloading: Ultralytics handles SAM2.1_B, plugin manages SAM 2.1.
    - Enhanced memory management and processing efficiency
    - Cross-platform compatibility with Windows, macOS, and Linux

# Update and support information
update_date=2026-05-09
