Last active
June 21, 2024 12:26
-
-
Save hirocarma/401fb9d456ee9c5fbe5284b7273dcd95 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import os | |
| import sys | |
| import shutil | |
| import cv2 | |
| import numpy as np | |
| def main(): | |
| IMG_DIR = sys.argv[1] | |
| OUT_DIR = sys.argv[2] | |
| height = 1080 | |
| width = 1920 | |
| blank = np.zeros((height, width), np.uint8) | |
| blank += 255 | |
| if os.path.exists(OUT_DIR): | |
| shutil.rmtree(OUT_DIR) | |
| os.mkdir(OUT_DIR) | |
| files = os.listdir(IMG_DIR) | |
| files = sorted(files) | |
| img_file = IMG_DIR + '/'+ files[0] | |
| for file in files: | |
| img_file = IMG_DIR + '/'+ file | |
| fname = file.split('.')[0] | |
| img = cv2.imread(img_file) | |
| kernel_size = 15 | |
| sigma = 0 | |
| img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) | |
| img1 = cv2.GaussianBlur(img, (kernel_size, kernel_size), sigma) | |
| img2 = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY) | |
| akaze = cv2.AKAZE_create() | |
| kp1 = akaze.detect(img2) | |
| img_akaze = cv2.drawKeypoints(blank, kp1, None, color=(0,0,0), flags=0) | |
| cv2.imwrite(OUT_DIR + fname + '-akaze' + '.jpg', img_akaze) | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment