Arshdeep SinghHow @bongyunng's viral OpenCV demo works — real-time physical object tracking with digital physics simulation. Full code walkthrough + the spatial computing context.
How @bongyunng's viral OpenCV demo works — real-time physical object tracking with digital physics simulation. Full code walkthrough + the spatial computing context.
Inspired by @bongyunng's viral Instagram demo
What if your screen wasn't a window into a digital world — but a surface where digital and physical coexist, interact, and respond to each other in real time?
That's exactly what developer @bongyunng demonstrated in a recent viral reel: a real-time "Block Computing" programme built from scratch that tracks physical objects through a camera feed and bounces digital elements off them — live, frame by frame.
No AR headset. No Unity engine. Just OpenCV, Python, and a deep understanding of how digital and physical can meet.
This post breaks down every concept behind that demo: how real-time object tracking works, how physics simulation is layered on top, and why this sits at the cutting edge of spatial computing in 2026.
The term block computing here refers to treating physical objects as computational blocks — discrete, trackable units that the system processes frame-by-frame. Each physical object becomes a block of data: its position, velocity, bounding box, and surface normal.
The programme computes:
This is fundamentally different from traditional AR, which overlays digital elements. Here, the digital elements have physics awareness — they respond to physical geometry.
OpenCV (Open Source Computer Vision Library) is the backbone. Here's what the pipeline looks like:
Using background subtraction or YOLOv8, the programme identifies physical objects in each frame:
import cv2
bg_subtractor = cv2.createBackgroundSubtractorMOG2()
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
fg_mask = bg_subtractor.apply(frame)
contours, _ = cv2.findContours(fg_mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
for cnt in contours:
if cv2.contourArea(cnt) > 500:
x, y, w, h = cv2.boundingRect(cnt)
cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2)
Once detected, OpenCV's CSRT tracker maintains identity across frames without re-running expensive detection every frame:
tracker = cv2.TrackerCSRT_create()
tracker.init(frame, bounding_box)
# In loop:
success, box = tracker.update(frame)
CSRT = best for accuracy. KCF = best for speed. For multi-object, use DeepSORT.
Key optimizations to hit 30+ FPS:
Tracking is step one. Making digital elements react to physical objects is where it gets interesting.
Each frame:
pos += velocity * dt
velocity = velocity - 2 * dot(velocity, normal) * normal
import numpy as np
def reflect_velocity(velocity, surface_normal):
normal = np.array(surface_normal, dtype=float)
normal = normal / np.linalg.norm(normal)
dot = np.dot(velocity, normal)
return velocity - 2 * dot * normal
ball_velocity = np.array([3.0, -2.0])
surface_normal = np.array([0.0, 1.0]) # upward surface
new_velocity = reflect_velocity(ball_velocity, surface_normal)
# Digital ball with glow effect
cv2.circle(frame, (int(ball_x), int(ball_y)), 15, (0, 100, 255), -1)
overlay = np.zeros_like(frame)
cv2.circle(overlay, (int(ball_x), int(ball_y)), 25, (0, 60, 150), -1)
blurred = cv2.GaussianBlur(overlay, (21, 21), 0)
frame = cv2.addWeighted(frame, 1.0, blurred, 0.6, 0)
This demo is a hands-on proof of concept for the convergence of physical and digital worlds — one of the defining tech trends of 2026.
What's remarkable: this achieves the essence of spatial computing with just a webcam and Python.
| Domain | Use Case |
|---|---|
| Education | Physics simulations with physical desk props |
| Gaming | No-controller games using body + real objects |
| Design | Visualize digital components on physical prototypes |
| Robotics | Navigation pipelines using the same tracking stack |
| Industrial AR | Overlay instructions onto physical machinery |
pip install opencv-python numpy
# Optional for better detection:
pip install ultralytics
import cv2
import numpy as np
ball_pos = np.array([320.0, 100.0])
ball_vel = np.array([4.0, 2.0])
ball_radius = 15
cap = cv2.VideoCapture(0)
bg_sub = cv2.createBackgroundSubtractorMOG2(history=500, varThreshold=50)
while True:
ret, frame = cap.read()
if not ret: break
h, w = frame.shape[:2]
fg = bg_sub.apply(frame)
fg = cv2.morphologyEx(fg, cv2.MORPH_OPEN, np.ones((5,5), np.uint8))
contours, _ = cv2.findContours(fg, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
obstacles = []
for cnt in contours:
if cv2.contourArea(cnt) > 1000:
x, y, cw, ch = cv2.boundingRect(cnt)
obstacles.append((x, y, x+cw, y+ch))
cv2.rectangle(frame, (x,y), (x+cw, y+ch), (0,255,0), 2)
# Update physics
ball_pos += ball_vel
if ball_pos[0] <= ball_radius or ball_pos[0] >= w - ball_radius: ball_vel[0] *= -1
if ball_pos[1] <= ball_radius or ball_pos[1] >= h - ball_radius: ball_vel[1] *= -1
# Obstacle collision
for (x1, y1, x2, y2) in obstacles:
bx, by = int(ball_pos[0]), int(ball_pos[1])
if x1 - ball_radius < bx < x2 + ball_radius and y1 - ball_radius < by < y2 + ball_radius:
ball_vel[1] *= -1
cv2.circle(frame, (int(ball_pos[0]), int(ball_pos[1])), ball_radius, (0, 100, 255), -1)
cv2.imshow('Block Computing', frame)
if cv2.waitKey(1) & 0xFF == ord('q'): break
cap.release()
cv2.destroyAllWindows()
From here, layer in YOLOv8 for precise detection, multiple physics objects, surface normal estimation with depth sensors, and GPU rendering via OpenGL.
@bongyunng's demo is more than a cool visual trick. It's a proof of concept for accessible spatial computing — you don't need a $3,500 headset to make digital and physical worlds interact meaningfully.
With OpenCV, Python, and physics simulation, you can build systems where the digital world knows about the physical world and responds in real-time.
Start with a webcam. Start with OpenCV. Start with a bouncing ball.
Written by Arshdeep Singh