diff --git a/modules/xphoto/src/annf.hpp b/modules/xphoto/src/annf.hpp index aa1b07b3e..1534fa50a 100644 --- a/modules/xphoto/src/annf.hpp +++ b/modules/xphoto/src/annf.hpp @@ -128,11 +128,19 @@ KDTree(const cv::Mat &img, const int _leafNumber, const int _zeroThresh) leafNumber(_leafNumber), zeroThresh(_zeroThresh) /////////////////////////////////////////////////// { - CV_Assert( img.isContinuous() ); + int imgch = img.channels(); + CV_Assert( img.isContinuous() && imgch <= cn); + + for(size_t i = 0; i < img.total(); i++) + { + cv::Vec v = cv::Vec::all((Tp)0); + for (int c = 0; c < imgch; c++) + { + v[c] = *((Tp*)(img.data) + i*imgch + c); + } + data.push_back(v); + } - std::copy( (cv::Vec *) img.data, - (cv::Vec *) img.data + img.total(), - std::back_inserter(data) ); generate_seq( std::back_inserter(idx), 0, int(data.size()) ); std::fill_n( std::back_inserter(nodes), int(data.size()), cv::Point2i(0, 0) );