基本信息
源码名称:android OCR 实例(文字识别,简单识别汉字数字)
源码大小:220.61M
文件格式:.rar
开发语言:Java
更新时间:2020-04-10
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 1 元×
微信扫码支付:1 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
cor文字识别例子
cor文字识别例子
/** * 灰度化处理 */ public Bitmap convertGray(Bitmap bitmap3) { colorMatrix = new ColorMatrix(); colorMatrix.setSaturation(0); ColorMatrixColorFilter filter = new ColorMatrixColorFilter(colorMatrix); Paint paint = new Paint(); paint.setColorFilter(filter); Bitmap result = Bitmap.createBitmap(bitmap3.getWidth(), bitmap3.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(result); canvas.drawBitmap(bitmap3, 0, 0, paint); return result; }
/** * 二值化 * * @param tmp 二值化阈值 默认100 */ private Bitmap binaryzation(Bitmap bitmap22, int tmp) { // 获取图片的宽和高 int width = bitmap22.getWidth(); int height = bitmap22.getHeight(); // 创建二值化图像 Bitmap bitmap; bitmap = bitmap22.copy(Bitmap.Config.ARGB_8888, true); // 遍历原始图像像素,并进行二值化处理 for (int i = 0; i < width; i ) { for (int j = 0; j < height; j ) { // 得到当前的像素值 int pixel = bitmap.getPixel(i, j); // 得到Alpha通道的值 int alpha = pixel & 0xFF000000; // 得到Red的值 int red = (pixel & 0x00FF0000) >> 16; // 得到Green的值 int green = (pixel & 0x0000FF00) >> 8; // 得到Blue的值 int blue = pixel & 0x000000FF; if (red > tmp) { red = 255; } else { red = 0; } if (blue > tmp) { blue = 255; } else { blue = 0; } if (green > tmp) { green = 255; } else { green = 0; } // 通过加权平均算法,计算出最佳像素值 int gray = (int) ((float) red * 0.3 (float) green * 0.59 (float) blue * 0.11); // 对图像设置黑白图 if (gray <= 95) { gray = 0; } else { gray = 255; } // 得到新的像素值 int newPiexl = alpha | (gray << 16) | (gray << 8) | gray; // 赋予新图像的像素 bitmap.setPixel(i, j, newPiexl); } } return bitmap; }