name: analyze_evidence description: Analyze dental X-ray images to detect teeth, pathologies, and estimate age/gender.
Analyze Evidence Skill
Use this skill to perform forensic analysis on dental X-ray images. This involves detecting teeth (FDI notation), identifying pathologies, and estimating biological profile (age/gender).
Dependencies
DentalID.Core.Interfaces.IAiPipelineService(The AI Engine)DentalID.Application.Services.ForensicAnalysisService(High-level orchestration)DentalID.Core.DTOs.AnalysisResult(The output format)
Workflow
Validate Input:
- Ensure the file is a supported image format (
.png,.jpg,.bmp,.dcm). - SECURITY: Do NOT pass file paths directly to the AI engine if possible. Open a
FileStream(Read-only) and pass theStream. This ensures file locks and prevents race conditions.
- Ensure the file is a supported image format (
Run Analysis:
- Call
IAiPipelineService.AnalyzeImageAsync(stream). - Note: This method is computationally expensive.
- Call
Interpret Results:
- Teeth: Check
AnalysisResult.Teeth. - Pathologies: Check
AnalysisResult.Pathologies. - Demographics: Check
EstimatedAgeandEstimatedGender.
- Teeth: Check
Advanced: Batch Processing:
- When processing multiple images (e.g., a full case folder), use
Task.WhenAllto maximize CPU/GPU usage. - Memory Warning: Process in chunks of 5-10 images to avoid OutOfMemory exceptions on standard laptops.
- When processing multiple images (e.g., a full case folder), use
Error Recovery:
- Low Confidence: If
Teeth.Count < 5, the image might be blurry.- Action: Apply
Histogram Equalization(using OpenCV/Skia) and retry.
- Action: Apply
- Upside Down: If
11is found at the bottom of the image.- Action: Rotate 180 degrees and retry.
- Low Confidence: If
Example Usage (C#)
using DentalID.Core.Interfaces;
using DentalID.Core.DTOs;
public async Task<AnalysisResult> PerformForensicAnalysis(string imagePath, IAiPipelineService aiService)
{
// 1. Secure Open
using var stream = File.OpenRead(imagePath);
// 2. Analyze with Retry Logic
try
{
return await aiService.AnalyzeImageAsync(stream);
}
catch (Exception ex)
{
Console.WriteLine($"[Error] First pass failed: {ex.Message}. Retrying with enhancement...");
// TODO: call ImagePreprocessor.Enhance(stream)
return await aiService.AnalyzeImageAsync(stream); // Retry
}
}
Troubleshooting
- Zero Teeth Detected: The image might be upside down or have massive artifacts. Try
DentalID.Core.Utilities.ImagePreprocessor.EnhanceContrast. - "Model Not Found": Ensure the
models/directory containsteeth_detect.onnxandpathology_detect.onnx.