Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

using GStreamer in Eclipse multiple project architecture

$
0
0

i have the following applet:

public class FakeApp extends PApplet{ public PApplet father; int numPixels; int[] backgroundPixels; Capture video;

Display d;

public void init(){ super.init(); this.setup(); } public void setup() { super.setup(); size(640, 480); d=new display(); d.setup((PApplet)this);
} public void draw(){ d.draw(); } }

where Display is delegated to show camera input (background subtraction in the processing showcase):

public void setup(PApplet father) { this.father=father;

// This the default video input, see the GettingStartedCapture // example if it creates an error video = new Capture(father, 640, 480); //video = new Capture(father, father.width, father.height);

// Start capturing the images from the camera video.start();

numPixels = 640* 480;//video.width * video.height; // Create array to store the background image backgroundPixels = new int[numPixels]; // Make the pixels[] array available for direct manipulation father.loadPixels(); }

public void draw() { if (video.available()) { video.read(); // Read a new video frame video.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 color // of the background in that spot int currColor = video.pixels[i]; int bkgdColor = backgroundPixels[i]; // Extract the red, green, and blue components of the current pixel's color int currR = (currColor >> 16) & 0xFF; int currG = (currColor >> 8) & 0xFF; int currB = currColor & 0xFF; // Extract the red, green, and blue components of the background pixel's color int bkgdR = (bkgdColor >> 16) & 0xFF; int bkgdG = (bkgdColor >> 8) & 0xFF; int bkgdB = bkgdColor & 0xFF; // Compute the difference of the red, green, and blue values int diffR = father.abs(currR - bkgdR); int diffG = father.abs(currG - bkgdG); int diffB = father.abs(currB - bkgdB); // Add these differences to the running tally presenceSum += diffR + diffG + diffB; // Render the difference image to the screen father.pixels[i] = father.color(diffR, diffG, diffB); // The following line does the same thing much faster, but is more technical //pixels[i] = 0xFF000000 | (diffR << 16) | (diffG << 8) | diffB; } father.updatePixels(); // Notify that the pixels[] array has changed //father.println(presenceSum); // Print out the total amount of movement } }

// When a key is pressed, capture the background image into the backgroundPixels // buffer, by copying each of the current frame's pixels into it. public void keyPressed() { video.loadPixels(); father.arraycopy(video.pixels, backgroundPixels); }enter code here } running this PApplet as an applet actually works, and also the following:

public class FakeStart {

public static void main(String[] args) { // TODO Auto-generated method stub JFrame f=new JFrame(); f.setBounds(0, 0, 640, 480); f.setLayout(null); FakeApp app=new FakeApp(); app.init(); //app.size(500, 500); //app.setup(); f.setResizable(false); f.show(); f.addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent we) { System.exit(0); } } ); f.add(app); app.show(); } }

works fine. the problem is that the code :

public static void main(String[] args) { aaa.view.video.FakeStart.main(null); }

fails with:

(javaw.exe:5620): GStreamer-WARNING **: Failed to load plugin 'C:/Users/bbb/Desktop/aaa/dskV/video/library/\windows64\plugins\libgstwavparse.dll': `C:/Users/bbb/Desktop/aaa/dskV/video/library/\windows64\plugins\libgstwavparse.dll': Impossibile trovare il modulo specificato. +30 similar warnings, and the camera fails to load. (the path C:/Users/bbb/Desktop/aaa/dskV/video/library/\windows64\plugins\ is correct)

So in short:

-when i run the code as an applet it works.

-when i launch a main that opens the applet in a jframe it works (if the main is in the dskV project where the native code is).

-when i launch a 1 line main that invokes the working main it doesnt work (in this case the main is in the root project).

-the dskV project has all the libraries required to make the native code work(and in fact it works), the root project has the dskV project in its build path. and to make sure also has all the libraries of dskV (tested with them and without, im desperate). i tried both

System.setProperty("jna.library.path","C:/Users/bbb/Desktop/aaa/dskV/video/library/windows64/plugins/" ); and

System.setProperty("jna.library.path","C:/Users/bbb/Desktop/aaa/dskRoot/video/library/windows64/plugins/" ); after copying the natives in the root project. in all possible places.

what can be this jna starting project related issue?


Viewing all articles
Browse latest Browse all 2896

Trending Articles