本文整理汇总了Java中com.cyzapps.mathrecog.ExprRecognizer类的典型用法代码示例。如果您正苦于以下问题:Java ExprRecognizer类的具体用法?Java ExprRecognizer怎么用?Java ExprRecognizer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExprRecognizer类属于com.cyzapps.mathrecog包,在下文中一共展示了ExprRecognizer类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: recognize
import com.cyzapps.mathrecog.ExprRecognizer; //导入依赖的package包/类
public String recognize() throws ExprRecognizeException, InterruptedException {
byte[][] biMatrix = mpaintImgView.getBiMatrix();
if (biMatrix != null && biMatrix.length > 0 && biMatrix[0].length > 0) {
//ImageChop imgChop = rectifySelect(biMatrix); // do not rectify because it leads to a lot of noise points.
ImageChop imgChop = new ImageChop();
imgChop.setImageChop(biMatrix, 0, 0, biMatrix.length, biMatrix[0].length, ImageChop.TYPE_UNKNOWN);
//----- now start recognization.
imgChop = imgChop.convert2MinContainer();
Log.e(TAG, "Now start to recognize image:");
long startTime = System.nanoTime();
StructExprRecog ser = ExprRecognizer.recognize(imgChop, null, -1, 0, 0);
ser = ser.restruct();
ser.rectifyMisRecogChars1stRnd(CameraPreview.msCLM);
ser.rectifyMisRecogChars2ndRnd();
ser.rectifyMisRecogWords(CameraPreview.msMWM);
SerMFPTransFlags smtFlags = new SerMFPTransFlags();
smtFlags.mbConvertAssign2Eq = true;
String strOutput = SerMFPTranslator.cvtSer2MFPExpr(ser, null, new CurPos(0), CameraPreview.msMWM, smtFlags);
long endTime = System.nanoTime();
Log.e(TAG, String.format("recognizing takes %s", toString(endTime - startTime)));
return strOutput;
}
return "";
}
示例2: recognize
import com.cyzapps.mathrecog.ExprRecognizer; //导入依赖的package包/类
public String recognize(byte[][] biMatrix) throws ExprRecognizeException, InterruptedException {
if (biMatrix != null && biMatrix.length > 0 && biMatrix[0].length > 0) {
//ImageChop imgChop = rectifySelect(biMatrix); // do not rectify because it leads to a lot of noise points.
ImageChop imgChop = new ImageChop();
imgChop.setImageChop(biMatrix, 0, 0, biMatrix.length, biMatrix[0].length, ImageChop.TYPE_UNKNOWN);
//----- now start recognization.
imgChop = imgChop.convert2MinContainer();
Log.e(TAG, "Now start to recognize image:");
long startTime = System.nanoTime();
StructExprRecog ser = ExprRecognizer.recognize(imgChop, null, -1, 0, 0);
ser = ExprFilter.filterRawSER(ser, null);
if (ser == null) {
return "";
}
ser = ser.restruct();
ser = ExprFilter.filterRestructedSER(ser, null, null);
if (ser == null) {
return "";
}
ser.rectifyMisRecogChars1stRnd(msCLM);
ser.rectifyMisRecogChars2ndRnd();
ser.rectifyMisRecogWords(msMWM);
SerMFPTransFlags smtFlags = new SerMFPTransFlags();
smtFlags.mbConvertAssign2Eq = true;
String strOutput = SerMFPTranslator.cvtSer2MFPExpr(ser, null, new CurPos(0), msMWM, smtFlags);
long endTime = System.nanoTime();
Log.e(TAG, String.format("recognizing takes %s", toString(endTime - startTime)));
return strOutput;
}
return "";
}
示例3: recognizeMathExpr
import com.cyzapps.mathrecog.ExprRecognizer; //导入依赖的package包/类
public static void recognizeMathExpr(String strImageFile, CharLearningMgr clm, MisrecogWordMgr mwm, boolean bFilter) throws InterruptedException {
BufferedImage image = ImageMgr.readImg(strImageFile);
byte[][] biMatrix = ImageMgr.convertImg2BiMatrix(image);
ImageChop imgChop = new ImageChop();
imgChop.setImageChop(biMatrix, 0, 0, biMatrix.length, biMatrix[0].length, ImageChop.TYPE_UNKNOWN);
imgChop = imgChop.convert2MinContainer();
System.out.println("Now reading image file " + strImageFile + " :");
long startTime = System.nanoTime();
String strOutput = "\\Exception";
try {
StructExprRecog ser = ExprRecognizer.recognize(imgChop, null, -1, 0, 0);
StructExprRecog serOld = ser;
//System.out.println("Before raw filter, image " + strImageFile + " includes expression : " + ser.toString());
if (bFilter) {
ser = ExprFilter.filterRawSER(ser, null);
serOld = ser;
}
if (ser != null) {
//System.out.println("Before restruct, image " + strImageFile + " includes expression : " + ser.toString());
ser = ser.restruct();
serOld = ser;
if (bFilter) {
ser = ExprFilter.filterRestructedSER(ser, null, null);
serOld = ser;
}
if (ser != null) {
ser.rectifyMisRecogChars1stRnd(clm);
ser.rectifyMisRecogChars2ndRnd();
ser.rectifyMisRecogWords(mwm);
SerMFPTransFlags smtFlags = new SerMFPTransFlags();
smtFlags.mbConvertAssign2Eq = true;
strOutput = SerMFPTranslator.cvtSer2MFPExpr(ser, null, new CurPos(0), mwm, smtFlags);
} else {
strOutput = "NO VALID EXPRESSION FOUND.";
}
} else {
strOutput = "NO VALID EXPRESSION FOUND.";
}
} catch(ExprRecognizeException e) {
if (e.getMessage().compareTo(ExprRecognizer.TOO_DEEP_CALL_STACK) == 0) {
strOutput = "Expression is too complicated to recognize.";
}
}
long endTime = System.nanoTime();
System.out.println("After restruct, image " + strImageFile + " includes expression :\n" + strOutput);
//System.out.println(String.format("recognize %s takes %s", strImageFile, toString(endTime - startTime)));
}