trying to make chroma key
in
Contributed Library Questions
•
1 year ago
Hi all!
im trying to do a real time chroma key
i have started from an example code that i find in the GSVideo Library
it works but not very well because it check only, i don't understand why, the brightness of the pixel and not the color
some one can help me?
thanks!
im trying to do a real time chroma key
i have started from an example code that i find in the GSVideo Library
- import codeanticode.gsvideo.*;
- // Size of each cell in the grid
- int cellSize = 1;
- // Number of columns and rows in our system
- int cols, rows;
- // Variable for capture device
- GSCapture video;
- void setup() {
- size(1280, 720, P3D);
- //set up columns and rows
- cols = width / cellSize;
- rows = height / cellSize;
- colorMode(RGB, 255, 255, 255, 100);
- // Uses the default video input, see the reference if this causes an error
- video = new GSCapture(this, 1280, 720);
- video.start();
- background(0);
- }
- void draw() {
- if (video.available()) {
- video.read();
- video.loadPixels();
- background(0, 0, 255);
- // Begin loop for columns
- for (int i = 0; i < cols;i++) {
- // Begin loop for rows
- for (int j = 0; j < rows;j++) {
- // Where are we, pixel-wise?
- int x = i * cellSize;
- int y = j * cellSize;
- int loc = (video.width - x - 1) + y*video.width; // Reversing x to mirror the image
- // Each rect is colored white with a size determined by brightness
- color c = video.pixels[loc];
- if (red (c) > 70) {
- stroke (c);
- point (i, j);
- }
- }
- }
- }
- }
it works but not very well because it check only, i don't understand why, the brightness of the pixel and not the color
some one can help me?
thanks!
1