opencv错误“;错误:org.opencv.objdetect.CascadeClassifier.CascadeClassifier_1(Ljava/lang/String;)J“;
我正在使用opencv错误“;错误:org.opencv.objdetect.CascadeClassifier.CascadeClassifier_1(Ljava/lang/String;)J“;,java,opencv,hadoop,image-processing,mapreduce,Java,Opencv,Hadoop,Image Processing,Mapreduce,我正在使用opencv-249.jar进行图像处理,但是当我在hadoop环境中运行我的程序时,它显示了一个错误。我还使用了System.loadlibrary(Core.NATIVE\u LIBRARY\u NAME),但仍然得到一个错误 Error: org.opencv.objdetect.CascadeClassifier.CascadeClassifier_1(Ljava/lang/String;)J 映射器类如下所示 public static class DumpHibMappe
opencv-249.jar
进行图像处理,但是当我在hadoop
环境中运行我的程序时,它显示了一个错误。我还使用了System.loadlibrary(Core.NATIVE\u LIBRARY\u NAME)
,但仍然得到一个错误
Error: org.opencv.objdetect.CascadeClassifier.CascadeClassifier_1(Ljava/lang/String;)J
映射器类如下所示
public static class DumpHibMapper
extends Mapper<ImageHeader, FloatImage, IntWritable, Text> {
private static Configuration conf;
public DumpHibMapper() {}
public void setup(Mapper<ImageHeader, FloatImage, IntWritable, Text>.Context paramMapper)
throws IOException {
conf = paramMapper.getConfiguration();
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
}
public void map(ImageHeader paramImageHeader, FloatImage paramFloatImage, Mapper<ImageHeader, FloatImage, IntWritable, Text>.Context paramMapper)
throws IOException, InterruptedException {
if (paramFloatImage != null) {
String str1 = conf.get("local.file.path");
CascadeClassifier localCascadeClassifier = new CascadeClassifier(str1 + "haarcascade_frontalface_default.xml");
String str2 = UUID.randomUUID().toString();
File localFile = new File(str1.toString() + "imwf/" + str2 + ".jpg");
FileOutputStream localFileOutputStream = new FileOutputStream(localFile);
JPEGImageUtil.getInstance().encodeImage(paramFloatImage, paramImageHeader, localFileOutputStream);
Mat localMat = Highgui.imread(localFile.getAbsolutePath());
MatOfRect localMatOfRect = new MatOfRect();
localCascadeClassifier.detectMultiScale(localMat, localMatOfRect);
int i = localMatOfRect.toArray().length;
if (i == 0) {
localFile.renameTo(new File(str1.toString() + "imwof/" + localFile.getName()));
}
int j = paramFloatImage.getWidth();
int k = paramFloatImage.getHeight();
String str3 = ByteUtils.asHex(ByteUtils.FloatArraytoByteArray(paramFloatImage.getData()));
String str4;
if (i > 0) {
str4 = j + "x" + k + "\t(" + str3 + ")\t\t" + str2 + ".jpg";
paramMapper.write(new IntWritable(1), new Text(str4));
} else {
str4 = j + "x" + k + "\t(" + str3 + ")\t\t" + "No face detected found " + str2 + ".jpg";
paramMapper.write(new IntWritable(1), new Text(str4));
}
}
}
}
公共静态类映射器
扩展映射器{
私有静态配置;
公共转储映射器(){}
公共无效设置(Mapper.Context参数Mapper)
抛出IOException{
conf=paramMapper.getConfiguration();
System.loadLibrary(Core.NATIVE\u LIBRARY\u NAME);
}
公共void映射(ImageHeader paramImageHeader、FloatImage paramFloatImage、Mapper.Context paramMapper)
抛出IOException、InterruptedException{
if(paramFloatImage!=null){
字符串str1=conf.get(“local.file.path”);
CascadeClassifier localCascadeClassifier=新的CascadeClassifier(str1+“haarcascade_frontalface_default.xml”);
字符串str2=UUID.randomUUID().toString();
File localFile=新文件(str1.toString()+“imwf/”+str2+“.jpg”);
FileOutputStream localFileOutputStream=新的FileOutputStream(localFile);
JPEGImageUtil.getInstance().encodeImage(paramFloatImage、paramImageHeader、localFileOutputStream);
Mat localMat=Highgui.imread(localFile.getAbsolutePath());
MatOfRect localMatOfRect=新的MatOfRect();
localCascadeClassifier.detectMultiScale(localMat、localMatOfRect);
int i=localMatOfRect.toArray().length;
如果(i==0){
localFile.renameTo(新文件(str1.toString()+“imwof/”+localFile.getName());
}
int j=paramFloatImage.getWidth();
int k=paramFloatImage.getHeight();
字符串str3=ByteUtils.asHex(ByteUtils.FloatArraytoByteArray(paramFloatImage.getData());
字符串str4;
如果(i>0){
str4=j+“x”+k+“\t(“+str3+”)\t\t“+str2+”.jpg”;
write(新的intwriteable(1),新的Text(str4));
}否则{
str4=j+“x”+k+“\t(“+str3+”)\t\t“+”未检测到人脸“+str2+”.jpg”;
write(新的intwriteable(1),新的Text(str4));
}
}
}
}
添加System.loadLibrary(Core.NATIVE\u LIBRARY\u NAME)代码>
在主方法中