Virostatiq

Visualization, language and culture

They Vote: how the Ljubljana They Live trailer was made

At the time of this writing, we are preparing for a referendum about the “Development Act”, or “Intervention Act”, as proposed by the government. I won’t go into details, but the opposition is calling it a “Law for the Rich”. As such, it should be opposed.

Personally, I would profit from the law. A lot. But I see it as unacceptable due to incomplete disclosure of the real tax burden and budget effects, and because it’s quite an overt overt attempt to transform the society into something I would not like. Again, I won’t go into details, as this is a technical post.

The motivation for the artwork below are incessant lies, manipulations, arrogance and obscurantism on the government side, so I wanted to create a small contribution in the campaign Against.

The finished trailer, 44 seconds, 720p. Original footage in colour; “glasses on” in black and white.

The effect, and why it is harder than it looks

In John Carpenter’s They Live (1988), a drifter finds a pair of sunglasses that show the world as it really is: billboards, magazines and shop signs turn into stark black-and-white commands such as OBEY, CONSUME and STAY ASLEEP. The trailer above does the same to ordinary phone videos shot on the streets of Ljubljana. Every advertising surface the camera passes, whether a printed citylight poster, a billboard on a wall or an LED screen on a building, is replaced by a plain white card with a slogan in Slovenian: UBOGAJ (obey), PLAČUJ (pay), NE RAZMIŠLJAJ (don’t think), DENAR JE SVOBODA (money is freedom).

Swapping one rectangle for another sounds trivial, and in a still photo it is. In video it is a small visual-effects job, the kind film studios call match moving. Thirty times a second the card has to sit exactly where the poster is, in the right perspective, and it has to keep doing that while:

  • the camera walks, sways and shakes in someone’s hand;
  • a poster grows from a speck 15 pixels tall in the distance to a close-up that leaves the edge of the frame;
  • pedestrians, lamp posts and other poster stands pass in front of it;
  • digital screens play animated content, so their own pixels don’t stay put;
  • the card’s brightness, blur and grain match the rest of the footage, so it doesn’t look pasted on.

A misplacement of two or three pixels is enough for the eye to see the card “swimming” against the wall behind it. Everything below is about avoiding that, with as little manual work as possible. No 3D software or compositing package was used: the whole pipeline is a set of Python scripts built around open computer-vision models, run on a single consumer graphics card (an NVIDIA RTX 3090).

The pipeline at a glance

Each street clip goes through the same five steps:

  1. Find the advertising surfaces.
  2. Outline each one in every frame (segmentation).
  3. Follow its four corners through the clip (tracking).
  4. Replace it with a slogan card, keeping anything that passes in front (compositing).
  5. Edit original and replaced footage together into the trailer, with the “glasses” look.

The source material is five phone clips, recorded in Full HD (1920×1080) at 30 frames per second on Miklošičeva, Dalmatinova and Slovenska streets and at the BTC shopping district, plus a short test clip at a bus stop. To keep each clip to a couple of minutes of processing, the analysis runs at 960×540 and only the final compositing at 1280×720.

Where it started: one screen at a bus stop

The first experiment was a single portrait digital screen at a bus stop, filmed while walking past. The screen grows, turns oblique and leaves the right edge of the frame within five seconds. Because it plays an animated ad, nothing on the screen can be tracked: the pixels move by themselves. Only its outline is reliable.

So the screen was modelled in 3D: a flat rectangle of unknown proportions, seen through a pinhole camera of unknown focal length, with a separate camera position and orientation for every frame. The rectangle is rendered “softly” (with blurred edges, so that it is differentiable) and compared with the segmentation mask of the screen, and gradient descent adjusts all the unknowns until the projected rectangle matches the mask in every frame. A smoothness term keeps the camera path plausible, which matters at the end, when only a sliver of the screen’s left edge remains in view. Because the loss only counts pixels inside the image, the same fit works whether the screen is whole, cut off by the frame edge or almost gone.

The fit was never told the screen’s shape, yet it settled on a width-to-height ratio of 0.566, against 0.5625 for a standard 9:16 portrait display, and a focal length of 1,488 pixels (about a 66° field of view, typical of a phone’s main camera). The fitted rectangle overlaps the mask with a mean intersection-over-union of 0.988, and its edges sit on average about one pixel from the mask’s edges, which is as precise as the mask itself.

