Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

sortIdx seems not to work

I am trying to sort elements of 1D mat in descending order. Code seems to work fine in python (openCV) but does not work in C++. In C++, I get zero values as output

My code:

> cv::Mat temp = cvCreateMat(5,
> 1,CV_32F); temp.setTo(10);
> temp.at<float>(2, 0) = 20;
> temp.at<float>(4, 0) = 40; cv::Mat
> ind; cv::sortIdx(temp, ind,
> CV_SORT_DESCENDING);

My output index array turns out to be zero which is strange ... I tried a lot but don't know what's going on

sortIdx seems not to work

I am trying to sort elements of 1D mat in descending order. Code seems to work fine in python (openCV) but does not work in C++. In C++, I get zero values as output

My code:code (C++):

> cv::Mat temp = cvCreateMat(5,
> 1,CV_32F); temp.setTo(10);
> temp.at<float>(2, 0) = 20;
> temp.at<float>(4, 0) = 40; cv::Mat
> ind; cv::sortIdx(temp, ind,
> CV_SORT_DESCENDING);

Pyhton Code:

     kernel = np.ones((7,1), np.int32)  
    kernel[5]=10    
    p =cv2.sortIdx(kernel, cv2.SORT_DESCENDING+cv2.SORT_EVERY_COLUMN)

My output index array turns out to be zero which is strange ... I tried a lot but don't know what's going on

sortIdx seems not to work

I am trying to sort elements of 1D mat in descending order. Code seems to work fine in python (openCV) but does not work in C++. In C++, I get zero values as output

My code (C++):

> cv::Mat temp = cvCreateMat(5,
> 1,CV_32F); temp.setTo(10);
> temp.at<float>(2, 0) = 20;
> temp.at<float>(4, 0) = 40; cv::Mat
> ind; cv::sortIdx(temp, ind,
> CV_SORT_DESCENDING);

Pyhton Code:

     kernel = np.ones((7,1), np.int32)  
    kernel[5]=10    
    p =cv2.sortIdx(kernel, cv2.SORT_DESCENDING+cv2.SORT_EVERY_COLUMN)

My output index array turns out to be zero with C++ code which is strange ... I tried a lot but don't know what's going on

sortIdx seems not to work

I am trying to sort elements of 1D mat in descending order. Code seems to work fine in python (openCV) but does not work in C++. In C++, I get zero values as output

My code (C++):

> cv::Mat temp = cvCreateMat(5,
> 1,CV_32F); temp.setTo(10);
> temp.at<float>(2, 0) = 20;
> temp.at<float>(4, 0) = 40; cv::Mat
> ind; cv::sortIdx(temp, ind,
> ind, CV_SORT_DESCENDING);

Pyhton Code:

     kernel = np.ones((7,1), np.int32)  
    kernel[5]=10    
    p =cv2.sortIdx(kernel, cv2.SORT_DESCENDING+cv2.SORT_EVERY_COLUMN)

My output index array turns out to be zero with C++ code which is strange ... I tried a lot but don't know what's going on