-
Notifications
You must be signed in to change notification settings - Fork 236
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
Showing
7 changed files
with
107 additions
and
39 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
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
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,60 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding:utf-8 -*- | ||
# Author: kerlomz <[email protected]> | ||
|
||
import cv2 | ||
import numpy as np | ||
from PIL import ImageSequence | ||
|
||
|
||
def split_frames(image_obj, need_frame=None): | ||
image_seq = ImageSequence.all_frames(image_obj) | ||
image_arr_last = [np.asarray(image_seq[-1])] if -1 in need_frame and len(need_frame) > 1 else [] | ||
image_arr = [np.asarray(item) for i, item in enumerate(image_seq) if (i in need_frame or need_frame == [-1])] | ||
image_arr += image_arr_last | ||
return image_arr | ||
|
||
|
||
def concat_arr(img_arr): | ||
if len(img_arr) < 2: | ||
return img_arr[0] | ||
all_slice = img_arr[0] | ||
for im_slice in img_arr[1:]: | ||
all_slice = np.concatenate((all_slice, im_slice), axis=1) | ||
return all_slice | ||
|
||
|
||
def numpy_to_bytes(numpy_arr): | ||
cv_img = cv2.imencode('.png', numpy_arr)[1] | ||
img_bytes = bytes(bytearray(cv_img)) | ||
return img_bytes | ||
|
||
|
||
def concat_frames(image_obj, need_frame=None): | ||
if not need_frame: | ||
need_frame = [0] | ||
img_arr = split_frames(image_obj, need_frame) | ||
img_arr = concat_arr(img_arr) | ||
return img_arr | ||
|
||
|
||
def blend_arr(img_arr): | ||
if len(img_arr) < 2: | ||
return img_arr[0] | ||
all_slice = img_arr[0] | ||
for im_slice in img_arr[1:]: | ||
all_slice = cv2.addWeighted(all_slice, 0.5, im_slice, 0.5, 0) | ||
all_slice = cv2.equalizeHist(all_slice) | ||
return all_slice | ||
|
||
|
||
def blend_frame(image_obj, need_frame=None): | ||
if not need_frame: | ||
need_frame = [-1] | ||
img_arr = split_frames(image_obj, need_frame) | ||
img_arr = blend_arr(img_arr) | ||
return img_arr | ||
|
||
|
||
if __name__ == "__main__": | ||
pass |
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
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
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 |
---|---|---|
|
@@ -37,7 +37,7 @@ coll = COLLECT(exe, | |
strip=False, | ||
upx=True, | ||
upx_exclude=[], | ||
name='app') | ||
name='captcha_platform_tornado_gpu') | ||
|
||
|
||
|
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