Difference mapping w/o displaying the camera and the properties of pixels[i]
in
Contributed Library Questions
•
2 years ago
A few questions
1. I want to create curves using difference mapping and Gsvideo. Is it possible to have the camera running and my application reading from the camera w/o actually displaying the output of the camera to the screen? i.e. do I have to put cam in img or could I
video = new GSCapture(this, width, height, 24);
loadPixels
and have it read the camera actively?
2. when I'm looping through pixels using my loops if (int i = 0; i < pixels.length; i++) {pixels[i].extra y and x value}
each pixels stores its x and y value where? When pixels[i] comes up, how can I extract the x and y values from the pixels or is that not stored in the pixel array and processing simply starts at 0,0 and iterates to the last pixel?
is there a pixel[i][0] with the x value and a pixels[i][1] with the Y value?
Sorry about that, the size of the array is the size of the window... gotcha... hence pixels[0] x = 0 y = 0 etc. it does wrap around correct i.e. pixels[1] x = 1 y = 0 pixels[2] x = 2 y = 0
I'm sorry if my questions are naive, but I'm a bit of a beginner.
3. Extra bonus question: I delcare int[] coords = {540, 320};
in my set up, when I tried to call it in the draw draw method I get an error, no such thing as coods.
Here is my code so far (I'm just trying to mod the original GSvideo example):
/**
* Getting Started with Capture.
*
* GSVideo version by Andres Colubri.
*
* Reading and displaying an image from an attached Capture device.
*/
import codeanticode.gsvideo.*;
GSCapture cam;
void setup() {
size(640, 480);
/*
// List functionality still not ready on Linux
String[] cameras = GSCapture.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 GSCapture(this, 320, 240, cameras[0]);
}
However, different cameras can be selected by using their device file:
cam = new GSCapture(this, 640, 480, "/dev/video0");
cam = new GSCapture(this, 640, 480, "/dev/video1");
etc.
*/
int[] coords = {540, 300}; // when I try to push pixels[i] value to this array in draw, I get no such thing as coords
cam = new GSCapture(this, 640, 480);
}
void draw() {
if (cam.available() == true) {
cam.read();// turn this into a variable and then read from it.
loadPixels();
image(cam, 0, 0);
int halfImage = width*height/2;
color pink = color(255, 102, 204);
loadPixels();
for (int i = 0; i < halfImage; i++) {
color currColor = pixels[i];
int currR = (currColor >> 16) & 0xFF;
int currG = (currColor >> 8) & 0xFF;
int currB = currColor & 0xFF;
int places = pixels[i];
beginShape();
// this is where my little curve will begin
// if possible I just want to draw the shape and not display the camera image
endShape();
}
updatePixels();
// color currColor = video.pixels[i];
// image(cam, x in box, y in box);
// The following does the same, and is faster when just drawing the image
// without any additional resizing, transformations, or tint.
// set(160, 100, cam);
}
}
1. I want to create curves using difference mapping and Gsvideo. Is it possible to have the camera running and my application reading from the camera w/o actually displaying the output of the camera to the screen? i.e. do I have to put cam in img or could I
video = new GSCapture(this, width, height, 24);
loadPixels
and have it read the camera actively?
2. when I'm looping through pixels using my loops if (int i = 0; i < pixels.length; i++) {pixels[i].extra y and x value}
each pixels stores its x and y value where? When pixels[i] comes up, how can I extract the x and y values from the pixels or is that not stored in the pixel array and processing simply starts at 0,0 and iterates to the last pixel?
is there a pixel[i][0] with the x value and a pixels[i][1] with the Y value?
Sorry about that, the size of the array is the size of the window... gotcha... hence pixels[0] x = 0 y = 0 etc. it does wrap around correct i.e. pixels[1] x = 1 y = 0 pixels[2] x = 2 y = 0
I'm sorry if my questions are naive, but I'm a bit of a beginner.
3. Extra bonus question: I delcare int[] coords = {540, 320};
in my set up, when I tried to call it in the draw draw method I get an error, no such thing as coods.
Here is my code so far (I'm just trying to mod the original GSvideo example):
/**
* Getting Started with Capture.
*
* GSVideo version by Andres Colubri.
*
* Reading and displaying an image from an attached Capture device.
*/
import codeanticode.gsvideo.*;
GSCapture cam;
void setup() {
size(640, 480);
/*
// List functionality still not ready on Linux
String[] cameras = GSCapture.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 GSCapture(this, 320, 240, cameras[0]);
}
However, different cameras can be selected by using their device file:
cam = new GSCapture(this, 640, 480, "/dev/video0");
cam = new GSCapture(this, 640, 480, "/dev/video1");
etc.
*/
int[] coords = {540, 300}; // when I try to push pixels[i] value to this array in draw, I get no such thing as coords
cam = new GSCapture(this, 640, 480);
}
void draw() {
if (cam.available() == true) {
cam.read();// turn this into a variable and then read from it.
loadPixels();
image(cam, 0, 0);
int halfImage = width*height/2;
color pink = color(255, 102, 204);
loadPixels();
for (int i = 0; i < halfImage; i++) {
color currColor = pixels[i];
int currR = (currColor >> 16) & 0xFF;
int currG = (currColor >> 8) & 0xFF;
int currB = currColor & 0xFF;
int places = pixels[i];
beginShape();
// this is where my little curve will begin
// if possible I just want to draw the shape and not display the camera image
endShape();
}
updatePixels();
// color currColor = video.pixels[i];
// image(cam, x in box, y in box);
// The following does the same, and is faster when just drawing the image
// without any additional resizing, transformations, or tint.
// set(160, 100, cam);
}
}
1