Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

How to replace each pixels from a video feed by an image ?

$
0
0

Hello Processing talented & helpful community :) I am Barbara, I am pretty new to Processing and I am working on a project that is giving me trouble right now. Figured maybe someone here would hear my call and help out !

So here is the deal : I have a pretty simple code, that basically displays the video from webcam feed, in pixels form. What I am trying to do is REPLACE each pixel by an image. Let's say I have 3 folders called : Blue Folder, Red Folder, Green Folder. In each folder I have 100 pictures. I want my code to randomly grab a picture in the folder in order to replace the pixel. So all red pixels will go grab pictures from the red folder. The results would look like a collage of hundreds of photos.

Do you think that is possible ? I have been on this for over 2 weeks and cannot figure it out :(

HERE IS MY BASIC CODE:

import processing.video.*;

int numPixels; int blockSize = 10 ; Capture video; color collageColors[];

void setup() { size(displayWidth, displayHeight); noStroke(); background(0); video = new Capture(this, displayWidth, displayHeight); numPixels = width / blockSize; collageColors = new color[numPixels * numPixels]; video.start(); }

void captureEvent(Capture v) { v.read(); v.loadPixels();

for (int j = 0; j < numPixels; j++) { for (int i = 0; i < numPixels; i++) { collageColors[jnumPixels + i] = v.get(iblockSize, j*blockSize); } } }

void draw() {

if (video.available() == true) { video.read(); image(video, 0, 0); }

for (int j = 0; j < numPixels; j++) { for (int i = 0; i < numPixels; i++) { fill(collageColors[jnumPixels + i]); rect(iblockSize, j*blockSize, blockSize-1, blockSize-1);

}

} }


Viewing all articles
Browse latest Browse all 2896

Trending Articles