Jna物业设置

时间:2017-01-20 13:30:58

标签: java eclipse processing jna

我有以下小程序:

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();
}

}

将委托显示摄像机输入:

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`
}

作为applet运行此PApplet实际上是有效的,还有以下内容:

公共类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();
}

}

工作正常。问题是代码:

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

}

失败了:

(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类似警告,相机无法加载。 (路径C:/ Users / bbb / Desktop / aaa / dskV / video / library / \ windows64 \ plugins \是正确的)

简而言之:

- 当我将代码作为小程序运行时,它可以工作。

- 当我启动一个在jframe中打开applet的main时它可以工作(如果main在dskV项目中是本机代码的话)。

- 当我启动一个调用工作主的1行main时它不起作用(在这种情况下,main在根项目中)。

- dskV项目具有使本机代码工作所需的所有库(实际上它可以工作),根项目在其构建路径中具有dskV项目。并确保还拥有dskV的所有库(使用它们进行测试,没有,我非常绝望)。我试过了两个

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

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

在所有可能的地方。

这个jna启动项目的相关问题是什么?

0 个答案:

没有答案