Skip to main content

13 posts tagged with "python"

View All Tags

Python urllib urlopen timeout Not Working on Windows: Fixing socket.getaddrinfo DNS Hangs

· 7 min read
Jaybee
AI & Robotics Engineer

While running a batch crawler across 194 official legal and government portals on Windows 11 (Python 3.12.6), our script froze completely on the 14th URL. Even though every request explicitly passed timeout=8 to urllib.request.urlopen and set socket.setdefaulttimeout(8) at startup, the process hung for over three minutes without raising TimeoutError or urllib.error.URLError.

This post documents the exact stack trace when interrupting the hang, why urllib.request.urlopen and requests.get timeouts fail during Windows socket.getaddrinfo DNS resolution, the three workarounds that failed first, and the production fix that brought batch execution down from an indefinite hang to a deterministic 4-second ceiling per host.

Air Combat Replanning #3: Deterministic JCS & Ed25519 Frag Fix

· 11 min read
Jaybee
AI & Robotics Engineer

This is the third installment in the engineering series on the Air Combat Dynamic Mission Replanning System (SDC). In the previous episode, Air Combat Mission Replanning #2: Stack Spike & Doctrine, we validated the technology stack spike against 6 criteria and structured the operational threat matrix (T1T12) and system bottleneck hypotheses (H1H9) grounded in the ROK 2022 Defense White Paper.

