问题描述
我有很多时间试图解决这个问题.这是我的日志文件(Android)中的以下错误
I'm having a lot of time trying to get solve this problem. This is the following error in my log file (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()调用生成的长值.
I'm totally stumped. The Java code passes in the long values generated from the .getNativeObjAddr() calls.
有人知道这个错误吗?我无法跟踪android中的错误(jni c ++).
Does anyone know about this error? I cannot trace the error(jni c++) in android.
推荐答案
相同的问题.除了通道的灰度/颜色数问题外,还可能是您没有将正确的结构发送给函数,在我的情况下std :: vector< cv :: Point2d>在cv :: solvePnP()中.
Same problem.Apart from the gray/color number of channels problem, it could be that you do not send the proper structure to a function, in my case std::vector< cv::Point2d > in cv::solvePnP().
我做到了:
...
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:
What works is sending a simple and proper std::vector of cv::Point2d:
...
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
这篇关于OpenCV错误:断言失败(channels()== CV_MAT_CN(dtype))的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!