My project is recognition the leaf on Android using OpenCV library. I am using ORB detection to get the keypoint of image and use ORB descriptor to get the feature of the keypoint. This is the code that i use:
bmp=BitmapFactory.decodeResource(getResources(),R.drawable.t1);
Utils.bitmapToMat(bmp, mat);
FeatureDetector detector = FeatureDetector.create(FeatureDetector.ORB);
detector.detect(mat, keypoints);
DescriptorExtractor extractor = DescriptorExtractor.create(DescriptorExtractor.ORB);
extractor.compute(mat, keypoints, features);
Source : http://answers.opencv.org/question/6260/orb-features/
But every i input the same image, the keypoint of that image always different. Can i save the feature of keypoint to database if that always different? Or should i save the image to save the feature data? If that can save to database, how can i do that??
In my opinion the most universal way to store the keypoints is to first convert them to a data-interchange format like JSON.
After you are able to do that conversion you have a lot of flexibility to store it. JSON is easily converted to a String and/or sent through a network connection.
With OpenCV C++ you are able to store data as YAML, but that is not available for Android yet.
To parse JSON in Java you can use this easy to use library Google GSON.
And here is my first attempt to do exactly that:
Although I have not run timings, I suspect that going through formats such as XML or JSON would require more space and computing resources than using primitives.
Below is some code that can be used to save and retrieve MatOfKeyPoint to SQLite database in an Android environment. This is using OpenCV 2.4.11 so SIFT is available.
What you see when you run this application is your test image (which you need to supply and put in the drawable folder) with added keypoints.
The
siftTest()
method starts by computingkeyPoints
which isMatOfKeyPoint
type. The code saves the underlying data of that object in the database, then reads that data out and creates a new objectkeyPointsFromDb
, the contents of which are applied to the original image and the result is displayed.Here is the database code which contains some details associated with converting to the byte array required for the database. I didn't include everything associated with using a database, since that's really a different topic.
The full sample project runs and displays the surf key points, so if you want to save keypoints to a database, this code should get you where you want to go.
Recently I complete a project about recognition human gesture. But I used svm from openCv. for your inform keypoint number in each image is its salient point (according to openCv definition). for recognition or in other words "prediction" you must save feature of keypoint (keypoint Property) that is a mat. I used SURF and it compute 64 feature for each keypoint. I hope it helps.