Giter Club home page Giter Club logo

ruia_ocr's Introduction

ruia_ocr

介绍

一款ruia_ocr插件, 使用baidu-aip接口识别本地或远程图片

安装教程

  1. python setup.py install

使用说明

实现BaseOcrService

from ruia import Item
from ruia_ocr import (OcrField, BaiduOcrService, OcrSpider, OcrResponse, 
                     OcrRequest)

app_id = 'xxxx'
api_key ='xxxx' 
secret_key = 'xxxx'

img = ".\test.jpg"
img2 = ".\test2.png"
img3 = r'http://static.zongheng.com/upload/cover/07/f9/07f9c3d9899a7df6284c1d340d45ba8c.jpeg'
    
class OcrItem(Item):
    title = OcrField(re_select=r'.*')

class MySpider(OcrSpider):

    ocr_service = BaiduOcrService(app_id, api_key, secret_key)

    # ocr_region:str  x1,y1,x2,y2;...
    # default: '' means  the whole picture to ocr
    # 1,1,0.5,0.5 means: cut from image 1,1, image.width * 0.5, image.height * 0.5
    # 1,1,200,200 means: cut from image 1,1,200,200 
    # 1,1,0.5,0.5;0.5,0.5,0.99,0.99 means: 
    #   cut from image 1,1,image.width * 0.5, image.height * 0.5 get image1  
    #   cut from image image.width*0.5, image.height*0.5 ,image.width*0.99, image.height*0.99  get image2
    #   stitching image1 image2 by row get new image to ocr
    ocr_region = '1,1,0.5,0.99'

    start_urls = [img, img2, img3]

    concurrency = 1

    async def parse(self, response: OcrResponse):
        item = await OcrItem.get_item(html=await response.text())
        return item

TIPS:
    use OcrRequest(url=image_source, sevice=ocr_service)


        

if __name__ == '__main__':
    MySpider.start()

ruia_ocr's People

Contributors

fffoobibi avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.