[转载] 图片文档扫描矫正处理(手机扫描仪),OCR识别,图片修改库整合

文章转载自:https://blog.csdn.net/u014133119/article/details/82222656,感谢分享。

开源项目

  1. OpenCV_image_comparator:图片相似度计算(直方图、峰值信噪比、结构相似性、感知哈希算法)、轮廓检测、直线检测、圆检测、角点检测、直线交点计算、旋转角度矫正、图像匹配的对应相似处连线、灰度、二值化、直方图均衡化。
  2. SmartCropper:智能图片裁剪框架。自动识别边框,手动调节选区,使用透视变换裁剪并矫正选区;适用于身份证,名片,文档等照片的裁剪。
  3. ImageDragZoomTest:模仿“扫描全能王”裁剪界面的一种实现方式
  4. ScanDemoExample
  5. IDCardCamera:识别IDcard,身份证
  6. android-ocr
  7. tesseract
  8. Simple-Android-OCR
  9. Tesseract-OCR-Scanner
  10. OCR_identify:身份证自动识别,银行卡识别,驾驶证识别,行驶证识别,根据百度文字识别 api 封装,能快速识别身份证信息,银行卡信息,驾驶证信息,行驶证信息,使用非常方便
  11. AndroidOCR:基于Google Tesseract-OCR 文字识别 仿小猿搜题、作业帮
    1.MagicCamera:修改美颜图片
  12. MagicShow:包含美颜等40余种实时滤镜相机,可拍照、图片修改 图片编辑包含常规参数设置(对比度,饱和度等)、美颜(美白,磨皮)、滤镜
  13. MagicCamera素描
  14. TakePhoto:一款用于在Android设备上获取照片(拍照或从相册、文件中选择)、裁剪图片、压缩图片的开源工具库
  15. PictureSelector:Picture Selector Library for Android or 多图片选择器
  16. StickerCamera.贴纸标签相机,功能:拍照,相片裁剪,给图片贴贴纸,打标签。

扫描类 App

  • Office Lens
  • Scanbot
  • 扫描全能王
  • FineScanner
  • Scanner Pro

转载于:https://www.cnblogs.com/zhyantao/p/10738874.html

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是使用OpenCVSharp对扫描文档图片进行处理的代码: ```csharp using System; using System.Drawing; using System.IO; using OpenCvSharp; namespace DocumentScanner { class Program { static void Main(string[] args) { // Load input image Mat inputImage = Cv2.ImRead("input.jpg"); // Convert to grayscale Mat grayImage = new Mat(); Cv2.CvtColor(inputImage, grayImage, ColorConversionCodes.BGR2GRAY); // Apply thresholding to make text more visible Mat thresholdedImage = new Mat(); Cv2.Threshold(grayImage, thresholdedImage, 0, 255, ThresholdTypes.Binary | ThresholdTypes.Otsu); // Find contours of text regions Point[][] contours; HierarchyIndex[] hierarchy; Cv2.FindContours(thresholdedImage, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxSimple); // Find largest contour (which should be the document) int largestContourIndex = -1; double largestContourArea = 0; for (int i = 0; i < contours.Length; i++) { double contourArea = Cv2.ContourArea(contours[i]); if (contourArea > largestContourArea) { largestContourIndex = i; largestContourArea = contourArea; } } // Approximate polygon of largest contour Point2f[] approxPolygon; Cv2.ApproxPolyDP(contours[largestContourIndex], out approxPolygon, 0.02 * Cv2.ArcLength(contours[largestContourIndex], true), true); // Find bounding rectangle of polygon RotatedRect boundingRect = Cv2.MinAreaRect(approxPolygon); // Calculate rotation angle of bounding rectangle double angle = boundingRect.Angle; if (boundingRect.Size.Width < boundingRect.Size.Height) { angle += 90; } // Rotate image to correct for angle of bounding rectangle Mat rotatedImage = new Mat(); Point2f center = new Point2f(inputImage.Width / 2f, inputImage.Height / 2f); Mat rotationMatrix = Cv2.GetRotationMatrix2D(center, angle, 1); Cv2.WarpAffine(inputImage, rotatedImage, rotationMatrix, inputImage.Size, InterpolationFlags.Linear, BorderType.Replicate); // Crop image to remove black border Mat croppedImage = new Mat(); Cv2.GetRectSubPix(rotatedImage, boundingRect.Size, boundingRect.Center, croppedImage); // Resize image to A4 paper size Size a4Size = new Size(2480, 3508); // A4 paper size in pixels at 300 DPI Mat resizedImage = new Mat(); Cv2.Resize(croppedImage, resizedImage, a4Size); // Save output image Cv2.ImWrite("output.jpg", resizedImage); } } } ``` 该代码实现了以下操作: 1. 加载输入图像。 2. 将图像转换为灰度图像。 3. 应用二值化以使文本更清晰可见。 4. 找到文本区域的轮廓。 5. 找到最大的轮廓(应该是文档)。 6. 近似最大轮廓的多边形。 7. 找到多边形的边界矩形。 8. 计算边界矩形的旋转角度。 9. 旋转图像以校正边界矩形的角度。 10. 裁剪图像以删除黑色边框。 11. 将图像大小调整为A4纸张大小。 12. 保存输出图像。 可以根据需要调整代码中的一些参数,例如二值化阈值、多边形近似精度和A4纸张大小。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值