Opencv320 java *.dylib assertion failed in Mac OS but work ok in Ubuntu with *.so lib












0














I have built a java project in Ubuntu 18.04 with libopencv_java320.so and It has worked very well. The problem occur when I run *.jar file in Mac OS with libopencv_java320.dylib.



OpenCV Error: Assertion failed (dims <= 2 && step[0] > 0) in locateROI, file /Users/Bryan/Documents/opencv-3.2.0/modules/core/src/matrix.cpp, line 949
CvException [org.opencv.core.CvException: cv::Exception: /Users/Bryan/Documents/opencv-3.2.0/modules/core/src/matrix.cpp:949: error: (-215) dims <= 2 && step[0] > 0 in function locateROI]
at org.opencv.imgproc.Imgproc.adaptiveThreshold_0(Native Method)
at org.opencv.imgproc.Imgproc.adaptiveThreshold(Imgproc.java:1355)


My code, where this error may occur:



    System.load(this.opencvNativeLibPath + "libopencv_java320.dylib");

Mat src = Imgcodecs.imread(folderPath + "/" + imgName);

int xx = 10, yy = 10;
if (xx > src.width() || yy > src.height()) {
xx = src.width() / 2;
yy = src.height() / 2;
}

Rect r = new Rect(xx, yy, src.width() - xx, src.height() - yy);

src = src.submat(r);

Mat src_gray = new Mat();

if (src == null)
System.out.println("Problem loading image!!!");

if (src.channels() == 3) {
Imgproc.cvtColor(src, src_gray, Imgproc.COLOR_BGR2GRAY);
} else {
src_gray = src.clone();
}

Mat not_gray = new Mat();
Core.bitwise_not(src_gray, not_gray);

// Apply adaptiveThreshold at the bitwise_not of gray, notice the ~
// symbol
Mat bw = new Mat();
Imgproc.adaptiveThreshold(not_gray, bw, 255, Imgproc.ADAPTIVE_THRESH_MEAN_C, Imgproc.THRESH_BINARY, 15, -2);


Thanks for your help.










