Sort matrix in OpenCV
I am having trouble using the cv::sort
functionality in the OpenCV C ++ API .
I am trying to sort content cv::Mat
in OpenCV using
cv::sort(InputArray src, OutputArray dst, int flags);
The following code is giving me a compilation error. I'm not sure what happened with this code:
using namespace std;
using namespace cv;
int main(int argc, char** argv)
{
Mat matrix(5,5,CV_32F,Scalar(0)),m;
randn(matrix, 2.00, 1.00);
cout<<"before sorting:\n"<<matrix<<endl;
sort(matrix, m, CV_SORT_EVERY_ROW + CV_SORT_ASCENDING);
cout<<"after sorting:\n"<<m<<endl;
return 0;
}
+3
garak
source
to share
1 answer
You need to use cv :: sort () and not sort () even if you are using the cv namespace. This is because C ++ has a sort () implementation in the std namespace and just using sort () will conflict.
+7
Happy lun
source
to share