We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hey,
I'm a beginner and I want to make a program in which my camera detects how a frame differs from a previous frame. If it differs, I want my camera to automatically take a picture.
I found something about this:
A useful function is absDiff() (absolute difference). This calculates the difference between two images, the one in the regular buffer and one in a second buffer (which an image can be stored in using the ‘remember()’ function. absDiff can be used to perform a number of useful functions.
One of these is background subtraction:
import hypermedia.video.*; // Imports the OpenCV library
OpenCV opencv; // Creates a new OpenCV Object
void setup() {
size( 320, 240);
opencv = new OpenCV( this ); // Initialises the OpenCV object
opencv.capture( 320, 240 ); // Opens a video capture stream
}
void draw() {
opencv.read(); // Grabs a frame from the camera
opencv.absDiff(); // Calculates the absolute difference
image( opencv.image(), 0, 0 ); // Display the difference image
}
void keyPressed() {
opencv.remember(); // Remembers a frame when a key is pressed
}
When a key is pressed, the current frame is stored in memory and is used when calculating the absolute difference. This means that only changes between the stored frame and the current frame are shown.
To use this code, I downloaded the openCV library but it won't work with the latest version of Processing. I get the error that 'something isn't installed right'. Does anybody know which version is compatible with the openCV library? And does anybody perhaps have some tips and tricks for making my program as described above.
Answers
That doesn't look right. Are you using PDE? If so, open the Contributions manager and install "OpenCV for Processing" from Libraries. Then open up some of the example sketches and run them -- they will start with a line like this:
If you aren't using PDE and want to install yourself, go to the Processing Libraries page:
...which takes you to the repository:
@jeremydouglass means to install procesdong open-cv.
Kf