--- subfuction/image_crop.py
+++ subfuction/image_crop.py
... | ... | @@ -1,7 +1,5 @@ |
1 | 1 |
import cv2 |
2 | 2 |
import os |
3 |
-import glob |
|
4 |
-from joblib import Parallel, delayed |
|
5 | 3 |
|
6 | 4 |
def crop_image(image_path, crop_size, start_point): |
7 | 5 |
if image_path.endswith(".jpg") or image_path.endswith(".png"): |
... | ... | @@ -13,25 +11,4 @@ |
13 | 11 |
return cropped_image |
14 | 12 |
else: |
15 | 13 |
print(f"Image {os.path.basename(image_path)} is too small to be cropped with the current settings.") |
16 |
- return False |
|
17 |
- |
|
18 |
-def crop_images_parallel(image_paths, output_directory, crop_size, start_point): |
|
19 |
- if not os.path.exists(output_directory): |
|
20 |
- os.makedirs(output_directory) |
|
21 |
- |
|
22 |
- # run the cropping function in parallel |
|
23 |
- Parallel(n_jobs=-1)(delayed(crop_image)(image_path, output_directory, crop_size, start_point) for image_path in image_paths) |
|
24 |
- |
|
25 |
-if __name__ == "__main__": |
|
26 |
- output_directory = "/home/takensoft/Pictures/test512_512/rainy/" |
|
27 |
- |
|
28 |
- # get all image paths in the directory |
|
29 |
- # image_paths = glob.glob("/home/takensoft/Pictures/화창한날, 비오는날 프레임2000장/화창한날 프레임 추출/하드디스크 화창한날(17개)/**/*.png") |
|
30 |
- # image_paths += glob.glob("/home/takensoft/Pictures/화창한날, 비오는날 프레임2000장/화창한날 프레임 추출/7월19일 화창한날(8개)/**/*.png") |
|
31 |
- image_paths = glob.glob("/home/takensoft/Pictures/화창한날, 비오는날 프레임2000장/비오는날 프레임 추출/7월11일 폭우(3개)/**/*.png") |
|
32 |
- image_paths += glob.glob("/home/takensoft/Pictures/폭우 빗방울 (475개)/*.png") |
|
33 |
- |
|
34 |
- crop_size = (512, 512) # width and height you want for your cropped images |
|
35 |
- start_point = (750, 450) # upper left point where the crop should start |
|
36 |
- |
|
37 |
- crop_images_parallel(image_paths, output_directory, crop_size, start_point) |
|
14 |
+ return False(파일 끝에 줄바꿈 문자 없음) |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?