- Add scan-to-plant flow: upload card photos, OCR, VPC match on confirm form - OpenCV CLAHE + adaptive threshold preprocessing; dual psm 6/11 OCR pass - Regex fixes for OCR misreads: height (s→5), frost (=,„,i,l,G), density, bloom months (E→I) - Scientific name extraction: passport section + cultivar quote strategy - Last-wins merge so back card data overrides front card garbage - Crop thumbnail tool with Cropper.js; cropped image shown in list and detail - VPC image always supersedes user thumbnail on detail page - VPC sunlight mapping: zon→full_sun, halfschaduw→part_sun, schaduw→full_shade - Auto-set thumbnail on plant created from scan Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
63 lines
1.4 KiB
Python
63 lines
1.4 KiB
Python
from plants.services.card_ocr import parse_card_text
|
|
|
|
# Simulated OCR output matching the Veronicastrum card back
|
|
_SAMPLE_TEXT = """
|
|
ELBURG SMIT
|
|
G1L-901126
|
|
|
|
Veronicastrum
|
|
virg. 'Red Arrows'
|
|
|
|
Virginische Ereprijs, Kandelaber-Ehrenpreis,
|
|
Culver's root, Grande veronique, Kransveronika
|
|
|
|
VII-VIII
|
|
|
|
7/m2 120 cm
|
|
|
|
-20 oC
|
|
|
|
Bijenlokker
|
|
Plant that attracts bees
|
|
"""
|
|
|
|
|
|
def test_scientific_name():
|
|
result = parse_card_text(_SAMPLE_TEXT)
|
|
assert result['scientific_name'] is not None
|
|
assert 'Veronicastrum' in result['scientific_name']
|
|
|
|
|
|
def test_bloom_months():
|
|
result = parse_card_text(_SAMPLE_TEXT)
|
|
assert result['bloom_months'] == [7, 8]
|
|
|
|
|
|
def test_height():
|
|
result = parse_card_text(_SAMPLE_TEXT)
|
|
assert result['max_height_cm'] == 120
|
|
|
|
|
|
def test_frost_hardiness():
|
|
result = parse_card_text(_SAMPLE_TEXT)
|
|
assert result['frost_hardiness_c'] == -20
|
|
|
|
|
|
def test_planting_density():
|
|
result = parse_card_text(_SAMPLE_TEXT)
|
|
assert result['planting_density_m2'] == 7
|
|
|
|
|
|
def test_bee_attractant():
|
|
result = parse_card_text(_SAMPLE_TEXT)
|
|
assert result['bee_attractant'] is True
|
|
|
|
|
|
def test_empty_text():
|
|
result = parse_card_text('')
|
|
assert result['scientific_name'] is None
|
|
assert result['bloom_months'] == []
|
|
assert result['max_height_cm'] is None
|
|
assert result['frost_hardiness_c'] is None
|
|
assert result['planting_density_m2'] is None
|
|
assert result['bee_attractant'] is False
|