Error : java.lang.UnsatisfiedLinkError with Charuco Camera Calibration (DetectorParameters)

huangapple go评论103阅读模式
英文:

Error : java.lang.UnsatisfiedLinkError with Charuco Camera Calibration (DetectorParameters)

问题

抱歉,我无法识别代码中的特定错误。如果你需要帮助解决代码错误,请提供更多上下文信息,以便我可以尝试提供更准确的建议。

英文:

Good morning everyone. I am currently working on a project in which I have to detect object coordinates within an image with high precision. I have tried using a normal chessboard for camera calibration but the reprojection error was too high so I decided to use the Charuco calibration pattern. I am working with OpenCv 3.4 and Java (project constraint). Since the Aruco function are not included in OpenCv for Java I created a new package in my project which includes the necessary classes. The Aruco code is the one that you can find in the following link :
Aruco Code Github

The code that I'm executing is the following:

  1. protected void captureImagesCharuco() {
  2. int squaresX = 5;
  3. int squaresY = 7;
  4. float squareLength = (float) 37.0;
  5. float markerLength = (float) 22.0;
  6. int calibrationFlags = 0;
  7. float aspectRatio = 1;
  8. DetectorParameters detectParams = DetectorParameters.create();
  9. detectParams.set_adaptiveThreshWinSizeMin(3);
  10. detectParams.set_adaptiveThreshWinSizeMax(23);
  11. detectParams.set_adaptiveThreshWinSizeStep(10);
  12. detectParams.set_adaptiveThreshConstant(7);
  13. detectParams.set_minMarkerPerimeterRate(0.03);
  14. detectParams.set_maxMarkerPerimeterRate(4.0);
  15. detectParams.set_polygonalApproxAccuracyRate(0.05);
  16. detectParams.set_minCornerDistanceRate(10);
  17. detectParams.set_minDistanceToBorder(3);
  18. detectParams.set_minMarkerDistanceRate(0.05);
  19. detectParams.set_cornerRefinementWinSize(5);
  20. detectParams.set_cornerRefinementMaxIterations(30);
  21. detectParams.set_cornerRefinementMinAccuracy(0.1);
  22. detectParams.set_markerBorderBits(1);
  23. detectParams.set_perspectiveRemovePixelPerCell(8);
  24. detectParams.set_perspectiveRemoveIgnoredMarginPerCell(0.13);
  25. detectParams.set_maxErroneousBitsInBorderRate(0.04);
  26. detectParams.set_minOtsuStdDev(5.0);
  27. detectParams.set_errorCorrectionRate(0.6);
  28. Dictionary dictionary = Aruco.getPredefinedDictionary(0);
  29. CharucoBoard charucoBoard = CharucoBoard.create(squaresX, squaresY, squareLength, markerLength, dictionary);
  30. List<List<Mat>> charucoCorners = new ArrayList<>();
  31. List<Mat> charucoIds = new ArrayList<>();
  32. List<Mat> validImgs = new ArrayList<>();
  33. Size imgSize = new Size();
  34. int nFrame = 0;
  35. File[] listImages = imageDirectory.listFiles();
  36. for(File file : listImages) {
  37. String src = file.getAbsolutePath();
  38. Mat imgRead = Imgcodecs.imread(src,Imgcodecs.IMREAD_COLOR);
  39. imgSize = imgRead.size();
  40. Mat imgCopy = new Mat();
  41. Mat ids = new Mat();
  42. List<Mat> rejectedCorners = new ArrayList<>();
  43. List<Mat> corners = new ArrayList<>();
  44. if (!imgRead.empty()){
  45. Aruco.detectMarkers(imgRead, dictionary, corners, ids);
  46. Aruco.refineDetectedMarkers(imgRead, (Board)charucoBoard, corners, ids, rejectedCorners);
  47. Mat currentCharucoCorners = new Mat();
  48. Mat currentCharucoIds = new Mat();
  49. int idsSize = ids.rows()*ids.cols();
  50. if(idsSize>0) {
  51. Aruco.interpolateCornersCharuco(corners, ids, imgRead, charucoBoard, currentCharucoCorners, currentCharucoIds);
  52. }
  53. imgRead.copyTo(imgCopy);
  54. if(idsSize<0) {
  55. Aruco.drawDetectedCornersCharuco(imgCopy, currentCharucoCorners);
  56. }
  57. if(currentCharucoCorners.total()>0) {
  58. Aruco.drawDetectedCornersCharuco(imgCopy, currentCharucoCorners, currentCharucoIds, new Scalar(255,0,0));
  59. }
  60. charucoCorners.add(corners);
  61. charucoIds.add(currentCharucoIds);
  62. validImgs.add(imgRead);
  63. nFrame++;
  64. }
  65. }
  66. intrinsic.put(0, 0, 1);
  67. intrinsic.put(1, 1, 1);
  68. List<Mat> allCharucoCorners = new ArrayList<>();
  69. List<Mat> allCharucoIds = new ArrayList<>();
  70. for(int i =0;i<nFrame;i++) {
  71. Mat currentCharucoCorners = new Mat();
  72. Mat currentCharucoIds = new Mat();
  73. Aruco.interpolateCornersCharuco(charucoCorners.get(i), charucoIds.get(i), validImgs.get(i), charucoBoard, currentCharucoCorners, currentCharucoIds,intrinsic,distCoeffs,4);
  74. allCharucoCorners.add(currentCharucoCorners);
  75. allCharucoIds.add(currentCharucoIds);
  76. }
  77. double repError = Aruco.calibrateCameraCharuco(allCharucoCorners, charucoIds, charucoBoard, imgSize, intrinsic, distCoeffsCharuco, rvecs, tvecs, calibrationFlags);
  78. System.out.println("reprojection error : " + repError);
  79. }

