-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
982abaa
commit d51f45d
Showing
5 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
Version 2, December 2004 | ||
|
||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> | ||
|
||
Everyone is permitted to copy and distribute verbatim or modified | ||
copies of this license document, and changing it is allowed as long | ||
as the name is changed. | ||
|
||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | ||
|
||
0. You just DO WHAT THE FUCK YOU WANT TO. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# SDDT-plates-decrypter | ||
|
||
## Usage | ||
|
||
Place the `.exe` file under the `.png` file that needs to be decrypted and open it, the program will do everything. | ||
|
||
## Build | ||
|
||
Run `pyinstaller decrypter.py -i "icon.ico" --onefile`, the executable file will compiled in the `dist` folder. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import fnmatch | ||
import io | ||
import os | ||
import cv2 | ||
import numpy as np | ||
|
||
i = 0 | ||
|
||
os.makedirs("Plates", exist_ok=True) | ||
os.makedirs("Plates/Original", exist_ok=True) | ||
os.makedirs("Plates/Alpha", exist_ok=True) | ||
os.makedirs("Plates/Split", exist_ok=True) | ||
|
||
for filename in os.listdir(os.getcwd()): | ||
if fnmatch.fnmatch(filename, f"UI_UserPlate_*.png"): | ||
print(f"{filename}...", end="") | ||
|
||
image = cv2.imread(filename) | ||
|
||
b, g, r = cv2.split(image) | ||
|
||
# 原通道的 Grean 是 Y 通道 | ||
y = g | ||
|
||
# 原通道的 Blue 左半边是 U 通道,右半边是 V 通道 | ||
# 拉伸处理过后的 UV 通道图片 | ||
# cv2.resize(img[x:h, y:w], (w, h)) | ||
u = cv2.resize(b[0:296, 0:540], (1080, 296)) | ||
v = cv2.resize(b[0:296, 540:1080], (1080, 296)) | ||
|
||
# https://stackoverflow.com/questions/60729170/python-opencv-converting-planar-yuv-420-image-to-rgb-yuv-array-format | ||
# 开一个基于内存的比特流 | ||
f = io.BytesIO() | ||
|
||
# 把 YUV 通道的图片写入比特流 | ||
f.write(y.tobytes()) | ||
f.write(u.tobytes()) | ||
f.write(v.tobytes()) | ||
|
||
# 回到内存的第 0 个索引(回到开头) | ||
f.seek(0) | ||
|
||
# 读取 YUV 通道并重写为相同长宽的 numpy 数组(行列式) | ||
y = np.frombuffer(f.read(y.size), dtype=np.uint8).reshape((y.shape[0], y.shape[1])) # Read Y color channel and reshape to height x width numpy array | ||
u = np.frombuffer(f.read(y.size), dtype=np.uint8).reshape((y.shape[0], y.shape[1])) # Read U color channel and reshape to height x width numpy array | ||
v = np.frombuffer(f.read(y.size), dtype=np.uint8).reshape((y.shape[0], y.shape[1])) # Read V color channel and reshape to height x width numpy array | ||
|
||
yvu = cv2.merge((y, v, u)) | ||
|
||
# YUV 转 BGR | ||
bgr = cv2.cvtColor(yvu, cv2.COLOR_YCrCb2BGR) | ||
|
||
# BGR 转 BGRA | ||
bgra = cv2.cvtColor(bgr, cv2.COLOR_BGR2BGRA) | ||
|
||
# 给丫 Alpha 通道干进去 | ||
bgra[:, :, 3] = r | ||
|
||
filename = filename.replace(".png", "") | ||
cv2.imwrite(f"./Plates/Original/{filename}.png", bgr) | ||
cv2.imwrite(f"./Plates/Alpha/{filename}.png", bgra) | ||
cv2.imwrite(f"./Plates/Split/{filename}_Upper.png", bgra[:168, :]) | ||
cv2.imwrite(f"./Plates/Split/{filename}_Lower.png", bgra[168:, :]) | ||
|
||
i += 1 | ||
|
||
print("Done") | ||
|
||
if i != 0: | ||
print(f"{i} plates processed.") | ||
else: | ||
print(f"Can't find any plates. Make sure you have placed exe file in the directory where you need to decrypt plates.") | ||
|
||
os.system('pause') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
numpy==1.21.4 | ||
opencv-python==4.5.5.64 | ||
pyinstaller==4.10 |