I'm developing an android application which recognizing accelerometer gesture. For now I'm just utilizing dynamic time warping to get the smallest distance between input gesture and about 200 unique gesture data in database. My application looping through the data and compare the input gesture with gesture data in the database one by one. It can find the smallest distance and recognizing the gesture for average in 5 second. The problem is can i speed up recognition time maybe for half second or less? Do I have to use classfication method like KNN and combine it with dtw method? an example or references will be apreciated..
What you are currently doing is a 1NN. In other words, you are already running a simplest possible KNN method. with K=1. Changing K won't speed up anything, it can only change the quality of the result. To speed up the process you can think about using two approaches:
Using some indexing methods, which will reduce the computational complexity of your distance based search. This problem is called Nearest Neighbout Search (NNS), and even wikipedia provides quite a lot of information regarding its speed ups;
Using completely different classification method, which build a much simplier model (possibly SVM or even some decision tree - it depends on your actual data).
My intuition is that Locally Sensitive Hashing can be quite easily applicable. For instance you could design them by picking K points randomly and checking if the time series isn't too "far" away.
I would go into more details on that idea, but instead I found this paper : http://dtai.cs.kuleuven.be/events/MLSA13/papers/mlsa13_submission_13.pdf , and it seems to be using much simpler LHS function.
So this is one way out, hope it works out. You can also implement an easy classifier and accept its answer if it is very certain about the gesture (I would recommend SVM here as in the answer above), and if it is close to the boundary decision look for the closest neighbour.
you can do DTW at 10,000 hz, even on a phone, see this vid
http://www.youtube.com/watch?v=d_qLzMMuVQg
eamonn
Related
I'm writing an Android game using LibGDX and Box2D. I'm planning on adding a turn-based multiplayer feature to it.
Now, if on both clients I step the Box2D world at the same rate with the same time steps and I start a simulation on both clients with the exact same initial parameters, when the simulations are over, will the final state of both simulations be exactly the same? In other words, is a Box2D simulation perfectly deterministic?
If it's not, then that means every time a simulation is over, one client acting as a host will have to tell the other to throw away its final simulation's results and use its instead.
Official FAQ quote
The official FAQ had a quote that confirms what you deduced http://web.archive.org/web/20160131050402/https://github.com/erincatto/Box2D/wiki/FAQ#is-box2d-deterministic:
Is Box2D deterministic?
For the same input, and same binary, Box2D will reproduce any simulation. Box2D does not use any random numbers nor base any computation on random events (such as timers, etc).
However, people often want more stringent determinism. People often want to know if Box2D can produce identical results on different binaries and on different platforms. The answer is no. The reason for this answer has to do with how floating point math is implemented in many compilers and processors. I recommend reading this article if you are curious: http://www.yosefk.com/blog/consistency-how-to-defeat-the-purpose-of-ieee-floating-point.html
Or in other words: Fixed-size floating point types
Why the wiki was deleted, I do not know. Humans. I'm glad he lowercased the project name though.
After looking around, the answer is "No", even if the same time steps are used! The reason for this answer has to do with how floating point math is implemented in many compilers and processors. Small discrepancies on each cycle add up resulting in significantly different simulations.
I managed to make Box2D deterministic for an experiment but it was not pretty. The way b2Body::GetTransform()/SetTransform() works does not allow reading the transform and then setting it back to the exact same values. I also had to delete and re-create the contact list for each body every frame. It would be possible to fix these cleanly and more efficiently but it would add enough overhead it would be hard to get the change merged.
I must create an Android app that recognizes some objects from the camera (car steering wheel, car wheel). I tried with Haar classifier but without success and I'm running out of time (it's a school project). So I decided to look for another way. I found some other methods for my goal - ORB. I found what should I do in this answer. My problem is that things are messed up in my head. Can you give me a step-by-step answer of what to do to implement the answer from the question in the link I gave:
From extracting the feature points to training the KD tree and using it for every frame from the camera.
Bonus questions:
Can you give a definition of feature point? It's something I couldn't exactly understand.
Will be the detecting slow using ORB? I know OpenCV can be used in native android, wouldn't that make the things faster?
I need to create this app as soon as possible. Please help!
I am currently developing a similar application. I would recommend getting something working with a single reference image first for a couple of reasons:
It's easier to do and understand if you're just starting out, and you can change it later.
For android applications you have limited processing capabilities so more images = lower fps.
You should have a look at the OpenCV tutorials which are quite helpful. Once you go through the “OpenCV for Android SDK” section and understand the three tutorials you can pretty easily add in functionality that will allow you to analyse the video feed.
The basic logic path I'd recommend following when making the app is:
Read in the reference image.
Create and use your FeatureDetector, DescriptorExtractor and DescriptorMatcher.
Use the above to detect keypoints and then descrive keypoints (the first two, don't forget to convert it to a mat and then to greyscale).
Every time you get a frame from your camera repeat step 3. on it and then compare the keypoints in the images (with the third part of 2.).
Use the result to determine if there is a match (if there is then draw a box around it or something).
Get a new frame.
Try making it to work for a single object and then add in others later. Another thing you could add is a screen at the start to allow users to pick what they want to search for.
Also ORB is reasonably fast, especially compared to SIFT and SURF. I get about 3fps on a HTC One with a single reference image.
We're currently working on an android ocr app using opencv.pre-processing ,segmentation ,Feature extraction steps are done. Classification is the remaining step and we're stuck ..We're using a DB table which is filled with each letter features ..Firstly we had only 1 feature per letter and we used euclidean distance ,but results wasn't accurate and more features needed to be obtained and so we did.The problem now is we have 7 features per letter and absolutely no idea of how to classify i/p based on them..some have recommended using knn ,but we can't figure out how and the opencv documentation in that part ain't clear ..so if anybody can help it wud be great.
Thanks in advance
Briefly and without discussing the details. Vector space comes in handy here. You need to build a feature vector
<feature1, feature2, feature3.. featureN> for each of the instances in your training set.
From each of these images you extract features that you think or you read in the research articles are important for image classification. For example you can do centroid, Gaussian blur, histograms, etc.
Once you have these values linear algebra comes into play with some classification algorithm: knn, svm, naive bayes etc that you run on your training set, that is you build your model.
If the model is ready you run it on your test set.
Use cross validation for more comprehensive results.
For more details check the course notes:
http://www.inf.ed.ac.uk/teaching/courses/iaml/slides/knn-2x2.pdf
or
http://www.inf.ed.ac.uk/teaching/courses/inf2b/lectureSchedule.html
would like to add that OpenCV may not have the sort of classifiers you might prefer.
There are several libraries out there, though you may have to see which works best when on a mobile platform. Could you give some details on the features you are using?
The simplest KNN (k-nearest neighbors) measure would be to find the Euclidean distance in n dimensions (for an n-dimensional feature vector) between the input sample's features and each of the vectors in your DB table. Also explore Mahalanobis distance (used to measure distance between a point and a dataset/class) if you have multiple classes and the input image is to be classified as one such 'type' or 'class' of image.
As #matcheek mentioned, more sophistication can be possible using machine learning techniques such as SVM, Neural Nets, etc. However first you might consider a simpler thing like kNN, considering its a mobile platform which may limit the computational complexity.
I want to develop an app on android to measure the size of objects in a room. E.g. to measure the length of an edge of a table. For this purpose I would use "edge detection" either from imagej or from openCV. Then I would take this edge and define the length of a small part of it as a reference. With this part it is perhaps possible to calculate the whole length of the edge. Perhaps the vanishing point can help me with calculations of the length here.
An example of what I roughly mean can be found here (at 1:19):
http://www.youtube.com/watch?v=-19zSjggMZ0
The Questions:
1. Is there already an app like this?
2. Would you rather recommend imagej or openCV (I know a little bit about NDK and native functions)
3. It would be a project for a 3 month bachelor-thesis (means programming the stuff and in addition writing about 50 sites of text). What do you think about the feasibility concerning this fact AND feasibility in general?
Any thoughts (also beside my questions) are greatly appreciated.
Thanks in advance
gartenabfall
Take a look at the answer to this.
How can I determine distance from an object in a video?
I also used OpenCV heavily for my bachelors thesis. I havent used imagej, but i can say that opencv is fast and easy to use (although i ran it on a PC). As for your project, you will not be able to determine the length without some type of reference (eg the length from the camera to the object, or a known objects length). what you could do is have a known reference, like a coin, appear in the image, then use that as a reference to determine length.
I've been thinking about working on an application. You take a picture of something at a yard sale and it compares it against an image database.
For example say you take a picture of a spoon, and compares the image taken against images in the database and throws back to the user the top 5 possible matches.
Is this possible with current Android?
If so point me in the right direction, for stuff I'd need.
Thanks,
abolbridge
Look forward to your guys feedback.
That is rather possible, but too much CPU consuming and therefore not possible on Android itself. You'd have to build a serverside application for that.
It is going to be hard though. Quite.
Take a look at Google Goggles for an idea. The image processing is entirely made on the server side.
Check out openCV, as it contains a lot of useful object recognition functions and can be used on android. However, this approach will push the limits of the phones CPU and more so, its memory when using higher resolution images. A server-side implementation may be more appropiate.