XMWAI 0.2.8__py3-none-any.whl → 0.2.92__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of XMWAI might be problematic. Click here for more details.
- XMWAI/__init__.py +3 -2
- XMWAI/trial_class.py +112 -0
- {xmwai-0.2.8.dist-info → xmwai-0.2.92.dist-info}/METADATA +3 -1
- {xmwai-0.2.8.dist-info → xmwai-0.2.92.dist-info}/RECORD +7 -7
- {xmwai-0.2.8.dist-info → xmwai-0.2.92.dist-info}/WHEEL +0 -0
- {xmwai-0.2.8.dist-info → xmwai-0.2.92.dist-info}/licenses/LICENSE.txt +0 -0
- {xmwai-0.2.8.dist-info → xmwai-0.2.92.dist-info}/top_level.txt +0 -0
XMWAI/__init__.py
CHANGED
|
@@ -2,8 +2,9 @@ from .core import story, photo, reply, poem, crack # 从子模块导入函数
|
|
|
2
2
|
from .magic_core import birthday # 从子模块导入函数到顶层
|
|
3
3
|
from .bomb_core import bomb # 从子模块导入函数到顶层
|
|
4
4
|
from .idiom_core import idiom, searchIdiom, get_json_path # 从子模块导入函数到顶层
|
|
5
|
-
from .trial_class import make, get_file_content_as_base64, save_pic, detect_windows_scale # 从子模块导入函数到顶层
|
|
5
|
+
from .trial_class import make, get_file_content_as_base64, save_pic, detect_windows_scale, get_file_content_as_base64_2, cartoon # 从子模块导入函数到顶层
|
|
6
6
|
|
|
7
7
|
__all__ = ["story", "photo", "reply", "poem", 'birthday', 'bomb',
|
|
8
8
|
"idiom", "searchIdiom", "get_json_path", "crack",
|
|
9
|
-
"make", "get_file_content_as_base64", "save_pic", "detect_windows_scale"
|
|
9
|
+
"make", "get_file_content_as_base64", "save_pic", "detect_windows_scale",
|
|
10
|
+
"get_file_content_as_base64_2", "cartoon"] # 可选:明确导出的内容
|
XMWAI/trial_class.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import base64
|
|
2
|
+
import tkinter as tk
|
|
2
3
|
import urllib
|
|
3
4
|
import requests
|
|
4
5
|
import json
|
|
@@ -8,6 +9,10 @@ from io import BytesIO
|
|
|
8
9
|
import time
|
|
9
10
|
import os
|
|
10
11
|
import ctypes
|
|
12
|
+
import cv2
|
|
13
|
+
import numpy as np
|
|
14
|
+
|
|
15
|
+
'''-----------体验课1-----------'''
|
|
11
16
|
|
|
12
17
|
|
|
13
18
|
def make(screen):
|
|
@@ -169,3 +174,110 @@ def detect_windows_scale():
|
|
|
169
174
|
print(f"检测缩放比例时出错: {e}")
|
|
170
175
|
print("使用默认缩放比例1.0")
|
|
171
176
|
return 1.0
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
'''-----------体验课2-----------'''
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def get_file_content_as_base64_2(path, urlencoded=False):
|
|
183
|
+
"""
|
|
184
|
+
获取文件base64编码
|
|
185
|
+
:param path: 文件路径
|
|
186
|
+
:param urlencoded: 是否对结果进行urlencoded
|
|
187
|
+
:return: base64编码信息
|
|
188
|
+
"""
|
|
189
|
+
with open(path, "rb") as f:
|
|
190
|
+
content = base64.b64encode(f.read()).decode("utf8")
|
|
191
|
+
if urlencoded:
|
|
192
|
+
content = urllib.parse.quote_plus(content)
|
|
193
|
+
return content
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def cartoon(name):
|
|
197
|
+
"""
|
|
198
|
+
使用 AK,SK 生成鉴权签名(Access Token)
|
|
199
|
+
:return: access_token,或是None(如果错误)
|
|
200
|
+
"""
|
|
201
|
+
API_KEY = "LjdoA5Ar7MGrwynZfTFcB7K3"
|
|
202
|
+
SECRET_KEY = "3htSVp4IhW8LIyetP5Yo8NdWvF0yNH0W"
|
|
203
|
+
url = "https://aip.baidubce.com/oauth/2.0/token"
|
|
204
|
+
params = {"grant_type": "client_credentials",
|
|
205
|
+
"client_id": API_KEY, "client_secret": SECRET_KEY}
|
|
206
|
+
s = str(requests.post(url, params=params).json().get("access_token"))
|
|
207
|
+
|
|
208
|
+
url = "https://aip.baidubce.com/rest/2.0/image-process/v1/selfie_anime?access_token=" + s
|
|
209
|
+
base64_string = get_file_content_as_base64_2("pic.jpg", True)
|
|
210
|
+
payload = "image={}".format(base64_string)
|
|
211
|
+
headers = {
|
|
212
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
213
|
+
'Accept': 'application/json'
|
|
214
|
+
}
|
|
215
|
+
response = requests.request(
|
|
216
|
+
"POST", url, headers=headers, data=payload.encode("utf-8"))
|
|
217
|
+
base64_data = response.json()["image"]
|
|
218
|
+
image_data = base64.b64decode(base64_data)
|
|
219
|
+
with open("img.png", 'wb') as f:
|
|
220
|
+
f.write(image_data)
|
|
221
|
+
|
|
222
|
+
photo = cv2.imread('img.png')
|
|
223
|
+
original = cv2.imread('pic.jpg')
|
|
224
|
+
height, width = photo.shape[:2]
|
|
225
|
+
|
|
226
|
+
# 扫描效果参数
|
|
227
|
+
scan_bar_height = 60 # 扫描光带高度
|
|
228
|
+
glow_width = 15 # 光晕宽度
|
|
229
|
+
glow_intensity = 0.3 # 光晕强度
|
|
230
|
+
scan_speed = 5 # 扫描速度(毫秒)
|
|
231
|
+
|
|
232
|
+
# 创建一个与图像大小相同的透明层用于绘制扫描效果
|
|
233
|
+
overlay = np.zeros_like(original, dtype=np.uint8)
|
|
234
|
+
|
|
235
|
+
for i in range(-scan_bar_height, height + scan_bar_height):
|
|
236
|
+
# 创建一个空白图像
|
|
237
|
+
display = original.copy()
|
|
238
|
+
# 只显示扫描到的部分
|
|
239
|
+
if i > 0:
|
|
240
|
+
display[:min(i, height), :] = photo[:min(i, height), :]
|
|
241
|
+
|
|
242
|
+
# 清除上一帧的扫描效果
|
|
243
|
+
overlay.fill(0)
|
|
244
|
+
|
|
245
|
+
# 计算扫描光带位置
|
|
246
|
+
scan_start = max(0, i - scan_bar_height // 2)
|
|
247
|
+
scan_end = min(height, i + scan_bar_height // 2)
|
|
248
|
+
|
|
249
|
+
if scan_start < scan_end:
|
|
250
|
+
# 创建渐变扫描光带
|
|
251
|
+
for y in range(scan_start, scan_end):
|
|
252
|
+
# 计算渐变因子(0-1-0)
|
|
253
|
+
distance_from_center = abs(y - i)
|
|
254
|
+
gradient_factor = 1.0 - \
|
|
255
|
+
(distance_from_center / (scan_bar_height / 2))
|
|
256
|
+
|
|
257
|
+
# 绿色扫描线主体
|
|
258
|
+
green_intensity = int(255 * gradient_factor)
|
|
259
|
+
overlay[y, :, 1] = green_intensity
|
|
260
|
+
|
|
261
|
+
# 添加轻微的蓝色调,使扫描线更真实
|
|
262
|
+
overlay[y, :, 2] = int(60 * gradient_factor)
|
|
263
|
+
|
|
264
|
+
# 添加光晕效果
|
|
265
|
+
for y in range(max(0, scan_start - glow_width), min(height, scan_end + glow_width)):
|
|
266
|
+
if y < scan_start or y >= scan_end:
|
|
267
|
+
# 计算光晕强度
|
|
268
|
+
distance_from_edge = min(
|
|
269
|
+
abs(y - scan_start), abs(y - scan_end))
|
|
270
|
+
glow_factor = max(
|
|
271
|
+
0, 1.0 - (distance_from_edge / glow_width)) * glow_intensity
|
|
272
|
+
|
|
273
|
+
# 添加绿色光晕
|
|
274
|
+
overlay[y, :, 1] = np.clip(
|
|
275
|
+
overlay[y, :, 1] + (255 * glow_factor), 0, 255)
|
|
276
|
+
|
|
277
|
+
# 将半透明扫描效果叠加到图像上
|
|
278
|
+
alpha = 0.5 # 透明度
|
|
279
|
+
cv2.addWeighted(overlay, alpha, display, 1 - alpha, 0, display)
|
|
280
|
+
|
|
281
|
+
# 显示稳定的扫描效果
|
|
282
|
+
cv2.imshow(name, display)
|
|
283
|
+
cv2.waitKey(scan_speed) # 控制扫描速度
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: XMWAI
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.92
|
|
4
4
|
Summary: Small code King AI related library
|
|
5
5
|
Home-page: https://github.com/Tonykai88/XMWAI.git
|
|
6
6
|
Author: pydevelopment
|
|
@@ -13,6 +13,8 @@ Description-Content-Type: text/markdown
|
|
|
13
13
|
License-File: LICENSE.txt
|
|
14
14
|
Requires-Dist: requests>=2.32.3
|
|
15
15
|
Requires-Dist: Pillow>=11.1.0
|
|
16
|
+
Requires-Dist: opencv-python>=3.4.18.65
|
|
17
|
+
Requires-Dist: numpy>=2.2.3
|
|
16
18
|
Dynamic: author
|
|
17
19
|
Dynamic: author-email
|
|
18
20
|
Dynamic: classifier
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
XMWAI/__init__.py,sha256=
|
|
1
|
+
XMWAI/__init__.py,sha256=Kz93zgrnLiGqlqCp6y8Y4McEBJOznvQrS-IPhwsvCTw,795
|
|
2
2
|
XMWAI/bomb_core.py,sha256=h2ZPH3SuoG2L_XOf1dcK8p3lhw5QzhneWl2yMLj1RiU,1819
|
|
3
3
|
XMWAI/cookbook_core.py,sha256=mo3IYgh_bYD_3vH2Stkjwo9okFOb4abooZeJ-Djx6VU,3675
|
|
4
4
|
XMWAI/core.py,sha256=SxzfbOW7WZALuA5fQ4dGieJR2-roxufjXQ_mqwGDg3E,7905
|
|
5
5
|
XMWAI/idiom_core.py,sha256=yU-VHhqqoutVm6GVikcjL3m9yuB1hUsFBpPYvwY4n5g,1689
|
|
6
6
|
XMWAI/magic_core.py,sha256=Ms4b12PJ8rjsmceg1VUqWCWx2ebvdhLp4sIF6K_Vaok,3491
|
|
7
|
-
XMWAI/trial_class.py,sha256=
|
|
7
|
+
XMWAI/trial_class.py,sha256=GRDEe24a-DYMRyoTLgJbE5dCSQY0CbYqB5ALsBfYmtA,10226
|
|
8
8
|
XMWAI/file/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
9
|
XMWAI/file/idiom.json,sha256=HUtPRUzhxBbWoasjadbmbA_5ngQ5AXLu9weQSZ4hzhk,10319857
|
|
10
10
|
XMWAI/gif/0.gif,sha256=LGpAReVTyZEb1J-bWYTpxxHbIxmLJ-3wA0lw4cBqdsY,303
|
|
@@ -94,8 +94,8 @@ XMWAI/gif/84.gif,sha256=6Ip_uQmvrr2fagLXu1YqWyI_DL2PVVtKCPtmNtzt3P4,38767
|
|
|
94
94
|
XMWAI/gif/85.gif,sha256=6Ip_uQmvrr2fagLXu1YqWyI_DL2PVVtKCPtmNtzt3P4,38767
|
|
95
95
|
XMWAI/gif/9.gif,sha256=cPouth-xwc3QPcg2m6HMP2OD1ZCeRBD_-RPImvvKAA0,9485
|
|
96
96
|
XMWAI/gif/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
97
|
-
xmwai-0.2.
|
|
98
|
-
xmwai-0.2.
|
|
99
|
-
xmwai-0.2.
|
|
100
|
-
xmwai-0.2.
|
|
101
|
-
xmwai-0.2.
|
|
97
|
+
xmwai-0.2.92.dist-info/licenses/LICENSE.txt,sha256=bcaIQMrIhdQ3O-PoZlexjmW6h-wLGvHxh5Oksl4ohtc,1066
|
|
98
|
+
xmwai-0.2.92.dist-info/METADATA,sha256=HBB0ZboyecpyuZgrAr7bG8zobiUs3FIm0JiGuLQl7r4,1135
|
|
99
|
+
xmwai-0.2.92.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
100
|
+
xmwai-0.2.92.dist-info/top_level.txt,sha256=yvGcDI-sggK5jqd9wz0saipZvk3oIE3hNGHlqUjxf0c,6
|
|
101
|
+
xmwai-0.2.92.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|