lichong 7 months ago
parent
commit
ba54eeb584
  1. 16
      code/main.py
  2. BIN
      code/ocr/simple/ch_PP-OCRv4_det_infer.tar
  3. BIN
      code/ocr/simple/ch_PP-OCRv4_rec_infer.tar
  4. 30
      front/src/renderer/src/views/user.vue
  5. BIN
      front/地址.jpg
  6. BIN
      front/姓名.jpg
  7. BIN
      front/封印1.jpg
  8. BIN
      front/封印2.jpg
  9. BIN
      front/当前有功.jpg
  10. BIN
      front/电表资产号.jpg
  11. BIN
      ppocr/mobile_v2.0_det_infer/inference.pdiparams
  12. BIN
      ppocr/mobile_v2.0_det_infer/inference.pdiparams.info
  13. BIN
      ppocr/mobile_v2.0_det_infer/inference.pdmodel
  14. BIN
      地址.jpg
  15. BIN
      姓名.jpg
  16. BIN
      封印1.jpg
  17. BIN
      封印2.jpg
  18. BIN
      当前有功.jpg
  19. BIN
      电表资产号.jpg

16
code/main.py

@ -1,4 +1,4 @@
from flask import Flask,request,jsonify from flask import Flask,request
from flask_cors import CORS from flask_cors import CORS
from ultralytics import YOLO from ultralytics import YOLO
import base64 import base64
@ -61,10 +61,10 @@ def startOcr():
img = image img = image
results = model.predict(image, device='cpu') results = model.predict(image, device='cpu')
ocr=None ocr=None
# if ocrType=="complex": if ocrType=="complex":
# ocr=ocrComplex ocr=ocrComplex
# else: else:
ocr=ocrSimple ocr=ocrSimple
for r in results: for r in results:
boxes = r.boxes boxes = r.boxes
@ -91,7 +91,7 @@ def startOcr():
'target_2': [], 'target_2': [],
'target_3': [] 'target_3': []
} }
returnObj={"hasError":False,"resultsObj":{},"message":''} returnObj={"resultsObj":{},"message":''}
resultAll={} resultAll={}
# 检查类别数量 # 检查类别数量
if (len(target_0) == 2 and len(target_1) == 1 and (len(target_2) == 1 or len(target_2) == 2) and len(target_3) == 2): if (len(target_0) == 2 and len(target_1) == 1 and (len(target_2) == 1 or len(target_2) == 2) and len(target_3) == 2):
@ -183,10 +183,10 @@ def startOcr():
else: else:
returnObj["resultsObj"]={} returnObj["resultsObj"]={}
returnObj["message"]="图像不清晰或要素不全请重新拍摄或人工记录" returnObj["message"]="图像不清晰或要素不全请重新拍摄或人工记录"
returnObj["hasError"]=True
# endTime=time.time() # endTime=time.time()
# print("运行时间:",endTime-startTime) # print("运行时间:",endTime-startTime)
return jsonify(returnObj) print("运行时间:",returnObj)
return returnObj
if __name__ == "__main__": if __name__ == "__main__":
app.run(host="0.0.0.0", port=7003) app.run(host="0.0.0.0", port=7003)

BIN
code/ocr/simple/ch_PP-OCRv4_det_infer.tar

Binary file not shown.

BIN
code/ocr/simple/ch_PP-OCRv4_rec_infer.tar

Binary file not shown.

30
front/src/renderer/src/views/user.vue

@ -20,7 +20,7 @@
<span>清空</span> <span>清空</span>
</el-button> </el-button>
<div class="inputClass uploadClass"> <div class="inputClass uploadClass">
<el-upload :show-file-list="false" v-model="fileOriData" :before-upload="beforeAvatarUpload" <el-upload multiple :show-file-list="false" v-model="fileOriData" :before-upload="beforeAvatarUpload"
:http-request="successSubmit" accept=".png, .jpg ,jpeg"> :http-request="successSubmit" accept=".png, .jpg ,jpeg">
<el-button type="success"> <el-button type="success">
<el-icon> <el-icon>
@ -101,7 +101,8 @@ export default {
formHeader: [], formHeader: [],
formData: {} formData: {}
}, },
fileOriData: [] fileOriData: [],
displayedMessages: [],//
} }
}, },
methods: { methods: {
@ -120,16 +121,28 @@ export default {
} }
return true return true
}, },
// //
async successSubmit(opts) { async successSubmit(opts) {
if (!this.displayedMessages.includes("识别中...")) {
this.displayedMessages.push("识别中...")
ElMessage.info({
message: '识别中...',
duration: 0
})
} else {
this.displayedMessages.push("识别中...")
}
let that = this let that = this
let file = opts.file let file = opts.file
this.fileDealData = [] this.fileDealData = []
let fileReader = new FileReader() let fileReader = new FileReader()
fileReader.onload = async function () { fileReader.onload = async function () {
let base64Data = fileReader.result; let base64Data = fileReader.result;
window.electron.ipcRenderer.send('ocrIdentify', { base64Str: base64Data }) let params = {
console.log(9999, base64Data) base64Str: base64Data,
ocrType: "complex",//:complex_simple_
}
window.electron.ipcRenderer.send('ocrIdentify', params)
} }
fileReader.onerror = function (error) { fileReader.onerror = function (error) {
console.error('Error reading file:', error) console.error('Error reading file:', error)
@ -141,11 +154,16 @@ export default {
let that = this let that = this
window.electron.ipcRenderer.on('ocrResult', (eve, res) => { window.electron.ipcRenderer.on('ocrResult', (eve, res) => {
console.log(97111, res) console.log(97111, res)
if (that.displayedMessages.includes("识别中...")) {
that.displayedMessages.splice(that.displayedMessages.indexOf("识别中..."), 1)
} else {
ElMessage.closeAll()
}
}) })
}, },
// //
async updateSeach(params = {}) { async updateSeach(params = {}) {
console.log(777, params) // console.log(777, params)
}, },
// //
async searchData() { async searchData() {

BIN
front/地址.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

BIN
front/姓名.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

BIN
front/封印1.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

BIN
front/封印2.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

BIN
front/当前有功.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

BIN
front/电表资产号.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 163 KiB

BIN
ppocr/mobile_v2.0_det_infer/inference.pdiparams

Binary file not shown.

BIN
ppocr/mobile_v2.0_det_infer/inference.pdiparams.info

Binary file not shown.

BIN
ppocr/mobile_v2.0_det_infer/inference.pdmodel

Binary file not shown.

BIN
地址.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

BIN
姓名.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

BIN
封印1.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

BIN
封印2.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

BIN
当前有功.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

BIN
电表资产号.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 163 KiB

Loading…
Cancel
Save