Comments (3)
I do get random numbers the radiusSearch(), but not for knnSearch(). The
results are the same, always... Can you double check? If it still does not
work, please provide more info about your platform, etc. thanks
Original comment by [email protected]
on 9 Nov 2011 at 1:55
from javacv.
yes, indeed knn is not generating random numbers.
Though it works extremely inefficient, instead of working faster it works
slower.
Perhaps you could take a look:
private Integer[] findPairs(CvSURFPoint[] objectKeypoints,
FloatBuffer[] objectDescriptors, CvSURFPoint[] imageKeypoints,
FloatBuffer[] imageDescriptors) {
boolean[] lessRidiculous = new boolean[imageDescriptors.length];
Integer[] toReturn = new Integer[objectDescriptors.length*2];
int numNeighbors = 100;
int matchCounter = 0;
LinearIndexParams kdParams = new LinearIndexParams();
SearchParams searchParams = new SearchParams(descriptorLength, 0.5f, true);
// Populate imageMat
CvMat imageMat = CvMat.create(imageDescriptors.length, descriptorLength, CV_32F);
for (int i = 0; i < imageDescriptors.length; i++)
{
for (int j = 0; j < descriptorLength; j++)
{
imageMat.put(i, j, imageDescriptors[i].get(j) );
}
}
Index flannIndex = new Index(imageMat, kdParams, 1);
for (int c = 0; c < objectDescriptors.length; c++)
{
CvMat queryMat = CvMat.create(1, descriptorLength, CV_32F);
CvMat indicesMat = CvMat.create(1, numNeighbors, CV_32S);
CvMat indicesMat = CvMat.create(1, numNeighbors, CV_32S);
CvMat distancesMat = CvMat.create(1, numNeighbors, CV_32F);
// Populate queryMat
for (int i = 0; i < descriptorLength; i++)
{
queryMat.put(0, i, (double) objectDescriptors[c].get(i));
}
flannIndex.knnSearch(queryMat, indicesMat, distancesMat, numNeighbors, searchParams);
//System.out.println("Index " + indicesMat.get(0,0) + " Distance " + distancesMat.get(0,0) + "Index " + indicesMat.get(0,1) + " Distance " + distancesMat.get(0,1));
int nearestNeighbor = (int)indicesMat.get(0,0);
if (indicesMat !=null && nearestNeighbor >0 && nearestNeighbor < imageDescriptors.length && !lessRidiculous[nearestNeighbor])
{
lessRidiculous[nearestNeighbor] = true;
//System.out.println("M " + c + " " + nearestNeighbor + " d " + distancesMat.get(0,0));
toReturn[matchCounter++] = c;
toReturn[matchCounter++] = nearestNeighbor ;
}
}
System.out.println("Matches count " + matchCounter);
return Arrays.copyOf(toReturn, matchCounter);
}
Original comment by [email protected]
on 10 Nov 2011 at 9:23
from javacv.
Well, CvMat.create() is a pretty heavy operation. You should move those calls
outside the loop.
BTW, check out the NetBeans profiler: http://profiler.netbeans.org/ . With that
tool we can easily find which calls use most of the CPU time.
Original comment by [email protected]
on 26 Nov 2011 at 7:04
- Changed state: Done
from javacv.
Related Issues (20)
- FacePreview: ClassNotFoundException - java.awt.image.BufferedImage HOT 4
- parameters for cvmat method? HOT 5
- ObjectFinder in Adroid HOT 7
- Memory Leak in cvLoadImage or JavaCV (Big Issue, New problem) HOT 17
- FacePreview using new OpenCV API HOT 3
- SURF Detect "bad allocation" Error HOT 10
- How to install? UnsatisfiedLinkError jniopencv_core36577.dll HOT 7
- Demo: java.lang.UnsatisfiedLinkError - Reason: image not found HOT 13
- cvFindContours different results HOT 2
- cannot run javacv example, ClassNotFoundException (Mac OS X) HOT 13
- ChamferMatching HOT 3
- Unable to use JavaCV in Matlab R2011b HOT 9
- javacv throws java.lang.UnsatisfiedLinkError HOT 3
- Invalid Memory Access using FloatPointer and PointVectorVector (chamerMatching()) HOT 1
- Getting Linker Error HOT 2
- Issue with javacv implementation of HOG descriptor HOT 10
- Running the sample facepreview of JavaCV on Android with eclipse + Windows xp HOT 7
- Insufficient memory HOT 2
- cvGoodFeaturesToTrack issue HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from javacv.