我有很多时间试图解决这个问题。这是我的日志文件(Android)中的以下错误
error()﹕ OpenCV Error: Assertion failed (channels() == CV_MAT_CN(dtype)) in void cv::Mat::copyTo(cv::OutputArray) const, file /home/reports/ci/slave_desktop/50-SDK/opencv/modules/core/src/copy.cpp, line 212
我完全难过了。 Java代码传递从.getNativeObjAddr()调用生成的长值。
有谁知道这个错误?我无法追踪android中的错误(jni c ++)。
答案 0 :(得分:0)
同样的问题。
除了通道的灰度/颜色数问题外,还可能是您没有将正确的结构发送给函数,在我的例子中,是cv :: solvePnP()中的std :: vector
我做到了:
...
std::vector<cv::KeyPoint> keypoints;
_blob_detector->detect(image, keypoints);
cv::solvePnP(_model_points, keypoints, _camera_matrix, _dist_coeffs, _rotation_vector, _translation_vector);
// error 215 because sending cv::Keypoints vector instead of cv::Point2d vector
// (same thing if trying to send a cv::Mat as second argument)
有效的方法是发送简单且正确的cv :: Point2d std :: vector:
...
std::vector<cv::KeyPoint> keypoints;
_blob_detector->detect(image, keypoints);
// copying to the correct structure
std::vector<cv::Point2d> image_points;
for (auto & keypoint : keypoints) image_points.push_back(keypoint.pt);
cv::solvePnP(_model_points, image_points, _camera_matrix, _dist_coeffs, _rotation_vector, _translation_vector);
// no error