We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, I have a very simple program that I have been trying to build for a while.
All I want to do is to take 1 video output and project it side by side in a full screen:
here is what I have so far
import processing.video.*;
Capture video;
int halfImage = width*height/2;
void setup() {
size(320,240);
video = new Capture(this,320,240);
background(255);
video.start();
}
void draw() {
if (video.available()) {
video.read();
}
image(video,0,0);
/*loadPixels();
for (int i = 0; i < halfImage; i++) {
pixels[i+halfImage] = pixels[i];
}
updatePixels(); */
}
I have been playing around with loadpixels and get, my goal is to make as simple and short of code that is possible.
This is how I was imagining the output:
I haven't really seen an example or any other sketch that has done something like this, and was wondering if anyone could help :)
Thank you so much!
Answers
You don't necessarily need loadPixels() if you're not modifying any image properties like specific pixels. You could just add an extra pair of parameters for the scaling of an image/video, and that's it.
Here's what I'm talking about:
-- MenteCode
Edit: I have indicated the change by commenting beside the changes, even though they're pretty self explanatory.
WOW thanks man, that was stupid easy hahaha.
Didn't realize you could do that, thank you SO MUCH! (I am not too bright haha).
Just to add to @MenteCode 's solution:
Both width & height system variables are still 0 before setup()! So that line #5 is useless now! 3:-O
Also, I've re-made the code w/ parameterized constants: (*)
P.S.: Processing's reference teaches that too:
http://processing.org/reference/image_.html
Sweet, that is even better!
Ok, so say later on I need to make the video more square to keep the proportions right, I would just do this:
Also, I have never seen the last 2 parameters, (capture, float, float, [float?], [float?]) it is interesting because I was just looking for a way to squinch the video down and you magically posted those extra parameters (thank you).
where is a good place to read up more on capture?
I looked over:
http://www.processing.org/reference/libraries/video/Capture.html http://processing.org/reference/libraries/video/
and just about 15 other examples but have never seen 5 parameters?
Thanks.
Function image() belongs to Processing's own API. It's not from a 3rd-party library like Capture from video.
Alright gotcha, thanks!