医疗数据组工具脚本--2

医疗数据组工具脚本-2

获取图片中身份证号码中信息,户籍地址信息

打开窗体
打开图片
获取图片中身份证信息
在文本框中验证修改信息
将文本框内容导入excel
切换图片

tkinter编写窗体-代码示例

class  Project:
    def __init__(self,root,isTKroot = True):
        
        self.root = root
        self.root.title("微信身份证信息获取-填入信息录入excel")
        self.root['background'] = '#efefef'
        self.root.geometry('556x581+10+10')
    
    def set__init(self):
        #Create the elements of root 
        self.Text_2= tkinter.Text(root)
        self.Text_2.place(x = 100,y = 50,width = 247,height = 49)
        self.Text_2.configure(relief = "sunken",font=(14))


        self.Button_20= tkinter.Button(root,text="获取信息",width = 10,height = 4,command=self.Button20)
        self.Button_20.place(x = 400,y = 50,width = 100,height = 200)
        
        self.Button_21= tkinter.Button(root,text="导入excel",width = 10,height = 4,command=self.Button21)
        self.Button_21.place(x = 400,y = 300,width = 100,height = 200)

win32gui查找需截图指定区域标题

hwnd_title = dict()
def get_all_hwnd(hwnd,mouse):
    if win32gui.IsWindow(hwnd) and win32gui.IsWindowEnabled(hwnd) and win32gui.IsWindowVisible(hwnd):
        hwnd_title.update({hwnd:win32gui.GetWindowText(hwnd)})

def find_title():
    win32gui.EnumWindows(get_all_hwnd, 0)
    for h,t in hwnd_title.items():
        if "图片查看" in t:
            #print(h, t)
            title=t
            break
    return title

paddleocr识别PyQt5截图区域的图片

def get_text():
    img_path = 'screenshot.jpg'
    title=find_title()
    hwnd = win32gui.FindWindow(None, title)
    app = QApplication(sys.argv)
    screen = QApplication.primaryScreen()
    img = screen.grabWindow(hwnd).toImage()
    img.save(img_path)
    
    ocr = PaddleOCR( lang="ch",use_gpu=False)  # need to run only once to download and load model into memory
    img_path =img_path
    result = ocr.ocr(img_path)
    lines=[]
    for line in result:
      lines.append(line[-1][0])
    return lines

验证身份证中信息,将识别内容整理显示在text框中

  def Button20(self):
        self.Label_22['text']="分析图片中,请等待。"
        
        ID,AD,NAME=get_all()
        DIC=validator.get_info(ID)
        AGE=DIC['age']
        SEX=DIC['sex']
        if SEX==1:
            SEX='男'
        else:
            SEX='女'
        now=datetime.datetime.now()
        NOW=now.strftime('%Y-%m-%d %H:%M:%S')    
        self.Text_2.delete(1.0,END)#房间号     NUM
        self.Text_3.delete(1.0,END)#姓名      NAME`
        self.Text_4.delete(1.0,END)#年龄      AGE`
        self.Text_5.delete(1.0,END)#身份证号   ID`
        self.Text_6.delete(1.0,END)#性别      SEX`
        self.Text_7.delete(1.0,END)#户籍地     AD`
        self.Text_8.delete(1.0,END)#联系电话  PHONE
        self.Text_9.delete(1.0,END)#住址      HOME`
        self.Text_10.delete(1.0,END)#入住时间  NOW
        #text_2.insert(INSERT,NUM)#房间号     NUM
        self.Text_3.insert(INSERT,NAME)#姓名      NAME`
        self.Text_4.insert(INSERT,AGE)#年龄      AGE`
        self.Text_5.insert(INSERT,ID)#身份证号   ID`
        self.Text_6.insert(INSERT,SEX)#性别      SEX`
        self.Text_7.insert(INSERT,AD)#户籍地     AD`
        #text_8.insert(INSERT,PHONE)#联系电话  PHONE
        #text_9.delete()#住址      HOME`
        self.Text_10.insert(INSERT,NOW)#入住时间  NOW
        self.Label_22['text']="图片分析结束,请修正信息。"

导出到excel表中

 def Button21(self):
      self.Label_22['text']="开始文件导入工作。"
      NUM=self.Text_2.get(1.0,END)
      NAME=self.Text_3.get(1.0,END)
      AGE=self.Text_4.get(1.0,END)
      ID=self.Text_5.get(1.0,END)
      SEX=self.Text_6.get(1.0,END)
      AD=self.Text_7.get(1.0,END)
      PHONE=self.Text_8.get(1.0,END)
      HOME=self.Text_9.get(1.0,END)
      NOW=self.Text_10.get(1.0,END)
      data=pd.read_excel('data.xlsx',dtype=str)
      #房间号	姓名	年龄	身份证号码	性别	户籍地	联系电话 	住址	入住时间
      li1=data.columns[3:12]
      li2=[NUM,NAME,AGE,ID,SEX,AD,PHONE,HOME,NOW]
      dic=dict(zip(li1,li2))
      df=pd.DataFrame(dic,index=[0])
      data=pd.concat([data,df],axis=0,ignore_index=True)
      data.to_excel('data.xlsx',index=False)
      self.Label_22['text']="导入完成,请继续。"
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值