Three frames of a bus-stop digital screen: the fitted rectangle outlined in green over the original ad, then the screen replaced by a white card reading UBOGAJ, and later by PODREDI SE as the camera passes close.
The test clip. Left: the fitted 3D rectangle (green) against the screen’s mask, with the overlap score in the corner. Middle and right: the replaced screen. Like a real digital screen, it switches slogans every two seconds with a hard cut: UBOGAJ (obey), PODREDI SE (submit).

This worked very well for one screen, but it took about two minutes of optimisation for 140 frames. Streets with a dozen posters over thousands of frames needed something faster, and that something turned out to be simpler, too.

Step 1: finding the ads

To find advertising surfaces automatically, every 15th frame was passed through Grounding DINO, an open-vocabulary object detector. Unlike classic detectors trained on a fixed list of classes, it takes a free-text prompt, here “advertising poster. billboard. digital advertising screen.”, and returns boxes for whatever matches.

A grid of 24 frames from Miklošičeva street, with yellow detection boxes and confidence scores drawn around a row of large exhibition boards on stands.
Grounding DINO detections on Miklošičeva street (an outdoor exhibition of the Slovenian Museum of Natural History, which plays the part of the advertising here). Recall varies from frame to frame, but each board is found well in at least some frames.

The detector is good at proposing candidates, but not good enough to run unattended: its recall jumps around from frame to frame, and it also flags bus timetables, glass totems and shop signs. On the first long test clip (75 seconds of a walk, 4,500 frames) the fully automatic route took hours. So for the trailer, detection became a review aid: the surfaces to replace were picked by hand, each with a single box drawn on one good frame. That is a minute of work per clip and removes every false positive at the source.

Step 2: outlining them through time

Segmentation, deciding exactly which pixels belong to the poster, is done by Meta’s Segment Anything 2 (SAM 2.1, the large “Hiera-L” model). Given that one box on one frame, its video predictor carries the mask forwards and backwards through the whole clip, using a memory of earlier frames to stay locked on the same object. Each surface is seeded on its close-up, its largest fully visible view, and SAM 2 then follows it all the way back to where it is a few pixels tall at the end of the street.

Eight frames from Dalmatinova street showing a citylight poster outlined in red, from a tiny distant rectangle to a large close-up.
One surface’s mask (red outline) across a Dalmatinova clip, frame numbers in yellow. SAM 2 follows the citylight from a speck in the distance to the close-up it was seeded on.

SAM 2 occasionally loses a surface in one stretch, typically when it is far away and partly hidden. For those cases a surface can be given extra seeds, a second box on a frame where the main track fails. Analysing at half resolution matters here too: SAM 2 keeps every frame in memory, at about 12.6 MB per frame at full HD.

Step 3: following the surface

A mask is not yet a track. When a pedestrian walks in front of a poster, the mask correctly loses the pedestrian’s shape, and when the poster leaves the frame, the mask shrinks to the part still visible. A card stretched over the mask’s outline would shrink and squash with it. What’s needed is where the poster’s four corners are, even when they are hidden or outside the image.

For printed posters there is a much better signal than the outline: the print itself. A poster is flat and its content doesn’t change, so between any two frames its image is related by a homography, the 3×3 projective transform that maps one view of a plane onto another. Tracking a poster means estimating that homography for every frame:

  • Keyframe. The frame where the poster is largest, fully inside the image and unoccluded. Its corners come from straight lines fitted to the mask’s edges, which gives sub-pixel corners.
  • Prediction. From one frame to the next, corner features on the poster are followed with KLT optical flow (Kanade–Lucas–Tomasi), which gives a first estimate of the new homography.
  • Refinement against the keyframe. ECC image alignment (enhanced correlation coefficient) then refines the homography from the keyframe directly to the current frame. Because every frame is registered to the same reference instead of to its neighbour, errors don’t accumulate and the track doesn’t drift.
  • Only visible pixels count. Both steps use only pixels that SAM 2 marks as part of the poster. Occluders don’t pull on the fit, and the corners continue correctly past the edge of the image.
  • Graceful gaps. Where the texture can’t be fitted, far away and mostly hidden behind nearer boards, the poster keeps its tracked shape and its position and scale are extrapolated from the nearest good frames. The card then stays full size behind the occluder instead of collapsing into the visible sliver.