This article documents the engineering work conducted on October 24, 2026, focusing on the M6 messaging and cryptographic security core engine. We address the challenges of ensuring reliable, tamper-proof state synchronization between ground Command & Control (C2) nodes and airborne fighters (F-16C, F-15K) over tactical data links (Link 16). We detail our zero-dependency implementation of RFC 8785 JSON Canonicalization Scheme (JCS) to eliminate cross-runtime (.NET/C# vs CPython) floating-point drift, our raw wire-byte Ed25519 multi-signature envelope architecture, and our resolutions for Defect A-01 (0.7 KB small envelope fragmentation failure) and Defect B-05 (signed delta benchmark distortion).

Episode 3 Cover Diagram Figure 1: RFC 8785 deterministic JCS canonical hashing pipeline, Ed25519 raw wire-byte cryptographic envelope, and Link 16 MTU fragmentation architecture.

Air Combat Mission Replanning #2: Stack Spike & Doctrine

· 12 min read
Jaybee
AI & Robotics Engineer

This is the second installment in the engineering series on the Air Combat Dynamic Mission Replanning System (SDC). In the previous episode, Air Combat Mission Replanning #1: Architecture & KLM Analysis, we established the multi-tier distributed architecture, overcame the CPython 14.5s latency barrier, optimized GPU memory to 0.80 GB, and numerically validated the F-16C fuel integration model via 4th-order Runge-Kutta (RK4).

This article documents the engineering facts from October 23, 2026, when we conducted Technology Stack Spike (a) to de-risk core feasibility before full distributed prototype implementation. We present the verification of 6 quantitative pass criteria, along with the formulation of Operational Threat Situations (T1~T12) and System Bottleneck Hypotheses (H1~H9) derived from official doctrine analysis.

Episode 2 Cover Diagram Figure 1: Architectural overview of Stack Spike (a) verification metrics and the ROK 2022 Defense White Paper-grounded T1~T12 operational threat matrix.

[Vision AI] Korean ANPR OCR Engine, Regex Normalization & Temporal Majority Voting (v01 to v11 Evolution) (#5)

· 3 min read
Jaybee
AI & Robotics Engineer

Temporal Majority Voting and Final Confirmation

📌 Key Takeaways (TL;DR)

  • Problem: Single-frame OCR inevitably suffers from transient misreadings (e.g., 64아1511, 24가1511) due to vehicle yaw, glare, and vibration.
  • Solution: Implemented Korean plate regex validation (^\d{2,3}[가-힣]\d{4}$) coupled with a temporal sliding window majority voting engine across a 7-frame buffer (plate_confirm_threshold=3).
  • Result: Advanced through 11 system iterations (v01 to v11), transitioning from initial gibberish (ACCIIXOY-1Z01...) on June 5 to deterministic confirmation of 64가1511 on June 7 with 99.4% reliability.

[Vision AI] Overcoming Blurry Blackbox Artifacts: Deep Super-Resolution (EDSR vs FSRCNN) & Multi-Frame Image Stacking (#4)

· 3 min read
Jaybee
AI & Robotics Engineer

EDSR Deep Super-Resolution Results

📌 Key Takeaways (TL;DR)

  • Problem: Cropped license plates from dashcam footage often measure under 40x20 pixels with heavy H.264 macroblocking; standard bicubic interpolation fails to resolve character contours.
  • Solution: Integrated EDSR_x4 deep residual networks (EDSR_x4.pb) that omit batch normalization to preserve dynamic range, combined with temporal multi-frame image stacking across 3 to 5 consecutive frames.
  • Result: Quadrupled plate pixel density and sharpened stroke edges, lifting downstream EasyOCR accuracy on Korean characters from 32% to over 91%.

[Vision AI] Hierarchical Object Detection: YOLOv3 Vehicle ROI, YOLOv5 Plate Detector & CSRT Tracking (#3)

· 3 min read
Jaybee
AI & Robotics Engineer

YOLOv5 Plate Detection Localization

📌 Key Takeaways (TL;DR)

  • Problem: Searching for tiny plates (30x15 pixels) across the raw 640x480 frame generates massive false positives from roadside signs and drops inference speed below 10 FPS.
  • Solution: Designed a two-stage hierarchical architecture: broad vehicle detection (YOLOv3-tiny) crops the vehicle ROI, within which a fine-tuned YOLOv5 (lp_det.pt, conf=0.6) locates the license plate. Integrated OpenCV CSRT correlation filter tracking with a 15-frame redetection interval.
  • Result: Eliminated 98% of background false positives and slashed GPU overhead by 80%, sustaining real-time 50+ FPS continuous tracking.

[Vision AI] Dynamic Lane Boundary Extraction & Geometric IoU Intrusion Criterion (#2)

· 4 min read
Jaybee
AI & Robotics Engineer

Dynamic Lane Detection Overlay

📌 Key Takeaways (TL;DR)

  • Problem: Dashcam footage contains heavy pavement specular reflection, tar cracks, and road shadows that induce false lane lines; simple coordinate checking cannot reliably catch the exact moment of lane encroachment.
  • Solution: Implemented vanishing-point trapezoidal ROI masking, slope thresholding (|slope| > 0.5), and a 7-frame temporal moving average queue. Formulated intrusion as geometric IoU between vehicle tire footprints and lane boundaries.
  • Result: Filtered out >95% of road texture noise while capturing vehicle lane crossing events with sub-frame accuracy.

[Vision AI] Blackbox Lane Intrusion & Super-Resolution ANPR: 6-Stage End-to-End Pipeline & Real-Time Constraints (#1)

· 4 min read
Jaybee
AI & Robotics Engineer

6-Stage ANPR Pipeline Diagram

📌 Key Takeaways (TL;DR)

  • Problem: Low-resolution dashcam footage suffers from severe vehicle vibration, nighttime backlighting, and heavy motion blur, making direct license plate recognition and lane violation tracking extremely error-prone.
  • Solution: Designed a unified 6-stage vision architecture: Canny/Hough lane extraction -> YOLOv3 vehicle detection -> polygon IoU lane violation calculation -> YOLOv5 plate localization -> EDSR_x4 super-resolution -> EasyOCR temporal voting.
  • Result: Constructed an end-to-end Python pipeline achieving robust vehicle tracking and lane boundary monitoring even under degraded dashcam conditions.

Sim-to-Real RL: Webots to Arduino with ArUco Vision Tracking (#5)

· 6 min read
Jaybee
AI & Robotics Engineer

ArUco Marker Vision Tracking

📌 Key Takeaways (TL;DR)

  • Problem: Severe computational constraints on microcontrollers (Arduino Uno ATmega328P with only 2KB SRAM), non-linear wheel slip, noisy ultrasonic sensing, and the classical Reality Gap between Webots simulation physics and physical hardware.
  • Solution: Designed a distributed I/O architecture (HC-06 Bluetooth at 115,200 baud) where a host PC runs OpenCV vision processing and Q-Table inference while the Arduino handles low-level PWM motor actuation. Overhead camera lens distortion correction and ArUco marker homography (vision.py) deliver sub-centimeter real-time (x, y, θ) tracking.
  • Result: Zero-shot transfer of the simulation-trained 648-state Q-Table achieved an 86.7% target reaching success rate (26/30 trials) in a physical 1.2m × 1.2m arena, successfully closing the reality gap without real-world fine-tuning.

[Webots Robotics] Deterministic Evaluation via evaluate_qlearning & Benchmark vs. DQN and SARSA (#4)

· 4 min read
Jaybee
AI & Robotics Engineer

Success and Steps Benchmark

📌 Key Takeaways (TL;DR)

  • Objective: Measure the pure, deterministic performance of the learned greedy policy (ε=0) without exploration noise, validating real-world deployability.
  • Methodology: Implemented evaluate_qlearning.py running 30 independent trials across 5 round-robin evaluation seeds, rigorously tracking success rates, path efficiency vs. theoretical shortest routes, and obstacle near-miss counts.
  • Result: Tabular Q-Learning attained a 93.3% deterministic success rate in the 12-wall arena with superior path smoothness and ultra-low 0.02ms inference latency, outperforming heavier DQN and SARSA baselines.

[Webots Robotics] Conquering Local Minima in 12-Wall Obstacles: Multi-Seed Headless Simulation (#3)

· 4 min read
Jaybee
AI & Robotics Engineer

obstacle12 Simulation Arena

📌 Key Takeaways (TL;DR)

  • Problem: When a goal lies directly behind an obstacle, the myopic nature of distance-delta rewards (+0.1 × Δdist) pulls the robot into head-on collisions, trapping it in severe Local Minima.
  • Solution: Integrated 3-way head-scan obstacle perception (front/left/right) with long-horizon Bellman value propagation (γ=0.99), alongside an automated PowerShell Webots Headless pipeline (headless_run.ps1) executing multi-seed training across seeds 0, 1, and 2.
  • Result: The agent successfully learned robust detour policies in the 12-wall arena, achieving a 90%+ goal success rate after 600 episodes.

[Webots Robotics] Tabular Q-Learning Implementation & Reward Shaping Tuning (#2)

· 5 min read
Jaybee
AI & Robotics Engineer

Training Reward Curve

📌 Key Takeaways (TL;DR)

  • Problem: Sparse reward setups (+1.0 at goal, -1.0 at collision) cause severe exploration delays, causing the agent to wander or spin for thousands of episodes before stumbling upon the target.
  • Solution: Implemented a multi-objective Dense Reward Shaping mechanism combining potential-based Euclidean distance delta rewards (+0.1 × Δdist) with step (-0.01), turning (-0.01), and backward (-0.05) penalties, paired with exponential epsilon decay (1.0 → 0.05).
  • Result: The moving average reward shifted into a steady positive regime (0.7+) within 500 episodes in the no_obstacle scenario, achieving a 98%+ goal success rate.

[Webots Robotics] Q-Learning Autonomous Navigation: 648-Bin State Discretization & Socket Architecture (#1)

· 4 min read
Jaybee
AI & Robotics Engineer

Webots Simulation Environment

📌 Key Takeaways (TL;DR)

  • Problem: Continuous sensor readings (distance & heading) cause a state-space explosion for tabular Q-learning, and synchronous IPC with the Webots simulator requires low-latency coordination.
  • Solution: Designed a geometrically partitioned 5-dimensional continuous sensor mapper producing 3 × 8 × 3 × 3 × 3 = 648 discrete states (discretizer.py) and a line-delimited JSON IPC socket pipeline over TCP port 5000.
  • Result: Achieved O(1) fast Q-Table indexing and reliable 32ms physics synchronization between the simulator and Python agent.