Digit recognition with OpenCV 2.4.6 in Java [closed]
Im trying to implement a basic Digit recognition using java, the main issue is that i'm really new with the framework and i dont know how to implement this.
i've read several c++ tutorials like this one: http://blog.damiles.com/2008/11/basic-ocr-in-opencv/ or this one: http://www.aishack.in/2010/08/sudoku-grabber-with-opencv/5/
and i know that i need a class with a train function that read a train file (which dictates what can be and what can not be recognized) , and a classify function using the k-nearest algorithm provided by opencv, im not so sure how to implement this, given that c++ tutorials use bitwise operations and operations that i can't replicate in java. the pre-procesing part is all done, i have a class that gives me a Mat object that contains the image of the digit, centered and without noise. i have to implement the part that actually takes that Mat object and turns it into an integer.
Thanks a lot for all your help!
you can do bit operations in java, it just looks different http://docs.opencv.org/java/org/opencv/core/Core.html#bitwise_and(org.opencv.core.Mat,%20org.opencv.core.Mat,%20org.opencv.core.Mat)
for example, look at this method:
int DigitRecognizer::readFlippedInteger(FILE *fp) { int ret = 0; BYTE *temp;
}
so ? that's reading a reversed sequence of 4 bytes. don't tell me that's impossible in java
please don't get mad. yes, i know it isnt impossible, but for example in this code, there are operations like memset that i dont really know how to use in java, i don't know any c++. the author talks about the endianness of the processor, and uses operations with pointers, since java runs on a virtual machine i don't know how can handle this
hey, no fear ;) noone's mad at you. porting c/c++ to java can be quite tricky.
again, sorry for sounding harsh, not intended.
ok no problem :), yes, its very tricky. i have a speciffic question: How can i read the training data so i can contain it in a Mat object?, and what format does the training data has to have? the training data is algorithm-specific?
sorry, must have missed something , training data for what, again ?
What about python?Maybe it is easier to understand.Try this link--http://stackoverflow.com/questions/9413216/simple-digit-recognition-ocr-in-opencv-python. You need to understand pointer before you try to study memset.Although java do not support pointer(haven't tried Unsafe class yet), but you are using a less powerful pointer in java anytime.The object of java is some sort of "const(final) pointer", or similar to the "reference" in c++.
if it's an opencv machine-learning thing, you're expected to deliver a Mat with 1 row per item ( if that's an image, you'll have to 'flatten' it to a row using reshape(1,1). also, iirc, most algos assume float data
hi, stereomatching, note that this guy is already confused enough, translating c++ to java ;)