Tracking on Miklošičeva: the SAM 2 masks (red) and the tracked quadrilaterals (green). The quads keep their full shape when boards overlap each other or leave the frame.

The tracked corners also reveal the poster’s real proportions. Given a homography and the camera’s focal length, the true width-to-height ratio of the physical rectangle can be computed. It is estimated from the most head-on views, where it barely depends on the focal length, and the card is drawn in that ratio. A Lisca lingerie citylight therefore gets a citylight-shaped card, however obliquely it is first seen.

Each track also gets a per-frame confidence: high where the fit registered well to the close-up, lower where the frame was only predicted, interpolated across a gap or extrapolated at the ends of the track. That confidence comes back in the edit.

Screens: track the wall, not the picture

LED screens break the “content doesn’t change” assumption. Tracked by their own texture, the large screen on the corner house on Slovenska street jittered by up to 5.7 pixels from frame to frame: the ad was changing under the tracker. The fix uses the screen’s surroundings instead. The wall, bezel and housing around a screen are static and lie in the same plane, so features are tracked on a ring just outside the screen (the screen itself excluded), and a homography is fitted to them with RANSAC, which ignores outliers such as passing cars, and refined with ECC on the same ring. The screen’s corners are anchored at the median of the old track, so the card stays where it was on average and only the frame-to-frame noise goes. Afterwards there is no measurable drift against the wall.

The LED screen on Slovenska street. Left: tracked by its own (changing) content, the card jitters against the façade. Right: tracked by the static wall around it.

Step 4: painting the cards

With four corners per surface per frame, the card is warped into place with a perspective transform. Most of the work that follows goes into making the card look as if the camera had filmed it.

  • Typography. Black capitals in a Helvetica-like sans serif, on white, as in the film. Multi-word slogans are broken into whichever line layout gives the largest type, so NE RAZMIŠLJAJ becomes two big lines rather than one small one. The fonts cover č, š and ž.
  • Brightness. A pure white card would glow unnaturally on a grey November day. The card’s white is set to the surface’s own bright level (a high percentile of the pixels inside its mask), smoothed over time and mostly desaturated, so it follows the light as clouds pass and the camera’s exposure adjusts. A dark ad would give a dark card, so screens get a minimum white level, and their black is 6% of their white, like the backlight bleed of a real LCD.
  • Sharpness and motion. The card is rendered at twice the resolution and downsampled for clean anti-aliased edges, and averaged over five sub-frame positions for motion blur that matches the camera’s.
  • Finish. A little film grain, and for screens a faint glow spilling onto the bezel.
  • Occlusion. Inside the card’s rectangle, any pixel that SAM 2 says is not poster keeps the original footage. Pedestrians, poles and nearer poster stands therefore stay in front of the card, with no manual rotoscoping.
  • Depth order. Smaller (usually more distant) surfaces are drawn first, so nearer cards overlap farther ones correctly.
Two before-and-after pairs from Miklošičeva street: a row of exhibition boards with animal photographs, and the same frames with white cards reading MOLI IN DELAJ, PLAČUJ and UBOGAJ.
Miklošičeva before (left) and after (right). Each board keeps one slogan: MOLI IN DELAJ (pray and work), PLAČUJ (pay), UBOGAJ (obey). The nearest card is motion-blurred as the camera passes; the farther cards are correctly hidden behind the nearer ones.
Three frames from Dalmatinova street, original above and processed below, where citylight posters are replaced by cards reading NE BERI, NE DVOMI and NE SPRAŠUJ.
Dalmatinova, original (top) and composite (bottom). Here the cards rotate every two seconds through NE SPRAŠUJ, NE RAZMIŠLJAJ, NE DVOMI, NE BERI (don’t ask, don’t think, don’t doubt, don’t read).

Step 5: glasses on, glasses off

The trailer alternates between ordinary footage in colour and the same street seen “through the glasses”. Each switch goes through the famous shot of the hero putting the sunglasses on, a fraction of a second quoted from the original 1988 trailer, played forwards for glasses on and backwards for glasses off.

The cuts do more than tell the story. No automatic track is perfect for a whole clip: cards are weakest when a surface is about to leave the frame up close, or is mostly hidden. Every cut back to the original hides one of those moments. To find the good stretches, the per-frame track confidences are combined: in each frame, the score is that of the worst-tracked surface that is big enough to matter, and runs of high scores become candidate “glasses on” windows.

