How to DETECT COLORS from CAMERA CAPTURE and OUTPUT them?

How can I gain the colors from a camera capture and output them in swatches?
What are the steps to do this?

Something like this: https://www.youtube.com/watch?v=EyuqP43jkQ8 but then with Processing instead of JS.

import processing.video.*;

Capture cam;

void setup() {
  size(640, 480);

  String[] cameras = Capture.list();
  
  if (cameras.length == 0) {
    println("There are no cameras available for capture.");
    exit();
  } else {
    println("Available cameras:");
    for (int i = 0; i < cameras.length; i++) {
      println(cameras[i]);
    }
    
    cam = new Capture(this, cameras[0]);
    cam.start();     
  }      
}

void draw() {
  if (cam.available() == true) {
    cam.read();
  }
  image(cam, 0, 0);
}

I’m new to processing so any advice is welcome.

Thank you,
badbatman