可以通过键盘快速操作
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99import cv2 import os import argparse import numpy as np from tqdm import tqdm import shutil import random import glob import json import sys import tty import termios def parse_arg(): """ Parse command line input parameters """ parser = argparse.ArgumentParser(description="Calculate the accuracy of license plate recognition") parser.add_argument("--input_image_paths", type=str, default="/home/yangbinchao/桌面/雄研/draw_test_data_image/draw",help=" File path to be processed ") args = parser.parse_args() print() print(f"args = {args}") print() return args def readchar(): fd = sys.stdin.fileno() old_settings = termios.tcgetattr(fd) try: tty.setraw(sys.stdin.fileno()) ch = sys.stdin.read(1) finally: termios.tcsetattr(fd, termios.TCSADRAIN, old_settings) return ch def readkey(getchar_fn=None): getchar = getchar_fn or readchar c1 = getchar() if ord(c1) != 0x1b: return c1 c2 = getchar() if ord(c2) != 0x5b: return c1 c3 = getchar() return chr(0x10 + ord(c3) - 65) def wait_key(img_path): # wait the key is put down while True: key=readkey() if key=='z': # save the path print('save the image path list',img_path) #miss_label_list.append(img_path) with open( './miss_label_list.json', 'a+', encoding='utf-8') as f: # 车牌对应的颜色标签 f.write(json.dumps(img_path,ensure_ascii=False,indent=1)+',') break if key=='x': print('save the image path list',img_path) #lack_vehicle_list.append(img_path) with open( './lack_vehicle_list.json', 'a+', encoding='utf-8') as f: # 车牌对应的颜色标签 f.write(json.dumps(img_path,ensure_ascii=False,indent=1)+',') break if key=='a': print('ignore the image path list',img_path) break if key=='q': return key break def read_img(img_path,image_dir): image_path = os.path.join( image_dir, img_path) img = cv2.imread(image_path) img = cv2.resize(img,(1000,500)) cv2.imshow(img_path, img) while cv2.waitKey(2500) != 27:# loop time is 3000 if not get ESC if cv2.getWindowProperty('img_path' ,cv2.WND_PROP_VISIBLE) <= 0: break cv2.destroyAllWindows() def main(args): for img_path in tqdm(os.listdir(args.input_image_paths)): read_img(img_path, image_dir=args.input_image_paths) key_value = wait_key(img_path) if(key_value == 'q'): print('nthe save image path list is {}'.format(miss_label_list)) print('nthe save image path list is {}'.format(lack_vehicle_list)) exit() print('nthe save image path list is {}'.format(miss_label_list)) print('nthe save image path list is {}'.format(lack_vehicle_list)) if __name__ == "__main__": args = parse_arg() miss_label_list = [] lack_vehicle_list = [] main(args)
最后
以上就是友好麦片最近收集整理的关于【Python脚本】手动过滤图片数据样本的自动化操作的全部内容,更多相关【Python脚本】手动过滤图片数据样本内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复