AU标注辅助小程序

本文介绍了一款使用Python开发的自动标注辅助小程序,旨在提高工作效率,简化标注过程。

人生苦短,我用python~

import cv2
import os
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import shutil
import csv


def check_landmark():
	os.system('cls')
	path = os.getcwd()
	path = 'dataset\\'

	student_id = input("please input the student id:\n")
	if student_id == 'q': return
	while 1:
		frame = input("please input the frame:\n")
		if frame == 'q': return
		im = cv2.imread(path + 'faces\\' + student_id + '\\' + frame + '.jpg')
		print(path + 'faces\\' + student_id + '\\' + frame + '.jpg')
		im = im[:, :, (2, 1, 0)]
		fig,ax = plt.subplots(figsize=(4, 4))
		ax.imshow(im, aspect = 'equal', extent = (0, 255, 255, 0))
		lm = np.loadtxt(path + 'landmarks\\' + student_id + '\\' + frame + '.txt', delimiter = ',')
		plt.plot(lm[:,0], lm[:,1], '*')
		plt.axis('off')
		#plt.tight_layout()
		#plt.draw()
		plt.show()

def remove_0_file_in_dataset():
	path = os.getcwd()
	path += '\\dataset\\'

	for dir in os.listdir(path):
		if dir == 'AU':
			continue
		if '0' in os.listdir(path + dir):
			path_of_0_file = path + dir + '\\0'
			shutil.rmtree(path_of_0_file)
			print(dir + " done")
		else:
			print(dir + " not exist")
	input()

def remove_specific_file():
	path = os.getcwd()
	path += '\\dataset\\'

	student_id = input("please input the student id:\n")
	if student_id == 'q': return
	while 1:
		frame = input("please input the frame:\n")
		if frame == 'q': return
		for dir in os.listdir(path):
			if dir == 'AU':
				continue
			if frame + '.jpg' in os.listdir(path + dir + '\\' + student_id + '\\'):
				path2rmv = path + dir + '\\' + student_id + '\\' + frame + '.jpg'
				os.remove(path2rmv)
				print('the file ' + path2rmv + " has been remove!")
			elif frame + '.txt' in os.listdir(path + dir + '\\' + student_id + '\\'):
				path2rmv = path + dir + '\\' + student_id + '\\' + frame + '.txt'
				os.remove(path2rmv)
				print('the file ' + path2rmv + " has been remove!")
			else:
				print("the file doesn't exist in " + path + dir + '\\' + student_id + '\\')
			
def check_reduntant_files():
	os.system('cls')
	pat_b = input("Please enter the path of your big folder: ")
	pat_s = input("Please enter the path to your small folder: ")
	root = os.getcwd()
	path_b = root + '\\dataset\\' + pat_b
	path_s = root + '\\dataset\\' + pat_s
	flag = True
	for f in os.listdir(path_b):
		ff = path_b + '\\' + f
		for name in os.listdir(ff):
			if os.path.exists(path_s + '\\' + f + '\\' + name)==False:
				print('Path:' + pat_b + '>>' + f + '>>' + name + 'is reduntant\n')
				flag = False
	if flag:
		print('The two folders are the same \n')
	input()

def calculate_the_files_number():
	os.system('cls')
	path = os.getcwd()
	path += '\\dataset\\'
	for f in os.listdir(path):
		sum = 0
		if f == 'AU':
			for ff in os.listdir(path + '\\' + f):
				csv_reader = csv.reader(open(path + '\\' + f + '\\' + ff, encoding='utf-8')) # encoding='utf-8' is required !!
				tmp = np.array(list(csv_reader)).shape[0] - 1
				sum += tmp
				print(os.path.splitext(ff)[0] + ':' + str(tmp), end = ' ')
		else:
			for ff in os.listdir(path + '\\' + f):
				if ff == '0':
					continue
				else:
					sum += len(os.listdir(path + '\\' + f + '\\' + ff))
					print(ff + ':' + str(len(os.listdir(path + '\\' + f + '\\' + ff))), end = ' ')
		print('%12s totally: '%f + str(sum))
	input()

if __name__ == '__main__':
	while True:
		os.system('cls')
		string1 = "----Welcome to the auxiliary system!----"
		print('\n')
		print(string1.center(80))
		print("     1. check landmark")
		print("     2. remove 0 file in dataset")
		print("     3. remove specific files")
		print("     4. check reduntant files")
		print("     5. calculate the files number")
		index = input("\nSelect your operation with corresponding number:")
		if index == '1':
			check_landmark()
		if index == '2':
			remove_0_file_in_dataset()
		if index == '3':
			remove_specific_file()
		if index == '4':
			check_reduntant_files()
		if index == '5':
			calculate_the_files_number()
		if index == 'q':
			quit()