I then simply execute the captureImagesCharuco() in the main program. However when I do so I get the following error :

  1. java.lang.reflect.InvocationTargetException
  2. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  3. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  4. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  5. at java.lang.reflect.Method.invoke(Method.java:498)
  6. at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
  7. at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
  8. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  9. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  10. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  11. at java.lang.reflect.Method.invoke(Method.java:498)
  12. at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
  13. Caused by: java.lang.UnsatisfiedLinkError: application.DetectorParameters.create_0()J
  14. at application.DetectorParameters.create_0(Native Method)
  15. at application.DetectorParameters.create(DetectorParameters.java:24)
  16. at application.CameraCalibrate.captureImagesCharuco(CameraCalibrate.java:115)
  17. at application.Main.main(Main.java:64)
  18. ... 11 more
  19. Exception running application application.Main

I have tried searching for how to solve this error (UnsatisfiedLinkError) and I found that it is usually caused when you're using a library that isn't included in the Build Path or the project (Even though I ma not sure). I guess the library in question here is the Aruco package but I don't know how I can include a package in the build path of the project.

Any kind of help will be more than welcome ! Thank you ! Error : java.lang.UnsatisfiedLinkError with Charuco Camera Calibration (DetectorParameters)

答案1

得分: 1

错误表明您已安装了OpenCV包,但没有使用的特殊模块;

为了解决这个问题,您需要找到一个带有您所需模块的预构建OpenCV(在您的情况下,它位于contrib库中,所以这里可能会有帮助。

如果您想从源代码构建它 - 您应该在CMake属性中启用您需要的模块。对于contrib - 您需要首先使用CMake构建contrib项目,然后在主OpenCV makefile中启用contrib。有关构建OpenCV和contrib的详细信息 - 请参考官方文档。

英文:

The error indicates that you have opencv package without special module you're using;

In order to fix that you'd need to either find a prebuilt opencv with module you need (in your exactly case it's lcoated in contrib library, so this probably helps.

In case you want to build it from sources - you should enable the module you want in cmake properties. For contrib - you'd need to cmake contrib project first & then enable contrib in main opencv makefile. For building opencv & contirb - please follow official documentation.

huangapple
  • 本文由 发表于 2020年7月22日 18:03:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/63031705.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定