Hi, I am trying really hard to access the A-KAZE descriptor values, but all I tryied until now had no effect. I am putting my code here, praying for somebody to help me getting the descriptor values, haha. When I try to use the .at<> function from Mat class, I get this error:
"OpenCV Error: Assertion failed (((((sizeof(size_t)<<28)|0x8442211) >> ((traits::Depth<_Tp>::value) & ((1 << 3) - 1))*4) & 15) == elemSize1()) in cv::Mat::at, file c:\opencv\build\include\opencv2\core\mat.inl.hpp, line 1096"
The 1096 line code means:
"_Tp& Mat::at(int i0, int i1) { CV_DbgAssert(dims <= 2); CV_DbgAssert(data); CV_DbgAssert((unsigned)i0 < (unsigned)size.p[0]); CV_DbgAssert((unsigned)(i1 * DataType<_Tp>::channels) < (unsigned)(size.p[1] * channels())); CV_DbgAssert(CV_ELEM_SIZE1(traits::Depth<_Tp>::value) == elemSize1()); return ((_Tp*)(data + step.p[0] * i0))[i1]; }"
Finally, my source code:
include "stdafx.h"
include "opencv2/opencv.hpp"
include <opencv2 features2d.hpp="">
include <opencv2 imgcodecs.hpp="">
include <vector>
include "src/utils.h"
include <string>
include "iostream"
using namespace std; using namespace cv;
Mat img = imread("lenna.png", IMREAD_GRAYSCALE);
namedWindow("window", WINDOW_NORMAL);
//imshow("image", img);
Mat homography;
FileStorage fs("../data/H1to3p.xml", FileStorage::READ);
fs.getFirstTopLevelNode() >> homography;
vector<KeyPoint> kpts1;
Mat desc1;
int rows = 0, cols = 0;
Ptr<AKAZE> akaze = AKAZE::create();
akaze->detectAndCompute(img, noArray(), kpts1, desc1);
int col = desc1.total()/kpts1.size();
int row = kpts1.size();
Mat descriptor(row, col, CV_8UC3, cv::Scalar::all(0));
akaze->compute(img, kpts1, descriptor);
//cv::getDescriptorSize(desc1);
Vec3b features = desc1.at<Vec3b>(2, 2);
int nr_kpts = kpts1.size();
//int nr_desc = desc1.size();
//for (int i = 0; i == nr_kpts - 1; i++)
// cout << kpts1[i];
std::cout << "A-KAZE Results " << descriptor.at<float>(0,0);
waitKey(0);
return 0;