AuAceBox 是 Skyfore 开发的一款 Au3 辅助工具:该工具涵盖了大多 数 Au3 编程常用操作,可完美替代官方的 AccAu3Box. 开发语言:AU3、C++、等等,所以文件偏大! 版本特点: 1.酷炫 UI,扁平化窗口设计 2.常用操作一键集成,绝对给力; 3.支持用户自定义工具,方便功能扩展,支持展开环境变量 使用帮助: 1.程序中大部分都有气泡提示,根据气泡提示操作即可。 2.配置 AuMFCompiler 1.程序默认不自带 AuMFCompiler,如果您需要使用,请根据以下步骤配置: 2.到 Au3.Cc -> AuMFC专区 花200A币下载 AuMFC 3.打开主程序 AuAceBox.exe 打开 主菜单 -> 扩展功能 -> 配置 AuMFC 编译器 4.根据提示操作,完成后您就可以直接在主界面调用 AuMFC 编译器了! 3.创建桌面方式 1.如果您觉得本工具好用的话,可以按以下步骤直接创建快捷方式: 2.打开主程序 AuAceBox.exe 打开 主菜单 -> 扩展功能 -> 程序设置 -> 选中 为 AuAceBox 创建桌面快捷方式 即可! 3.然后桌面上就会跳出快捷方式 "AuAceBox 专业版",OK,以后您就可以直接通过快捷方式运行本工具了 4.用户自定义工具 1.AuAceBox v2.1+ 版本提供用户自定义工具功能 2.点击 首页大图标 -> 实用工具汇总 -> 用户工具 -> 配置用户工具箱 即可配置工具; 3.工具格式:每行一个工具,格式如: 工具名=路径(或URL) 4.自定义工具支持如下环境变量: %APPDIR%:AuAceBox.exe 所在目录 %AU3DIR%:AutoIt3.exe 所在目录 %ScriptFile%:载入 Au3 脚本路径 5.检查更新窗口弹出为何有延时 1.更新先获取网络版本号,更新日志,更新地址 2.再显示更新窗口,所以会有些延迟,具体时间与网络环境有关 6.本程序是否开源 1.对不起,本程序为闭源程序,未来也不打算开源 2.要问原因?1.这个程序本来就没什么开源价值 2.伸手党泛滥... AutoIt v3 编程交流学习网 - Au3.Cc 版本更新日志: [2015/3/7 2.1.2.6] 1.修正 取消所有窗口半透明 2.修正 更新窗口若无可用更新自适应为 初始化程序 3.新增 原生支持托盘功能,适应不同用户需求 4.新增 托盘双击显示、隐藏主窗口 5.新增 托盘显示 内置/用户 工具 6.修正 关于对话框标题栏显示程序版本号 7.新增 Ctrl+F12 显示隐藏主界面 8.修正 AuAceBox 更新逻辑 9.新增 AuAceBox 设置中心 AuAceManager 10.新增 支持手动限制自动吸附 11.优化 AuAceBox 吸附效率/未知吸附情况 12.修正 新功能增加后对应控件/托盘说明 [2015/3/5 2.1.2.4] 1.新增 检查更新功能 2.新增 AuAceBox 专属浏览器 3.新增 修正 N 多窗口主题 4.新增 无人值守自动更新 功能 5.新增 Au3.Cc 链接支持两种打开方式 6.修正 菜单文字以及描述 7.修正 访问网站链接指向 AuAceBox 专属浏览器. 8.修复 2.1 版本中的某些 BUG. 9.修正 关于页文字说明来自 ReadMe.Txt (如果存在) 10.优化 保证效率下减小附加组件内存及CPU占用率 [2015/3/2 2.1.0.34] 1.删除 Au3 脚本录制工具链接 2.新增 内置实用工具 ,用于放置 AU3 辅助工具,从此本人写的所有 AU3 辅助工具就都会直接嵌入至 AuAceBox ! 3.新增 GUID 生成器; 4.新增 RegExTester 内嵌插件,绝对给力! [2015/3/2 2.1.0.9] 1.调整 根据用户反馈,调整编译栏背景色 2.修正 部分文字描述 [2015/3/1 2.1.0.6] 1.调整 调整UI,使其看起来更和谐; 2.修正 AuAceBox.Tool 增加部分工具; [2015/3/1 2.1.0.5] 1.修正 修复1.0版本的 N 多 BUG; 2.修正 完全重写代码,加快程序运行速度 3.新增 用户自定义工具功能 4.修正 窗口乱跑的问题 5.去除 托盘,用户定义工具集成于图标菜单 6.新增 支持程序环境变量(支持系统原有的如%WINDIR%) %AU3DIR% %APPDIR% %ScriptFile%
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值