Skip to content

Commit 5f76562

Browse files
committed
focss edit on laptop
0 parents  commit 5f76562

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1435
-0
lines changed

.gitattributes

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.traineddata filter=lfs diff=lfs merge=lfs binary
2+
*.xlsx filter=lfs diff=lfs merge=lfs binary
3+
*.png filter=lfs diff=lfs merge=lfs binary
4+
*.xml filter=lfs diff=lfs merge=lfs text

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
~*

BigData/BigData_FiringList.xlsx

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:2bbae5f146b8ea410785ce61373a7bb8220fc82b10fc834fed6d75ad093b5205
3+
size 5709

Ref/Ammo/0.png

+3

Ref/Ammo/1.png

+3

Ref/Ammo/2.png

+3

Ref/Ammo/3.png

+3

Ref/Ammo/4.png

+3

Ref/Ammo/5.png

+3

Ref/Ammo/6.png

+3

Ref/Ammo/7.png

+3

Ref/Ammo/8.png

+3

Ref/Ammo/9.png

+3

Ref/DmgLogo/DmgLogo.png

+3

Ref/Weapons/30-30.png

+3

Ref/Weapons/CAR.png

+3

Ref/Weapons/EVA-8.png

+3

Ref/Weapons/G7侦查枪.png

+3

Ref/Weapons/L-STAR能量机枪.png

+3

Ref/Weapons/P2020手枪.png

+3

Ref/Weapons/R-301卡宾枪.png

+3

Ref/Weapons/R-99冲锋枪.png

+3

Ref/Weapons/RE-45自动手枪.png

+3

Ref/Weapons/三重式狙击枪.png

+3

Ref/Weapons/专注轻机枪.png

+3

Ref/Weapons/充能步枪.png

+3

Ref/Weapons/克雷贝尔狙击枪.png

+3
+3

Ref/Weapons/哈沃克步枪.png

+3

Ref/Weapons/哨兵狙击步枪.png

+3

Ref/Weapons/喷火轻机枪.png

+3

Ref/Weapons/复仇女神.png

+3

Ref/Weapons/平行步枪.png

+3

Ref/Weapons/敖犬霰弹枪.png

+3

Ref/Weapons/暴走.png

+3

Ref/Weapons/波塞克.png

+3

Ref/Weapons/狙击目标.png

+3

Ref/Weapons/猎兽冲锋枪.png

+3

Ref/Weapons/电能冲锋枪.png

+3

Ref/Weapons/莫桑比克.png

+3
+3

Ref/Weapons/转换者冲锋枪.png

+3

Ref/Weapons/转轮机枪.png

+3

Ref/Weapons/辅助手枪.png

+3

Ref/Weapons/长弓.png

+3

Tesseract traineddata/num.traineddata

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:61b15d41411a5982b1275b8cafd260bea65259aeb6c42eb704898c6e6cb0294d
3+
size 15400601

__pycache__/ammo_ocr.cpython-37.pyc

2.18 KB
Binary file not shown.
6.3 KB
Binary file not shown.

__pycache__/damage_ocr.cpython-37.pyc

2.57 KB
Binary file not shown.
365 Bytes
Binary file not shown.
558 Bytes
Binary file not shown.
620 Bytes
Binary file not shown.
1.75 KB
Binary file not shown.
2.61 KB
Binary file not shown.
3.07 KB
Binary file not shown.

ammo_ocr.py

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import cv2
2+
import numpy as np
3+
import os
4+
from func_cv_imread import cv_imread
5+
from func_img_proc import img_similarity, black_area
6+
import pandas as pd
7+
8+
9+
def cut_ammo(img: np.ndarray) -> np.ndarray: # 裁切主弹夹弹药数字
10+
img_cut = img[961:1000, 1700:1785]
11+
return img_cut
12+
13+
14+
def binary_ammo(img: np.ndarray) -> np.ndarray: # 弹药数字图二值化
15+
img_binary = cv2.threshold(img, 215, 255, cv2.THRESH_BINARY_INV)[1]
16+
return img_binary
17+
18+
19+
def ammo_ocr_img_process(img: np.ndarray) -> np.ndarray: # 预处理弹药数字图
20+
if img.ndim > 2:
21+
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
22+
return binary_ammo(cut_ammo(img))
23+
24+
25+
def digit2(img: np.ndarray) -> np.ndarray: # 百位数
26+
return img[3:34, 3:26]
27+
28+
29+
def digit1(img: np.ndarray) -> np.ndarray: # 十位数
30+
return img[3:34, 30:53]
31+
32+
33+
def digit0(img: np.ndarray) -> np.ndarray: # 个位数
34+
return img[3:34, 57:80]
35+
36+
37+
def ammo_recognize_1_digit(img: np.ndarray) -> int:
38+
if black_area(img) < 80:
39+
return None
40+
reffiledir = './Ref/Ammo/'
41+
maxn = 10
42+
similarity = np.zeros([maxn, 1], dtype=np.uint16)
43+
for i in range(maxn):
44+
img_Ref = cv2.imread(reffiledir + str(i) + '.png', 0)
45+
sim = img_similarity(img, img_Ref)
46+
similarity[i, 0] = sim
47+
maxsimnum = np.max(similarity)
48+
maxsimname = np.where(similarity == np.max(similarity))[0][0]
49+
if maxsimnum < 300:
50+
return None
51+
return maxsimname
52+
53+
54+
def ammo_recognize_cv(img: np.ndarray, digits: int) -> int:
55+
img = ammo_ocr_img_process(img)
56+
ammo_num = ammo_recognize_1_digit(digit0(img))
57+
if ammo_num is None:
58+
return None
59+
if digits > 1:
60+
d1 = ammo_recognize_1_digit(digit1(img))
61+
if d1 is not None:
62+
ammo_num += 10 * d1
63+
if digits == 3:
64+
d2 = ammo_recognize_1_digit(digit2(img))
65+
if d2 is not None:
66+
ammo_num += 100 * d2
67+
return ammo_num
68+
69+
70+
if __name__ == '__main__':
71+
# Ammo_Train_Generate()
72+
pass

0 commit comments

Comments
 (0)