2017-09-11 42 views
0

我捕獲連續圖像並提取快速特徵,並進一步匹配這些特徵以獲取Rotational和 平移矩陣。這將幫助我進行3D場景重建,但在使用Calib3d.findFundamentalMat命令時出現 錯誤,但無法解決此問題。在android opencv中使用findFundamentalMat時出現錯誤,但無法解析它

  MatOfDMatch matches = new MatOfDMatch(); 
      descriptorM.match(firstImgDescriptors, secondImgDescriptors, matches); 

      Calib3d calib = new Calib3d(); 
      MatOfPoint2f imgpts1 = getMatOfPoint2fFromDMatches(matches, keyPoints1, 0); 
      MatOfPoint2f imgpts2 = getMatOfPoint2fFromDMatches(matches, keyPoints2, 1); 
      Mat F = Calib3d.findFundamentalMat(imgpts1, imgpts2, Calib3d.FM_RANSAC,3, 0.99); 


    private static MatOfPoint2f getMatOfPoint2fFromDMatches(MatOfDMatch matches, 
                 MatOfKeyPoint keyP, int tipo) { 
      /* 0 para query, 1 para train*/ 
      DMatch dm[] = matches.toArray(); 
      List<Point> lp = new ArrayList<Point>(dm.length); 
      KeyPoint tkp[] = keyP.toArray(); 
      if(tipo == 0){ 
       for (int i = 0; i < dm.length; i++) { 
        DMatch dmm = dm[i]; 
        //if (dmm.queryIdx < tkp.length) 
         lp.add(tkp[dmm.queryIdx].pt); 
       } 
      } 
      if (tipo == 1) { 
       for (int i = 0; i < dm.length; i++) { 
        DMatch dmm = dm[i]; 
        // if (dmm.trainIdx < tkp.length) 
         lp.add(tkp[dmm.trainIdx].pt); 
       } 
      } 

      return new MatOfPoint2f(lp.toArray(new Point[0])); 
     } 




    the Logcat window show the following error 

    E/cv::error(): OpenCV Error: Bad argument (The input arrays should be 2D or 3D point sets) in cv::Mat cv::findFundamentalMat(cv::InputArray, cv::InputArray, int, double, double, cv::OutputArray), file /Volumes/Linux/builds/master_pack-android/opencv/modules/calib3d/src/fundam.cpp, line 724 
    09-11 15:29:04.578 13625-13625/io.rpng.calibration E/org.opencv.calib3d: calib3d::findFundamentalMat_11() caught cv::Exception: /Volumes/Linux/builds/master_pack-android/opencv/modules/calib3d/src/fundam.cpp:724: error: (-5) The input arrays should be 2D or 3D point sets in function cv::Mat cv::findFundamentalMat(cv::InputArray, cv::InputArray, int, double, double, cv::OutputArray) 
    09-11 15:29:04.579 13625-13625/io.rpng.calibration D/AndroidRuntime: Shutting down VM 
    09-11 15:29:04.588 13625-13625/io.rpng.calibration E/AndroidRuntime: FATAL EXCEPTION: main 
                     Process: io.rpng.calibration, PID: 13625 
                     CvException [org.opencv.core.CvException: cv::Exception: /Volumes/Linux/builds/master_pack-android/opencv/modules/calib3d/src/fundam.cpp:724: error: (-5) The input arrays should be 2D or 3D point sets in function cv::Mat cv::findFundamentalMat(cv::InputArray, cv::InputArray, int, double, double, cv::OutputArray) 
                     ] 
                      at org.opencv.calib3d.Calib3d.findFundamentalMat_1(Native Method) 
                      at org.opencv.calib3d.Calib3d.findFundamentalMat(Calib3d.java:153) 
                      at com.pradeep.calibration.activities.MainActivity$5.onImageAvailable(MainActivity.java:529) 
                      at android.media.ImageReader$ListenerHandler.handleMessage(ImageReader.java:648) 
                      at android.os.Handler.dispatchMessage(Handler.java:111) 
                      at android.os.Looper.loop(Looper.java:207) 
                      at android.app.ActivityThread.main(ActivityThread.java:5769) 
                      at java.lang.reflect.Method.invoke(Native Method) 
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) 
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679) 
+0

由於問題解決之前打印這些尺寸。這是由於空值 –

回答

0

錯誤是告訴你,你的imgpoints1和/或imgpoints2不正確的2D或3D點矩陣。

嘗試直接調用Calib3d.findFundamentalMat(...)

相關問題