I am trying to run a motion detection script using the default processing video library. The problem is that when I use the OpenGL renderer, the screen turns white and the code does not work anymore.
I really need to use OpenGL, since my program needs a fast renderer.
Does anyone know a way to make the two libraries work together?
Below is my isolated code for motion detection (it works fine without OpenGL):
import processing.opengl.*;
import processing.video.*;
// Variable for capture device
Capture video;
// Previous Frame
PImage prevFrame;
// How different must a pixel be to be a "motion" pixel
float threshold = 50;
// Count motion pixels to detect motion
HashMap pixeisEmMovimento = new HashMap();
boolean motionDetected = false;
int contagemMovimento;
void setup() {
size(320,240, OPENGL);
video = new Capture(this, width, height, 30);
// Create an empty image the same size as the video
prevFrame.copy(video,0,0,video.width,video.height,0,0,video.width,video.height); // Before we read the new frame, we always save the previous frame for comparison!
prevFrame.updatePixels();
video.read();
}
loadPixels();
video.loadPixels();
prevFrame.loadPixels();
// Begin loop to walk through every pixel
for (int x = 0; x < video.width; x ++ ) {
for (int y = 0; y < video.height; y ++ ) {
int loc = x + y*video.width; // Step 1, what is the 1D pixel location
color current = video.pixels[loc]; // Step 2, what is the current color
color previous = prevFrame.pixels[loc]; // Step 3, what is the previous color
I am using proxml in order to import structured information from a xml file. It works fine, except for one thing: the special characters are converted to html entities: «'», to «'», for example. Is there any way that I can get the characters correctly from the xml file or unescape after they're imported?
// Contar o numero de quotes int childrenCount = citacoesXML.countChildren();
// Definir o tamanho das arrays de quotes e autor, as quais a classe "frase" vai aceder, de acordo // com o numero de quotes no xml quoteXML = new String[childrenCount]; authorXML = new String[childrenCount];
I am trying to achieve an image revealing effect with lines drawn by the user. To do this, I am placing a white square above the image to be revealed. What I would like to know is if it is possible to paint the alpha channel of this square in the space around the lines.