Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

Adaptive non maximal suppression for keypoints distribution Java?

$
0
0
Hi, I'm sorry to ask but I'm new to OpenCV for Android, and I've tried to change this [code on the last answer ](http://answers.opencv.org/question/93317/orb-keypoints-distribution-over-an-image/#93395)to Java. The questions are: 1. I don't understand `sort` function. Is that from library? If it's not how should I make it? 2. Is the `numeric_limits` I set myself? If yes, what number should I set it to? 3. `Core.norm( keypoints.get(i).pt - keypoints.get(j).pt )` Java can't substract Point with Point. I've tried `Point temp = new Point(keypoints.get(i).pt.x - keypoints.get(j).pt.x, keypoints.get(i).pt.y - keypoints.get(j).pt.y)` but the `Core.norm` need Mat parameter. 4. `swap` function on the bottom? The code that I change public void adaptiveNonMaximalSuppresion( List keypoints, const int numToKeep ) { if( keypoints.size() < numToKeep ) { return; } // // Sort by response // //sort( keypoints.begin(), keypoints.end(), //[&]( const cv::KeyPoint& lhs, const cv::KeyPoint& rhs ) //{ // return lhs.response > rhs.response; //} ); List anmsPts = new ArrayList(); List radii = new ArrayList(); //radii.resize( keypoints.size() ); List radiiSorted = new ArrayList(); //radiiSorted.resize( keypoints.size() ); Float robustCoeff = 1.11f; // see paper for( int i = 0; i < keypoints.size(); ++i ) { Float response = keypoints.get(i).response * robustCoeff; Double radius = numeric_limits::max(); for( int j = 0; j < i && keypoints[j].response > response; ++j ) { radius = Math.min( radius, Core.norm( keypoints.get(i).pt - keypoints.get(j).pt ) ); } radii.set(i,radius); radiiSorted.set(i,radius); } //std::sort( radiiSorted.begin(), radiiSorted.end(), //[&]( const double& lhs, const double& rhs ) //{ // return lhs > rhs; //} ); Double decisionRadius = radiiSorted.get(numToKeep); for( int i = 0; i < radii.size(); ++i ) { if( radii.get(i) >= decisionRadius ) { anmsPts.add( keypoints.get(i) ); } } anmsPts.swap( keypoints ); }

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>