A timeline over 50 seconds with one row per tracked surface, coloured from green (reliable) to red (unreliable), and a bottom row of green bars marking the windows where the glasses can be on.
Track confidence on the 50-second Slovenska clip, one row per surface (green reliable, red weak, grey where the surface is too small or hidden to matter). The bottom row shows the stretches where every surface that matters is tracked well enough to put the glasses on.

The final cut was chosen by eye with these windows as a guide. It is listed as a short edit decision list, a sequence of segments such as “original Dalmatinova 9.0–11.8 s, glasses on, composite 12.6–18.0 s, glasses off”, from which the whole trailer renders in about 20 seconds.

The “truth filter” look of the glasses is built from simple image operations: black and white with a contrast S-curve, thin vertical TV lines every three pixels, a vignette, flicker and grain. On top sits a status bar like a body camera’s: a red recording dot, TRUTH FILTER ON, LJUBLJANA, signal and battery, and a clock that shows the real time of the recording, read from the phone’s video metadata.

Black-and-white frame of a corner building on Slovenska street whose large LED screen reads DENAR JE SVOBODA, with a status bar on top reading TRUTH FILTER ON, 09:12:39, LJUBLJANA, 5G.
Through the glasses: the Slovenska LED screen reads DENAR JE SVOBODA (money is freedom). The clock in the status bar is the actual time of recording.

The trailer opens with an old film-leader countdown, with “Virostatiq Studios Presents” above and THEY VOTE below. The stock leader footage only contains a clean 5 and 4, so 3, 2 and 1 are forged: the printed digit is masked out, the hole is filled by extending the surrounding pixels radially from the crosshair’s centre (the sweeping wedge, its edge and the crosshair are all radial, so they continue naturally through the hole), and the new digit is drawn in the same typeface and size. The trailer ends by fading the last street shot to dark, followed by a date: 6 December 2026.

Film-leader countdown frame showing a large 2 inside concentric circles, with Virostatiq Studios Presents at the top and THEY VOTE at the bottom.
The countdown. This “2” never existed in the original leader footage.

What didn’t make the cut

Several more ambitious approaches were tried and set aside, because choosing cuts by eye and stabilising against the wall got there faster:

  • A full camera solve. COLMAP structure-from-motion reconstructed the camera path and a sparse 3D model of the street, with the ads masked out so their content couldn’t steer the solution. Each poster could then be a fixed rectangle in 3D, projected through the solved cameras. In principle this is the most robust option, since a surface can be placed correctly even when it is barely visible, but it was slower to get right than the 2D trackers.
  • Rigid and optical-flow tracks. Rectangles driven by the estimated camera shake, or by dense optical flow on the wall, as alternatives to texture tracking.
  • A multi-surface 3D fit. The bus-stop method generalised to many surfaces with a shared camera. On a McDonald’s citylight it recovered the standard 118.5 × 175 cm poster proportions (0.680 against 0.677), but it was unstable for surfaces seen only as specks.

Known limitations remain. The cards are cleaner than real glass, which reflects sky and trees; the occlusion matte is a hard mask with a one-pixel blur, so hair and limbs have sharp edges; and one slightly curved poster stand is treated as flat.

By the numbers

FootagePhone, 1920×1080 at 30 fps; four street clips in the trailer, plus a bus-stop test clip
ResolutionAnalysis at 960×540, compositing and final render at 1280×720
Surfaces per clip2 to 9, chosen by hand with one box each
Processing timeAbout 1.5–2 minutes per clip end to end on an RTX 3090; the trailer renders in about 20 s
Bus-stop testRecovered aspect 0.566 (true 9:16 = 0.5625), mask overlap 0.988, edge error ≈ 1 px
Screen stabilisationJitter of up to 5.7 px reduced to no measurable drift against the wall
Trailer length44.4 s

Tools

  • SAM 2 (Meta) for video segmentation
  • Grounding DINO for open-vocabulary detection, through Hugging Face Transformers
  • OpenCV for optical flow, homographies, ECC alignment and warping
  • COLMAP for the structure-from-motion experiment
  • PyTorch for the differentiable 3D fit
  • FFmpeg for decoding, encoding and the edit
HTML Snippets Powered By : XYZScripts.com