ICP :: registerModelToScene () Ошибка: утверждение не выполнено - PullRequest
0 голосов
/ 19 января 2020

пытается выполнить базовый c тест из вызова jni и продолжает сталкиваться с одной и той же ошибкой

E/cv::error(): OpenCV(4.2.0-dev) Error: Assertion failed (dataset.type() == CvType<ElementType>::type()) in GenericIndex, file /home/vladholoarch/Desktop/opencv/modules/flann/include/opencv2/flann.hpp, line 318

В документации метода четко указано, что srcP C && dstP C должно иметь CV_32F, который они представляют и представляют из Matx44d. Вот краткий

  /**
 *  \brief Perform registration
 *
 *  @param [in] srcPC The input point cloud for the model. Expected to have the normals (Nx6). Currently,
 *  CV_32F is the only supported data type.
 *  @param [in] dstPC The input point cloud for the scene. It is assumed that the model is registered on the scene. Scene remains static. Expected to have the normals (Nx6). Currently, CV_32F is the only supported data type.
 *  @param [out] residual The output registration error.
 *  @param [out] pose Transformation between srcPC and dstPC.
 *  \return On successful termination, the function returns 0.
 *
 *  \details It is assumed that the model is registered on the scene. Scene remains static, while the model transforms. The output poses transform the models onto the scene. Because of the point to plane minimization, the scene is expected to have the normals available. Expected to have the normals (Nx6).
 */
  CV_WRAP int registerModelToScene(const Mat& srcPC, const Mat& dstPC, CV_OUT double& residual, CV_OUT Matx44d& pose);

А вот мой код:

   extern "C" JNIEXPORT jfloatArray JNICALL
Java_com_example_opencvandroidplugin_MainActivity_testFromJNI(JNIEnv *env, jobject) {
        float m2[4][6] = {{1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f},
                          {2.0f, 2.0f, 0.0f, 1.0f, 1.0f, 1.0f},
                          {2.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f},
                          {1.0f, 2.0f, 0.0f, 1.0f, 1.0f, 1.0f}};
        float m1[4][6] = {{1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f},
                          {2.0f, 2.0f, 0.0f, 1.0f, 1.0f, 1.0f},
                          {2.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f},
                          {1.0f, 2.0f, 0.0f, 1.0f, 1.0f, 1.0f}};
        Mat M1 = cv::Mat(4, 6, CV_32F, m1);
        Mat M2 = cv::Mat(4, 6, CV_32F, m2);
        double re;
        Matx44d pose1;

        vector<ppf_match_3d::Pose3DPtr> resultsSub;
        FlannBasedMatcher matcher;
        cv::ppf_match_3d::ICP calculate(100, 0.005f, 2.5f, 8);
        calculate.registerModelToScene(M1, M2, re, pose1);

        Mat mat = Mat(pose1);
        float res[16];

        for (int i = 0; i < 4; i++)
            for (int j = 0; j < 4; j++) {
                res[4 * i + j] = mat.at<float>(i, j);
            }

        jfloatArray array = env->NewFloatArray(16);
        env->SetFloatArrayRegion(array, 0, 16, res);
        free(res);
        return array;
}

А вот код flann.hpp, который не работает;

template <typename Distance>
GenericIndex<Distance>::GenericIndex(const Mat& dataset, const ::cvflann::IndexParams& params, Distance distance)
{
    CV_Assert(dataset.type() == CvType<ElementType>::type());
    CV_Assert(dataset.isContinuous());
    ::cvflann::Matrix<ElementType> m_dataset((ElementType*)dataset.ptr<ElementType>(0), dataset.rows, dataset.cols);

    nnIndex = new ::cvflann::Index<Distance>(m_dataset, params, distance);

    FLANN_DISTANCE_CHECK

    nnIndex->buildIndex();
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...