Files
boc/iom/visual_geolocation/test_bangkok.py
T
Bernt bae705aa97 ARCHITECTURE: NFC roadmap, edge AI, audit logging
- Add NFC ePassport roadmap (ICAO 9303, eIDAS)
- Add TensorFlow.js edge face detection (BlazeFace)
- Add structured audit logger (GDPR-compliant)
- Risk scoring support

Part of KYC Apple Native UX v1.1.0
2026-06-29 16:24:48 +00:00

250 lines
7.4 KiB
Python

"""
Test Visual Geolocation with Bangkok Data
Simulate Erik's Bangkok images
"""
import sys
sys.path.insert(0, '/home/bernt/.openclaw/workspace/iom')
from visual_geolocation.pipeline import VisualGeolocationPipeline
from visual_geolocation.evidence_extractor import (
EvidencePackage, ImageMetadata, VisualObject,
TextDetection, GeometricFeature, EnvironmentalSignal
)
from visual_geolocation.geolocation_engine import GeolocationEngine
from visual_geolocation.confidence_model import ConfidenceModel
from datetime import datetime
def create_bangkok_evidence():
"""Create evidence package for Bangkok image"""
# Metadata from Bangkok image
metadata = ImageMetadata(
gps_lat=13.7563,
gps_lng=100.5018,
altitude=10.0,
compass_heading=90.0, # East-facing
pitch=5.0,
roll=2.0,
timestamp="2026-06-26T20:00:00Z", # Night time
camera_model="iPhone15,2",
focal_length=24.0,
exposure=0.033, # 1/30s
aperture=1.78,
iso=1600
)
# Visual objects detected
visual_objects = [
VisualObject(
label="street_light",
confidence=0.85,
bbox=[100, 50, 150, 400],
attributes={"type": "LED", "color": "white"}
),
VisualObject(
label="building",
confidence=0.92,
bbox=[200, 100, 500, 400],
attributes={"type": "commercial", "floors": 5}
),
VisualObject(
label="car",
confidence=0.78,
bbox=[50, 300, 200, 450],
attributes={"type": "sedan", "color": "white"}
),
VisualObject(
label="sign",
confidence=0.88,
bbox=[300, 50, 450, 150],
attributes={"type": "commercial", "illuminated": True}
)
]
# Semantic objects
semantic_objects = [
VisualObject(
label="street_view",
confidence=0.95,
bbox=[0, 0, 640, 480],
attributes={"type": "scene", "lighting": "night"}
),
VisualObject(
label="commercial_area",
confidence=0.82,
bbox=[0, 0, 640, 480],
attributes={"type": "zone", "density": "high"}
)
]
# OCR text detections
text_detections = [
TextDetection(
text="Sukhumvit Road",
confidence=0.92,
bbox=[50, 50, 250, 100],
language="en",
text_type="street_name"
),
TextDetection(
text="Sainokuni",
confidence=0.88,
bbox=[300, 60, 450, 120],
language="ja",
text_type="business_name"
),
TextDetection(
text="MASSAGE",
confidence=0.85,
bbox=[500, 80, 600, 130],
language="en",
text_type="business_name"
),
TextDetection(
text="Bangkok 10110",
confidence=0.90,
bbox=[50, 400, 200, 450],
language="en",
text_type="postal_code"
)
]
# Geometric features
geometric_features = [
GeometricFeature(
feature_type="horizon_line",
coordinates=[0, 240, 640, 240],
confidence=0.70
),
GeometricFeature(
feature_type="vanishing_point",
coordinates=[320, 200],
confidence=0.65
),
GeometricFeature(
feature_type="camera_height_estimate",
coordinates=[1.6], # meters
confidence=0.60
)
]
# Environmental signals
environmental_signals = [
EnvironmentalSignal(
signal_type="lighting",
value={
"type": "artificial",
"sources": ["street_light", "commercial_signs"],
"brightness": "medium",
"is_night": True
},
confidence=0.95
),
EnvironmentalSignal(
signal_type="weather",
value={
"condition": "clear",
"temperature_estimate": 28, # celsius
"humidity_estimate": 80
},
confidence=0.70
),
EnvironmentalSignal(
signal_type="urban_density",
value={
"level": "high",
"building_height": "medium",
"commercial_activity": "high"
},
confidence=0.85
)
]
# Temporal signals
temporal_signals = {
"timestamp": "2026-06-26T20:00:00Z",
"time_of_day": "night",
"season": "summer",
"day_of_week": "Friday",
"is_weekend": False,
"local_time": "03:00", # Bangkok time (UTC+7)
}
# Create evidence package
evidence = EvidencePackage(
image_id="bangkok_001",
timestamp=datetime.now(),
metadata=metadata,
visual_objects=visual_objects,
semantic_objects=semantic_objects,
text_detections=text_detections,
geometric_features=geometric_features,
environmental_signals=environmental_signals,
temporal_signals=temporal_signals
)
return evidence
def test_bangkok_geolocation():
"""Test geolocation with Bangkok evidence"""
print("=" * 60)
print("BANGKOK VISUAL GEOLOCATION TEST")
print("=" * 60)
# Create evidence
evidence = create_bangkok_evidence()
print("\n📸 EVIDENCE PACKAGE")
print(f" Image ID: {evidence.image_id}")
print(f" Timestamp: {evidence.timestamp}")
print(f" Visual objects: {len(evidence.visual_objects)}")
print(f" Semantic objects: {len(evidence.semantic_objects)}")
print(f" Text detections: {len(evidence.text_detections)}")
print(f" Geometric features: {len(evidence.geometric_features)}")
print(f" Environmental signals: {len(evidence.environmental_signals)}")
# Geolocate
print("\n🌍 GEOLOCATION")
engine = GeolocationEngine()
estimate = engine.geolocate(evidence)
print(f" Position: {estimate.lat:.6f}, {estimate.lng:.6f}")
print(f" Accuracy: ±{estimate.accuracy:.1f}m")
print(f" Confidence: {estimate.confidence:.1%}")
print(f" Method: {estimate.method}")
# Confidence
print("\n✅ CONFIDENCE")
model = ConfidenceModel()
report = model.calculate_confidence(estimate, evidence)
print(f" Overall: {report.overall_confidence:.1%}")
print(f" Uncertainty: ±{report.uncertainty_radius:.1f}m")
print(f" Supporting evidence: {len(report.supporting_evidence)}")
for ev in report.supporting_evidence:
print(f" - {ev['type']}: {ev['description']}")
print(f" Contradicting evidence: {len(report.contradicting_evidence)}")
print(f" Unknown factors: {len(report.unknown_factors)}")
for factor in report.unknown_factors:
print(f" - {factor}")
# Summary
print("\n" + "=" * 60)
print("RESULT")
print("=" * 60)
print(f"📍 Bangkok, Sukhumvit Road")
print(f" Position: {estimate.lat:.6f}°N, {estimate.lng:.6f}°E")
print(f" Accuracy: ±{estimate.accuracy:.1f}m")
print(f" Confidence: {report.overall_confidence:.1%}")
print(f" Time: Night (Friday, Summer)")
print(f" Evidence: {len(evidence.visual_objects)} visual + {len(evidence.text_detections)} text")
return estimate, report
if __name__ == '__main__':
test_bangkok_geolocation()