-
-
Notifications
You must be signed in to change notification settings - Fork 129
Eclipse Setup
In order to develop the video library using the Eclipse IDE, we need to import the processing-core and processing-video projects into Eclipse, copy the GStreamer libraries into the processing-video project, and finally create a debug project.
Since we only require processing as a dependency, perform a shallow clone of the processing repo and build it by running ant in the processing/build folder, as detailed in the build instructions for Processing:
git clone https://github.com/processing/processing.git --depth 1
- Import the Processing repo into Eclipse: Import > Projects from Git > Existing local repository > Select Processing folder > Import existing eclipse project
- Select processing-core
Import the processing-video repo into Eclipse, following the same procedure explained in the previous step to import processing-core.
The video library needs the GStreamer libraries in order to run. On Linux, GStreamer is available by default in most distributions, but Windows and MacOS need separate installs, so GStreamer is directly bundled with the video library. Download the appropriate package for your system from this file release, either Windows 32 bit, Windows 64 bit, or MacOS (64 bit only), uncompress and copy the folder into processing-video/library.
Once we have processing-core and processing-video imported in Eclipse and the GStreamer libraries copied into processing-video in the case we are developing either on Windows or Mac, we need to create an Eclipse project that allows to run a Processing sketch using the video's classes. This tutorial on Processing in Eclipse is useful, but we need to do a different configuration:
First of all, we start creating a new empty Eclipse project as indicated in the tutorial, and then add a main class to it, named for example Test inside some package path such as video_test. But then, because processing-core and processing-video should be already imported into the Eclipse environment, we can simply include them in the Java Build Path of our project:
We can import the core and video packages into our Test project because we added them to the Build path in the previous step. This will allow us to add all the functionality needed to to video operations in Processing, from our Eclipse project.
package video_test;
import processing.core.*;
import processing.video.*;
public class Test extends PApplet {
Movie movie;
public void settings() {
size(560, 406);
}
public void setup() {
background(0);
// Load and play the video in a loop
movie = new Movie(this, "launch2.mp4");
movie.loop();
}
public void draw() {
image(movie, 0, 0, width, height);
}
public void movieEvent(Movie m) {
m.read();
}
public static void main(String[] args) {
PApplet.main("video_test.Test");
}
}
It is important to add a video file to the Eclipse project, in this case it is called launch2.mp4, and should be located in a data folder created in the root of the project. Also, remember to set all methods, particularly movieEvent, as public. Otherwise, playback will not work.
package video_test;
import processing.core.*;
import processing.video.*;
public class TestCapture extends PApplet {
Capture cam;
public void settings() {
size(640, 480);
}
public void setup() {
String[] cameras = Capture.list();
if (cameras == null) {
println("Failed to retrieve the list of available cameras, will try the default...");
cam = new Capture(this, 640, 480);
} else if (cameras.length == 0) {
println("There are no cameras available for capture.");
exit();
} else {
println("Available cameras:");
printArray(cameras);
// The camera can be initialized directly using an element
// from the array returned by list():
cam = new Capture(this, cameras[0]);
// Start capturing the images from the camera
cam.start();
}
}
public void draw() {
if (cam.available() == true) {
cam.read();
}
image(cam, 0, 0, width, height);
}
public static void main(String[] args) {
PApplet.main("video_test.TestCapture");
}
}
Remember to have a capture device attached for Capture functionality to work properly. Also, remember to set all methods as public.
When running the video library from Eclipse, we need to explicitly tell Java where to find the GStreamer base libraries and plugins (this is required only for Windows and Mac). Since the base libs should be located in <processing-video path>/library/<system>
(where system is macosx64, windows64, or windows32), and the plugins in <processing-video path>/library/<system>/gstreamer-1.0
, we set them using the gstreamer.library.path and gstreamer.plugin.path, which are set in the Run Configurations of the Eclipse project:
under the Arguments tab:
After doing all of this, the project should run and play the video file: