67,514
社区成员
发帖
与我相关
我的任务
分享
package Gundll;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Structure;
public interface detect extends Library {
String path = detect.class.getResource("").getFile();
File file = new File(path);
String filePath = file.getPath();
detect INSTANCE = (detect) Native.loadLibrary(filePath + File.separator + "detect", detect.class);
public static class PredictResult extends Structure implements Structure.ByReference {
public static class ByReference extends PredictResult implements Structure.ByReference {
}
public static class ByValue extends PredictResult implements Structure.ByValue {
}
public int centerX;
public int centerY;
public int radius;
@Override
protected List getFieldOrder() {
List a = new ArrayList();
a.add("centerX");
a.add("centerY");
a.add("radius");
return a;
}
}
public static class DtOut extends Structure {
public static class ByReference extends DtOut implements Structure.ByReference {
}
public static class ByValue extends DtOut implements Structure.ByValue {
}
public byte[] imageName = new byte[1000];
int width;//4byte
int height;//4byte
int objectSum;//4byte
public PredictResult.ByValue[] PredictResult = new PredictResult.ByValue[200];
@Override
protected List getFieldOrder() {
List a = new ArrayList();
a.add(imageName);
a.add(width);
a.add(height);
a.add(objectSum);
a.add("PredictResult");
return a;
}
}
// 初始化
void GunPredictInit();
// 调用算法
DtOut GunPredict(String imageFileName);
}
package Gundll;
import Gundll.detect.DtOut;
public class Test {
// String path = detect.class.getResource("").getFile();
// File file = new File(path);
// String filePath = file.getPath();
public static void main(String[] args) {
try {
// 初始化
detect.INSTANCE.GunPredictInit();
detect detect1 = detect.INSTANCE;
DtOut dtOut = detect1.GunPredict("c:/1.jpg");
System.out.println("=================================");
System.out.println("imageName:" + dtOut.imageName);
// System.out.println("width:" + dtOut.width);
// System.out.println("height:" + dtOut.height);
// System.out.println("objectSum:" + dtOut.objectSum);
// System.out.println("PredictResult:" + dtOut.PredictResult);
} catch (Exception e) {
e.printStackTrace();
}
}
}