At 2 a.m., someone on an alley CCTV camera threw a can and disappeared. The computer finds the person among millions of numbers on the screen, turns the person into a 13-joint stick figure, and boils the stick figure's movement down to a few numbers (features) to decide "Is this littering?" We follow it all the way through: where human-made rules get fooled, what learning fixes, and why "where did it land?" is the most important clue.
A CCTV control room has dozens of screens. No one can watch every screen all night. The lab has received a single mission: make AI spot the "motion" of dumping trash first.
Find the person among 6 million numbers and reduce the pose to 26 numbers
Summarize 46 frames of movement as 4 features and compare rules with learning
Live scores and abstaining, and where this method goes wrong
What the computer receives is not a photo but the intensity (0–255) of red, green, and blue in each cell. Switch the view mode and hover your mouse over the screen.
One frame of Full HD CCTV is 1,920 cells wide × 1,080 cells tall, and each cell holds three numbers: red, green, and blue. 1,920 × 1,080 × 3 = 6,220,800. At 30 frames per second, that is 186.62 million numbers every second. Nowhere among these numbers is there a label saying "person" or "trash can." So the first step is to find what is where in the pile of numbers. How a photo becomes a matrix of numbers is covered in detail in 4-2.
There are two steps. First, object detection finds the boxes (bounding boxes) around the person, the trash can, and the can. Then pose estimation finds the coordinates of 13 joints inside the person's box. Try turning the layers on and off.
The coordinates were read directly from the joint points in the illustration (1402 × 1122). The top left is (0, 0), and y increases going down. Because we are facing the person, the arm on the left side of the screen is their "right arm."
For object detection, the YOLO family [R3] is widely used; for pose estimation, OpenPose [R1] or MediaPipe [R5]. For joint numbering, the 17-point scheme of the COCO dataset [R2] is the de facto standard. This page uses 13 points: the COCO 17 points minus the two eyes and two ears, with the head represented by the single nose point.
Littering is not a single frame but movement over 3 seconds. Pick from six scenes. The yellow dotted line is the right wrist's trajectory, and the graph below shows wrist speed and the can's state.
The six scenes are not real footage but synthetic data made by changing joint angles over time. They use units where body height = 1 (based on a height of 1.7 m), and a thrown can flies in a parabola under gravity. The function in Code 1 and this figure perform the same calculation. With real footage, the pose estimation from section 3 would produce these coordinates for every frame.
We reduce 1,196 numbers to 4 features chosen by people. Then we decide in two ways: rules set by people, and a model learned from data. Move the threshold and find where the rules go wrong.
We varied the six scenes in speed (×0.8–1.25), position, and motion size (×0.75–1.25) to make 600 training and 300 test scenes, and added jitter (pose estimation error) to the joint coordinates. The correct answer is set by the outcome: if the can remains on the ground outside the trash can, it is littering. So even "Throw far" is normal if a hard throw lands in the can (only 52% of the throws in the test set are littering). The numbers in the cells are the share of that scene judged as littering, and those that differ from the correct answer by more than 5 percentage points are marked in red.
Rule 1 (60.7%): It flagged 94% of hand waves as littering (false alarms). It missed 98% of slow drops.
Rule 2 (76.7%): Adding "did it let go?" removed the hand-waving false alarms. But it still misses drops, and it even flags normal scenes where the can was thrown into the bin.
4 features + logistic regression (99.7%): The learned weights are [speed −0.33, release 1.16, distance outside the bin 3.93, moving away 1.19]. Wrist speed actually got a small negative weight. The strongest clue the model picked is "did the can remain on the ground outside the bin?"
MLP fed raw coordinates (92.3%): It learned the "shape" of throwing, but it also raised alarms for throws that landed in the bin (19 false alarms). Adding 2 object coordinates did not help. Among 1,288 numbers, finding "is the can's x-coordinate in the last frame outside the bin?" from only 600 training examples is hard.
This uses the weights learned by the logistic regression in Code 2 as they are. Using only the frames seen so far, it recomputes the 4 features and assigns a score. At 0.6 or above it raises an alarm; between 0.4 and 0.6 it abstains and hands the case to a person.
False alarms make innocent people suspects, and misses make enforcement toothless. Because the two mistakes carry different weights, it is hard to settle on a single threshold. So scores in the ambiguous zone (here 0.4–0.6) are not decided automatically; instead a control-room operator watches the footage directly. AI is used only to set the order of "which screen to look at first," and people make the final judgment and bear the responsibility. Press "Random scene" several times and look for throws that land in the bin and weak throws.
A stick figure and 4 features are easy to understand and lightweight. By the same token, what they miss is clear, too.
Both code notebooks use only libraries preinstalled in Colab. After "Download notebook (.ipynb)", open it in Colab via File → Upload notebook, or copy the code and paste it into a new notebook cell.
Computes the function that draws a stick figure from joint angles (fk), the six scenes, and the 4 features. It produces the same numbers as the table at the top of section 5. To use your own data, put the coordinates from a pose estimation tool where clip() returns joint coordinates, and divide so that the person's height becomes 1.
Creates 600 training and 300 test examples by varying the scenes, and compares 2 rules, logistic regression, and 2 MLPs. The experiment table in section 5 and the weights in the section 6 control room come straight from this output.
These are prompts to paste into AI assistants such as ChatGPT, Qwen, or Claude. When you press "Copy," the selected code is attached after the prompt. Just replace the parts in 〔 〕 with your own situation.
The AI's answer is only a starting point. Always verify suggested papers, figures, and library functions against the original sources and official documentation. When using footage of real people, first check filming consent and personal data processing rules.
The same dictionary as the yellow dotted underlines in the text. Click a section name to jump to where the term first appears.
Analogies are a first step toward understanding, but they can also plant misconceptions. Analogies to human perception are marked by strength. Direct there is evidence that it actually does the same thing · Partial only some properties are similar · None no known counterpart
| Concept | Everyday analogy | Human perception analogy | Where the analogy breaks |
|---|---|---|---|
| Object detection | Sticking a Post-it on each person in a photo | Partial Noticing at a glance that "there's a person over there" | A person places Post-its accurately, but a detector also outputs wrong boxes, along with confidence scores |
| Pose estimation | Laying a wire doll over a photo | Partial The ability to recognize a walking person from the motion of just a few dots (point-light walkers) | People can guess where a hidden arm is, but when parts are hidden, pose estimation puts points in the wrong place or leaves them out |
| Feature | The "height, clothing, gait" items on a suspect sketch | None | People choose the items on a suspect sketch. A model that learns from raw coordinates makes up its own items (the MLP in section 5) |
| Rule-based | A security guard's rule of thumb: "someone running is suspicious" | None | A guard adjusts the rule of thumb based on context, but a rule simply fails on scenes outside its set conditions |
| Abstaining | A referee requesting a video review | None | Video review is used rarely, but if you widen the abstain zone, the operators' workload grows again |
E-1 About the author · E-2 Academic references · E-3 Sources of figures and numbers
A teaching guide for instructors, on-the-job (OJT) trainers and tutors. Times are estimates, so adjust them to your actual class.
| Audience | University students and working adults new to video AI. Practitioners considering CCTV analytics for public safety, facility management or store operations |
|---|---|
| Prerequisites | That a photo is a matrix of numbers (4-2), coordinates and distance calculation (Pythagoras), what accuracy means |
| Learning goals | ① Explain the flow CCTV video → object detection → pose estimation → features → decision ② Give examples of scenes where rules and learning each go wrong ③ Propose an operating plan that weighs false alarms and misses, abstaining ("no call") and privacy together |
| Estimated time | Reading 35–45 min · animation demos 20 min · Colab practice 25 min (Code 1: 10 min; Code 2: 1 min to run + 14 min to interpret) |
Intro 5 min (Section 1 report) → Sections 2·3, from the screen to the stick figure, 12 min → Section 4 six scenes 8 min → Section 5 rule-threshold experiment 10 min → Section 6 control room 10 min → check questions 5 min.
Sections 1·3 15 min → re-read the Section 5 experiment table in terms of false-alarm costs at your own site 20 min → Section 6 discussion on setting the abstain range 15 min → Section 7 build a legal/bias checklist 15 min → run and interpret Code 2 25 min.
Beginners: only Sections 2·3, the upper table of 5, and 6. Intermediate learners: have them trace the features function in Code 1 by hand, then add one new feature (e.g. the minimum distance between the hand and the bin) and compare the scores in Code 2.
| Section | Question to pause and ask | Hands-on tip |
|---|---|---|
| 2 The screen is numbers | "Where is the person among 6 million numbers?" | In "View as numbers", shrink the cell size from 64 → 16 |
| 3 Finding the person | "If we keep only the stick figure, what do we lose and what do we protect?" | Move on to the next section with privacy mode still on |
| 4 Into time | "Where do the graphs of waving and throwing differ?" | Click the two scenes in turn and compare the height of the yellow line |
| 5 Rules vs. learning | "Where can we put the threshold so that all six scenes are right?" | Move the slider all the way to confirm "nowhere", then go on to the experiment table |
| 6 Control room | "What happened in the frame where the score suddenly jumps?" | Play the drop scene and pause the moment the can hits the ground |
| 7 Limits | "If the AI sounds an alarm, can we issue a fine right away?" | Connect abstaining with a final check by a human |
| Misconception | Correct explanation | Scene to show |
|---|---|---|
| AI "sees" the CCTV screen like a person does | It receives a grid of numbers and computes step by step. Labels like "person" and "bin" are attached by the detection model | Section 2 "View as numbers" |
| Swinging an arm fast means littering | Waving is fast too, and dropping is slow. The outcome (where the object ended up) is a stronger clue | Section 5, Rule 1 |
| 99.7% accuracy means 99.7% in the field too | That is a result on synthetic data. On real video it drops because of occlusion, darkness and multiple people | Section 5, explanation 3 below |
| Deep learning on raw coordinates is always better | With little data, a few well-chosen features can win | The two MLP rows in the Section 5 experiment table |
| If we store only the stick figure, there is no privacy problem | It reduces the risk but does not remove it. People can be recognized by their gait, and the rules on installation and storage still apply | Section 3 privacy mode, Section 7 |
1920 × 1080 × 3 = 6,220,800. The stick figure has 13 × 2 = 26, so 6,220,800 ÷ 26 ≈ 239,262: about 1/240,000.
Distance = √(0.12² + 0.08²) ≈ 0.144. That took 1/15 s, so 0.144 × 15 ≈ 2.16 heights/s. It exceeds Rule 1's threshold of 2.0.
Miss: dropping at your feet (the wrist is slow). False alarm: a hard throw that lands in the bin (fast and released, but not littering).
No. It is its share with the other features (especially the distance outside the bin) included at the same time. Since the distance outside the bin already explains almost all littering, speed is left with only a small role: slightly pushing down scenes that are fast but normal, like waving. Never interpret one weight on its own.
It falls in the abstain range (0.4–0.6), so the system makes no automatic decision and hands the video to a control-room operator. With a single threshold, 0.52 would immediately become a littering alarm, and false alarms on ambiguous scenes would land straight on people.
Add a fifth feature to Code 1: "the horizontal distance between the hand and the bin at the moment the can is released". Tabulate this value for the six scenes and explain in two sentences whether it helps separate putting it in the bin from dropping it.
In make_dataset in Code 2, change the number of training scenes 100 → 25 → 400 and compare the test accuracy of logistic regression and "joints + objects + MLP". Report with a graph how the gap between the two approaches changes with the amount of data.
| Beginners | For the graph in Section 4 and the experiment table in Section 5, it is enough to read only "which scene went wrong" |
|---|---|
| Advanced | Have learners extract joint coordinates with MediaPipe from a short video they shoot themselves (acted, with consent) and feed them into features in Code 1 |
| Next episode | 5-2 From Recognizing to Creating — flip the arrow on the same feature table to generate motion |
You have read the whole "5-1 CCTV Littering" episode. The lab crew each sum it up in a word.