share|improve this question



























    0














    I have built a java project in Ubuntu 18.04 with libopencv_java320.so and It has worked very well. The problem occur when I run *.jar file in Mac OS with libopencv_java320.dylib.



    OpenCV Error: Assertion failed (dims <= 2 && step[0] > 0) in locateROI, file /Users/Bryan/Documents/opencv-3.2.0/modules/core/src/matrix.cpp, line 949
    CvException [org.opencv.core.CvException: cv::Exception: /Users/Bryan/Documents/opencv-3.2.0/modules/core/src/matrix.cpp:949: error: (-215) dims <= 2 && step[0] > 0 in function locateROI]
    at org.opencv.imgproc.Imgproc.adaptiveThreshold_0(Native Method)
    at org.opencv.imgproc.Imgproc.adaptiveThreshold(Imgproc.java:1355)


    My code, where this error may occur:



        System.load(this.opencvNativeLibPath + "libopencv_java320.dylib");

    Mat src = Imgcodecs.imread(folderPath + "/" + imgName);

    int xx = 10, yy = 10;
    if (xx > src.width() || yy > src.height()) {
    xx = src.width() / 2;
    yy = src.height() / 2;
    }

    Rect r = new Rect(xx, yy, src.width() - xx, src.height() - yy);

    src = src.submat(r);

    Mat src_gray = new Mat();

    if (src == null)
    System.out.println("Problem loading image!!!");

    if (src.channels() == 3) {
    Imgproc.cvtColor(src, src_gray, Imgproc.COLOR_BGR2GRAY);
    } else {
    src_gray = src.clone();
    }

    Mat not_gray = new Mat();
    Core.bitwise_not(src_gray, not_gray);

    // Apply adaptiveThreshold at the bitwise_not of gray, notice the ~
    // symbol
    Mat bw = new Mat();
    Imgproc.adaptiveThreshold(not_gray, bw, 255, Imgproc.ADAPTIVE_THRESH_MEAN_C, Imgproc.THRESH_BINARY, 15, -2);


    Thanks for your help.










    share|improve this question

























      0












      0








      0







      I have built a java project in Ubuntu 18.04 with libopencv_java320.so and It has worked very well. The problem occur when I run *.jar file in Mac OS with libopencv_java320.dylib.



      OpenCV Error: Assertion failed (dims <= 2 && step[0] > 0) in locateROI, file /Users/Bryan/Documents/opencv-3.2.0/modules/core/src/matrix.cpp, line 949
      CvException [org.opencv.core.CvException: cv::Exception: /Users/Bryan/Documents/opencv-3.2.0/modules/core/src/matrix.cpp:949: error: (-215) dims <= 2 && step[0] > 0 in function locateROI]
      at org.opencv.imgproc.Imgproc.adaptiveThreshold_0(Native Method)
      at org.opencv.imgproc.Imgproc.adaptiveThreshold(Imgproc.java:1355)


      My code, where this error may occur:



          System.load(this.opencvNativeLibPath + "libopencv_java320.dylib");

      Mat src = Imgcodecs.imread(folderPath + "/" + imgName);

      int xx = 10, yy = 10;
      if (xx > src.width() || yy > src.height()) {
      xx = src.width() / 2;
      yy = src.height() / 2;
      }

      Rect r = new Rect(xx, yy, src.width() - xx, src.height() - yy);

      src = src.submat(r);

      Mat src_gray = new Mat();

      if (src == null)
      System.out.println("Problem loading image!!!");

      if (src.channels() == 3) {
      Imgproc.cvtColor(src, src_gray, Imgproc.COLOR_BGR2GRAY);
      } else {
      src_gray = src.clone();
      }

      Mat not_gray = new Mat();
      Core.bitwise_not(src_gray, not_gray);

      // Apply adaptiveThreshold at the bitwise_not of gray, notice the ~
      // symbol
      Mat bw = new Mat();
      Imgproc.adaptiveThreshold(not_gray, bw, 255, Imgproc.ADAPTIVE_THRESH_MEAN_C, Imgproc.THRESH_BINARY, 15, -2);


      Thanks for your help.










      share|improve this question













      I have built a java project in Ubuntu 18.04 with libopencv_java320.so and It has worked very well. The problem occur when I run *.jar file in Mac OS with libopencv_java320.dylib.



      OpenCV Error: Assertion failed (dims <= 2 && step[0] > 0) in locateROI, file /Users/Bryan/Documents/opencv-3.2.0/modules/core/src/matrix.cpp, line 949
      CvException [org.opencv.core.CvException: cv::Exception: /Users/Bryan/Documents/opencv-3.2.0/modules/core/src/matrix.cpp:949: error: (-215) dims <= 2 && step[0] > 0 in function locateROI]
      at org.opencv.imgproc.Imgproc.adaptiveThreshold_0(Native Method)
      at org.opencv.imgproc.Imgproc.adaptiveThreshold(Imgproc.java:1355)


      My code, where this error may occur:



          System.load(this.opencvNativeLibPath + "libopencv_java320.dylib");

      Mat src = Imgcodecs.imread(folderPath + "/" + imgName);

      int xx = 10, yy = 10;
      if (xx > src.width() || yy > src.height()) {
      xx = src.width() / 2;
      yy = src.height() / 2;
      }

      Rect r = new Rect(xx, yy, src.width() - xx, src.height() - yy);

      src = src.submat(r);

      Mat src_gray = new Mat();

      if (src == null)
      System.out.println("Problem loading image!!!");

      if (src.channels() == 3) {
      Imgproc.cvtColor(src, src_gray, Imgproc.COLOR_BGR2GRAY);
      } else {
      src_gray = src.clone();
      }

      Mat not_gray = new Mat();
      Core.bitwise_not(src_gray, not_gray);

      // Apply adaptiveThreshold at the bitwise_not of gray, notice the ~
      // symbol
      Mat bw = new Mat();
      Imgproc.adaptiveThreshold(not_gray, bw, 255, Imgproc.ADAPTIVE_THRESH_MEAN_C, Imgproc.THRESH_BINARY, 15, -2);


      Thanks for your help.







      java macos dynamic-library opencv3.2






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 12 at 12:38









      Duy Huynh

      64




      64





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53262369%2fopencv320-java-dylib-assertion-failed-in-mac-os-but-work-ok-in-ubuntu-with-s%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53262369%2fopencv320-java-dylib-assertion-failed-in-mac-os-but-work-ok-in-ubuntu-with-s%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Xamarin.iOS Cant Deploy on Iphone

          Glorious Revolution

          Dulmage-Mendelsohn matrix decomposition in Python