Java:运行处理 3.2.1 的 Raspberry Pi 上出现不满足的链接错误

标签 java processing openkinect archlinux-arm libfreenect2

每当我从 OpenKinect Kinect v1 示例 PointCloud 运行示例代码时,都会收到此错误。

 Unsatisfied link error: Unable to load library 'freenect': Native library (linux-arm/libfreenect.so) not found in resource path. 
A library relies on native code that's not available.

OpenKinect 库专为 ARM Linux 架构而设计,可以在 here 找到。 。基本问题是,我认为它没有正确找到 libfreenect.so 库,即使该库有它。我猜它不在路径中。

请参阅下面正在运行的示例代码(我认为导入库 freenect.* 是导致问题的原因):

// Daniel Shiffman
// Kinect Point Cloud example

// https://github.com/shiffman/OpenKinect-for-Processing
// http://shiffman.net/p5/kinect/

import org.openkinect.freenect.*;
import org.openkinect.processing.*;

// Kinect Library object
Kinect kinect;

// Angle for rotation
float a = 0;

// We'll use a lookup table so that we don't have to repeat the math over and over
float[] depthLookUp = new float[2048];

void setup() {
  // Rendering in P3D
  size(800, 600, P3D);
  kinect = new Kinect(this);
  kinect.initDepth();

  // Lookup table for all possible depth values (0 - 2047)
  for (int i = 0; i < depthLookUp.length; i++) {
    depthLookUp[i] = rawDepthToMeters(i);
  }
}

void draw() {

  background(0);

  // Get the raw depth as array of integers
  int[] depth = kinect.getRawDepth();

  // We're just going to calculate and draw every 4th pixel (equivalent of 160x120)
  int skip = 4;

  // Translate and rotate
  translate(width/2, height/2, -50);
  rotateY(a);

  for (int x = 0; x < kinect.width; x += skip) {
    for (int y = 0; y < kinect.height; y += skip) {
      int offset = x + y*kinect.width;

      // Convert kinect data to world xyz coordinate
      int rawDepth = depth[offset];
      PVector v = depthToWorld(x, y, rawDepth);

      stroke(255);
      pushMatrix();
      // Scale up by 200
      float factor = 200;
      translate(v.x*factor, v.y*factor, factor-v.z*factor);
      // Draw a point
      point(0, 0);
      popMatrix();
    }
  }

  // Rotate
  a += 0.015f;
}

// These functions come from: http://graphics.stanford.edu/~mdfisher/Kinect.html
float rawDepthToMeters(int depthValue) {
  if (depthValue < 2047) {
    return (float)(1.0 / ((double)(depthValue) * -0.0030711016 + 3.3309495161));
  }
  return 0.0f;
}

PVector depthToWorld(int x, int y, int depthValue) {

  final double fx_d = 1.0 / 5.9421434211923247e+02;
  final double fy_d = 1.0 / 5.9104053696870778e+02;
  final double cx_d = 3.3930780975300314e+02;
  final double cy_d = 2.4273913761751615e+02;

  PVector result = new PVector();
  double depth =  depthLookUp[depthValue];//rawDepthToMeters(depthValue);
  result.x = (float)((x - cx_d) * depth * fx_d);
  result.y = (float)((y - cy_d) * depth * fy_d);
  result.z = (float)(depth);
  return result;
}
<小时/>

编辑 这是我得到的图片:

I always get this missing native code error

最佳答案

所以这是一个比我想象的更简单的修复(不是总是这样吗?)所以我必须转到我的 /home/pi/sketchbook/libraries/ 并删除任何现有的 openKinect 库。然后下载专为 Raspberry Pi armv6hf 板制作的 openKinect 库 zip 文件,并将其解压到 /home/pi/sketchbook/libraries/ 中。然后重新启动处理并打开示例,然后它找到了库。感谢乔治·普罗芬扎的意见。

关于Java:运行处理 3.2.1 的 Raspberry Pi 上出现不满足的链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39585804/

相关文章:

c - 使用 libfreenect 编译代码时出现链接器错误

javascript - 处理js无法正常工作

c++ - 使用 Pthreads 捕获异常

java - 在 Java 中,如何在特定时间后(可靠地)从主线程中断线程?

java - 使用 jsoup 从下拉列表中获取所选项目的值

javascript - 删除所选之前数组中的所有元素

java - 尝试保存处理中 WavePlayers 的输出

Windows 7 上的 Kinect v2

java - 使用php和mysql为android构建登录、注册系统,但应用程序可以运行

java - Accumulo BatchWriter close() 永远卡住了