bug: wave3: ticket#7, reference opencv dll from relative library path.
This commit is contained in:
parent
83690ce049
commit
1e019bcdab
@ -10,6 +10,7 @@ import com.zhangy.skyeye.jm.dto.JmJobImageDTO;
|
||||
import com.zhangy.skyeye.jm.entity.JmImage;
|
||||
import com.zhangy.skyeye.jm.service.JmImageService;
|
||||
import com.zhangy.skyeye.publics.consts.FileTypeEnum;
|
||||
import com.zhangy.skyeye.publics.utils.OpenCVUtil;
|
||||
import org.opencv.core.Core;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
@ -138,21 +139,7 @@ public class JmImageController {
|
||||
}
|
||||
static {
|
||||
//System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
|
||||
//加载 OpenCV (强制使用绝对路径加载,解决 UnsatisfiedLinkError)
|
||||
String openCvDll = System.getProperty("opencv.library.path") + File.separator + Core.NATIVE_LIBRARY_NAME + ".dll";
|
||||
try {
|
||||
File dllFile = new File(openCvDll);
|
||||
if (dllFile.exists()) {
|
||||
// 注意:必须使用 System.load() 加载绝对路径
|
||||
System.load(dllFile.getAbsolutePath());
|
||||
System.out.println("SUCCESS: OpenCV loaded from -> " + dllFile.getAbsolutePath());
|
||||
} else {
|
||||
System.err.println("ERROR: OpenCV DLL not found at -> " + openCvDll);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
System.err.println("CRITICAL: Failed to load OpenCV: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
OpenCVUtil.loadNativeDylib();
|
||||
}
|
||||
|
||||
/*@IgnoreAuth
|
||||
|
||||
@ -24,7 +24,8 @@ import java.util.List;
|
||||
public class ImageUtil {
|
||||
|
||||
static {
|
||||
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
|
||||
//System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
|
||||
OpenCVUtil.loadNativeDylib();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -19,7 +19,26 @@ import java.util.List;
|
||||
public class OpenCVUtil {
|
||||
|
||||
static {
|
||||
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
|
||||
//System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
|
||||
loadNativeDylib();
|
||||
}
|
||||
|
||||
public static void loadNativeDylib() {
|
||||
//加载 OpenCV (强制使用绝对路径加载,解决 UnsatisfiedLinkError)
|
||||
String openCvDll = System.getProperty("opencv.library.path") + File.separator + Core.NATIVE_LIBRARY_NAME + ".dll";
|
||||
try {
|
||||
File dllFile = new File(openCvDll);
|
||||
if (dllFile.exists()) {
|
||||
// 注意:必须使用 System.load() 加载绝对路径
|
||||
System.load(dllFile.getAbsolutePath());
|
||||
System.out.println("SUCCESS: OpenCV loaded from -> " + dllFile.getAbsolutePath());
|
||||
} else {
|
||||
System.err.println("ERROR: OpenCV DLL not found at -> " + openCvDll);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
System.err.println("CRITICAL: Failed to load OpenCV: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user