Video2Law 如何從影片推導物理定律並找出不可見物體
We taught a laptop to find the laws of physics from a video (and spot things it can't see)
Video2Law 可分析物體擺動影片,自動推導運動方程式、能量公式及摩擦造成的能量流失,並預測後續運動。Neptune Mode 僅憑可見擺錘的運動推算隱藏擺錘,在測試中定位誤差少於半釐米;目前只以模擬影片測試,尚未測試真實手機影片。另有一個可在筆記本電腦 GPU 上全離線運作的 AI 助手,負責操作應用程式,不負責物理推導。
In school, physics always came with the formula first: here is T = 2π√(L/g), now plug in the numbers. A few weeks into B.Tech, my teammate Vinayakan V and I wondered: what if you did it the other way round? What if you just filmed something moving and let the computer work out the formula?
That question became Video2Law, which we built in one day for the Open Scientific Intelligence Hackathon 2026.
What it does
You open a short video of something swinging, and the app:
- finds the equation of motion by itself,
- discovers energy: it searches for the quantity that stays almost constant, and finds the textbook energy formula without us telling it,
- measures the leak: how fast friction drains that energy,
- predicts the future: a "ghost" pendulum runs ahead of the real one, and you can ask "what if this were on the Moon?",
- and our favourite part, Neptune Mode.
Neptune Mode
In the 1840s, Uranus wasn't moving quite the way Newton's laws said it should. Astronomers guessed a hidden planet was pulling on it, calculated where it had to be, and found Neptune.
We wanted to recreate that. In Neptune Mode the camera only sees one pendulum, but it's secretly connected to a second one that's off-screen. Just from the "wrong" wobble of the visible one, the app works out that something hidden is there, and draws it. In our tests it placed the hidden pendulum within half a centimetre while seeing only half of the video.

Before: only the red pendulum is visible. The right half of the video is hidden from the app.

After: the app reveals the hidden blue pendulum it worked out from the red one's motion.
How it works (the simple version)
No neural network does the physics. It's all maths I had half-seen before, used in a new way:
- Track the object in each frame and smooth out the noise.
- Make a list of possible terms (sin θ, cos θ, speed...) and use sparse regression to keep only the few that actually matter. That gives the equation.
- Use SVD (a matrix tool) to find the combination that doesn't change over time. That's energy.
- Solve the equation step by step with RK4 to predict the future.
- For Neptune Mode, look for "extra patterns" in the motion with SVD and an FFT. Extra patterns mean something hidden.
Everything is written in Rust as a native desktop app.
The AI part
We also made a second edition with a built-in AI assistant that runs fully offline on my laptop's GPU (a 4 GB GTX 1650!). You can type or just say "track the red ball and find g", and it clicks the right buttons for you. It can even find the object in the video on its own, no coloured sticker needed.
One rule we kept: the AI never does the physics. It only operates the app and reads back the real numbers. Getting it to stop "pretending" it had done things it hadn't was honestly one of the hardest parts of the day.
What I learned
- Simple maths goes a long way. Least squares and matrices were enough to rediscover a law of physics.
- Always test against a known answer. We made our test videos with a physics engine so we knew the truth, and that's how we caught most of our bugs.
- Be honest about limits. So far we've only tested on simulated videos, not real phone footage. That's the next step.
Try it / see the code
The code is open source here: https://github.com/armangulia29/Video2Law
Huge thanks to my teammate Vinayakan V for building this with me, and to the organisers of the Open Scientific Intelligence Hackathon.
If you're a student who likes physics or coding, I'd love to hear what you'd film first!
來源:DEV Community · dev.to