Dear Processing Community,
I’ve used code from the Processing textbook for a video imaging exercise that detects presence and compares a new frame to a previously saved frame. On my iMac, I get a grey screen only and with a PC I get the error below as well as a grey screen:
(Processing core video:3936): GStreamer-CRITICAL **: 14:48:21.340: gst_value_set_fraction_range_full: assertion ‘denominator_start != 0’ failed
I have double checked to ensure the video library has been downloaded and it is inserted into the sketch. Does anybody have an idea as to what’s wrong? Is it a lack of contrast?
import processing.video.*;
//VARIABLES
int numPixels;
int[] backgroundPixels;
Capture firstcam;
//SETUP
void setup()
{
size (320, 240);
firstcam = new Capture(this, width, height, 24);
numPixels = firstcam.width * firstcam.height;
//Array to store the background image
backgroundPixels = new int[numPixels];
//Make the pixels[] array available for direct manipulation
loadPixels();
}
//DRAW
void draw()
{
if (firstcam.available())
{
firstcam.read(); //Read a new video frame
firstcam.loadPixels(); //Make the pixels of video available
//Difference between the current frame and the stored background
int presenceSum = 0;
for (int i = 0; i < numPixels; i++)
{
//For each pixel in the video frame...
//Fetch the current color in that location, and also the colour of the background in that spot
color currColor = firstcam.pixels[i];
color bkgdColor = backgroundPixels[i];
//Extract the red, green, blue components of the current pixel's colour
int currR = (currColor >> 16) & 0xFF;
int currG = (currColor >> 8) & 0xFF;
int currB = currColor & 0xFF;
//Extract the red, green, blue components of the background pixel's colour
int bkgdR = (bkgdColor >> 16) & 0xFF;
int bkgdG = (bkgdColor >> 8) & 0xFF;
int bkgdB = bkgdColor & 0xFF;
//Compute the difference of the red, green, blue values
int diffR = abs(currR - bkgdR);
int diffG = abs(currG - bkgdG);
int diffB = abs(currB - bkgdB);
//Add these differences to the running tally
presenceSum += diffR + diffG + diffB;
//Render the difference image to the screen
pixels[i] = color(diffR, diffG, diffB);
}
updatePixels();
println(presenceSum);
}
}
//When key pressed, capture the background image into the backgroundPixels
//buffer by copying each of the current frame's pixels into it.
void keyPressed()
{
firstcam.loadPixels();
arrayCopy(firstcam.pixels, backgroundPixels);
}