mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-07 04:40:00 +08:00
添加 反吞图模块
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
import cv2
|
||||||
|
import random
|
||||||
|
import warnings
|
||||||
|
import numpy as np
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
|
||||||
|
def pixRandomChange(img):
|
||||||
|
# Image转cv2
|
||||||
|
img = cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR)
|
||||||
|
img[0, 0, 0] = random.randint(0, 0xfffffff)
|
||||||
|
# cv2转Image
|
||||||
|
img = Image.fromarray(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
|
||||||
|
return img
|
||||||
|
|
||||||
|
|
||||||
|
def pixRandomChangeFile(path):
|
||||||
|
# 注意:cv2.imread()不支持路径中文
|
||||||
|
warnings.filterwarnings("ignore", category=Warning)
|
||||||
|
img = cv2.imread(path)
|
||||||
|
img[0, 0, 0] = random.randint(0, 0xfffffff)
|
||||||
|
cv2.imwrite(path, img)
|
||||||
|
print('finish')
|
||||||
|
|
||||||
|
|
||||||
|
pixRandomChangeFile('./0.jpg')
|
||||||
Reference in New Issue
Block a user