| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- import matplotlib.pyplot as plt
- import matplotlib.patches as patches
- import numpy as np
- fig, ax = plt.subplots(figsize=(11, 9))
- fig.patch.set_facecolor('#1a1a2e')
- ax.set_facecolor('#1a1a2e')
- ax.set_xlim(490, 560)
- ax.set_ylim(380, 590)
- ax.set_aspect('equal')
- ax.invert_yaxis()
- plt.tight_layout()
- # Colors
- BBOX_COLOR = '#4a90d9'
- WALL_COLOR = '#e94560'
- INT_COLOR = '#50fa7b'
- EXP_COLOR = '#f1fa8c'
- EP_COLOR = '#ff79c6'
- OTHER = '#555'
- # Other walls
- other_segs = [
- [[420,266],[420,360]], [[420,360],[537,360]], [[537,360],[537,266]],
- [[458,424],[509,424]], [[509,424],[698,424]], [[698,424],[698,379]],
- [[740,379],[740,266]], [[740,266],[560,266]], [[560,266],[560,304]],
- [[560,304],[537,304]], [[537,304],[537,360]], [[537,360],[458,360]],
- [[458,360],[458,424]],
- ]
- for s in other_segs:
- ax.plot([s[0][0], s[1][0]], [s[0][1], s[1][1]], color=OTHER, linewidth=1.5, alpha=0.5)
- # Target segment
- ax.plot([521, 521], [424, 575], color=WALL_COLOR, linewidth=3, label='Wall seg50 (x=521, y=424->575)')
- # Door bbox
- rect = patches.Rectangle((515, 399), 12, 38, linewidth=2, edgecolor=BBOX_COLOR, facecolor=(0.29, 0.56, 0.85, 0.2), label='Door bbox (12x38px)')
- ax.add_patch(rect)
- # Expand +10px
- rect_exp = patches.Rectangle((505, 389), 32, 58, linewidth=1.5, edgecolor=EXP_COLOR, facecolor=(0.945, 0.98, 0.545, 0.08), linestyle='--', label='expand +10px')
- ax.add_patch(rect_exp)
- # Intersection
- ax.plot(521, 437, 'o', markersize=10, color=INT_COLOR, label='Intersection (only 1)')
- ax.annotate('(x=521, y=437)', xy=(521, 437), xytext=(540, 445),
- fontsize=10, color=INT_COLOR,
- arrowprops=dict(arrowstyle='->', color=INT_COLOR))
- # Endpoint
- ax.plot(521, 424, 'o', markersize=10, color=EP_COLOR, label='Seg endpoint (inside bbox)')
- ax.annotate('(x=521, y=424)', xy=(521, 424), xytext=(540, 418),
- fontsize=10, color=EP_COLOR,
- arrowprops=dict(arrowstyle='->', color=EP_COLOR))
- # Arrow from endpoint to bottom edge
- ax.annotate('', xy=(521, 437), xytext=(521, 424),
- arrowprops=dict(arrowstyle='<->', color=EP_COLOR, lw=1.5))
- ax.text(503, 430, '13px\ngap', fontsize=9, color=EP_COLOR, ha='center', va='center')
- # Dimension labels
- ax.plot([513, 513], [399, 437], color=EXP_COLOR, linewidth=1)
- ax.text(510, 418, '38px', fontsize=9, color=EXP_COLOR, ha='center', va='center', rotation=90)
- ax.plot([515, 527], [440, 440], color=EXP_COLOR, linewidth=1)
- ax.text(521, 445, '12px', fontsize=9, color=EXP_COLOR, ha='center', va='top')
- ax.text(521, 394, 'top edge y=399', fontsize=9, color=BBOX_COLOR, ha='center')
- ax.text(521, 456, 'bottom edge y=437', fontsize=9, color=BBOX_COLOR, ha='center')
- # Wall annotation
- ax.text(518, 560, 'Seg enters bbox\nfrom top edge\nendpoint stops at\ny=424 (inside)', fontsize=9, color=WALL_COLOR, ha='right', va='bottom',
- bbox=dict(boxstyle='round,pad=0.3', facecolor=(0.914, 0.271, 0.376, 0.1), edgecolor=WALL_COLOR))
- # Summary
- summary = (
- 'Door 21: Projection Fallback Case\n\n'
- 'Wall enters bbox from top, endpoint inside bbox\n'
- 'Intersection detection: only 1 point\n'
- 'expand +10px: still only 1 point\n\n'
- 'Result: falls back to projection\n'
- ' - Project door center to wall\n'
- ' - Use bbox long edge = 38px = 0.76m\n'
- ' - Generate door line along wall direction\n\n'
- 'This is correct fallback behavior, door size is OK'
- )
- ax.text(0.5, 0.02, summary, transform=ax.transAxes, fontsize=10,
- color='#e0e0e0', ha='center', va='bottom',
- bbox=dict(boxstyle='round,pad=0.5', facecolor=(0.29, 0.56, 0.85, 0.1), edgecolor='#4a90d9'))
- ax.set_title('Door 21: Segment Endpoint Inside Bbox -> Projection Fallback', fontsize=14, color='#e94560', pad=20)
- ax.legend(loc='upper right', fontsize=9, facecolor='#1a1a2e', edgecolor='#555')
- plt.savefig('/media/dage/KESU/temp/floorplan/fallback_analysis.png', dpi=150, bbox_inches='tight',
- facecolor='#1a1a2e', edgecolor='none')
- plt.close()
- print('Saved to fallback_analysis.png')
|