Module 4 · Advanced Practical Projects

Computer vision: how the machine learns to see

Lesson 10 of 15 9 min lesson Updated on October 30, 2026
Progress in the course67%

In this lesson

Machines learn to see from examples.

A phone recognizes its owner's face, and a store camera counts who walks in. Behind both is computer vision. Here you see how it works and when it is worth training a model with your own photos.

Why it needs examples

A machine does not know what a car is. It knows what someone showed it. A person writes down the name of what appears in thousands of photos. That annotation is called a label, and the network learns to link pixel patterns to the labels. That is why a model only knows the categories it was trained on.

And the network does not say "I have never seen this". A new object gets the closest category, often with high confidence.

Three questions, three tasks

TaskQuestion it answersData preparation
ClassificationWhat is this image?One label per photo
DetectionWhat is here, and where?One box drawn per object
SegmentationWhich pixels belong to the object?An exact outline, the most expensive

Use the simplest task that answers the question. If all you need to know is whether there is a hard hat, classification does the job.

Start with a ready-made detector

Many projects start with a detector trained on COCO, a reference dataset with 80 common categories, such as person, car and bottle. Before you label a single photo, run it on 20 images from your own setting and sort them into three piles: what it gets right, what it gets wrong and what it does not even try, because the category is not among the 80.

In video, the detector runs on every frame. A person standing still in front of the camera is counted on every frame. Counting detections is not counting people: for that you need tracking.

Training with your own photos

When the category does not exist in COCO, train. Starting from a ready-made model is much cheaper, because the network already knows edges and textures. A few hundred examples per class are usually enough to get started.

Watch the validation. If you photographed the same box 30 times in a row and drew 20% of the photos at random, the validation set is made of near copies of the training set, and the number comes out pretty and false. Split by capture session: day, place and device.

What the pros know

Two numbers look the same and say different things. According to Ultralytics, the mAP50 counts a detection as a hit when the box overlaps the hand-drawn box by at least 50%: only the easy cases. The mAP50-95, in turn, averages thresholds from 50% to 95%, which demands tight boxes. If the mAP50 is high and the mAP50-95 is low, the model finds the object but draws a loose box. For counting, that may be enough. For measuring size or position, it is not.

Reading the metrics

Precision tells you how many detections are real, that is, how much the model makes up. Recall tells you how many real objects were found, that is, how much it lets slip by. Raising the confidence threshold increases precision and brings recall down. The cost of each error decides the point: a false alarm for a missing hard hat costs a glance, and a hard hat that goes undetected can cost a life.

The confusion matrix shows which class turns into which class. If one row leaks into another, the two are too much alike. Both cases point to the data, not to the model.

Careful

The LGPD, Brazil's data protection law, treats biometric data linked to a person as sensitive personal data. Detecting "there is a person" is enough for counting. Recognizing who each one is requires a legal basis of its own. When you do not need the recorded face, blur it before you store it.

Practice · 5 min

  1. Run the ready-made detector on 20 photos from your own setting and sort them: gets it right, gets it wrong and category that does not exist.
  2. For the errors, note whether they look like low confidence, a duplicate box or a small object.
  3. Write in three lines where your validation would come from and what cannot be on both sides.
Deliverable: the three piles with the photo count and the validation rule in three lines.

Summary

Sources

Read on October 30, 2026.

  1. Ultralytics. YOLO Performance Metrics: IoU, mAP50 and mAP50-95.
  2. Ultralytics. Predict: detector parameters.
  3. Brazil. Lei 13.709/2018 (LGPD): biometric data and purpose.

Lesson quiz

Three situations to apply what you learned.

Lesson 10 of 15

Before moving on to the next lesson

Put what you saw into practice. The boxes stay checked in this browser, so you can come back later.

Have a question about this lesson? The IV Help team answers personally on WhatsApp.

Ask on WhatsApp