Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUI #2

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ xgtf_to_excel/result.xlsx
.idea/inspectionProfiles/profiles_settings.xml
.idea/.gitignore
result.xlsx

gui-for-tester-tracker
162 changes: 162 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file added xgtf_to_excel/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified xgtf_to_excel/requirements.txt
Binary file not shown.
145 changes: 145 additions & 0 deletions xgtf_to_excel/untitled.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>750</width>
<height>250</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>750</width>
<height>250</height>
</size>
</property>
<property name="windowTitle">
<string>Xgtf to Excel GUI</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="2">
<widget class="QPushButton" name="button_exit">
<property name="text">
<string>Выход из программы</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="button_clear_input">
<property name="text">
<string>Очистить поля</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="button_select_result_dir">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="button_start">
<property name="text">
<string>Запустить</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="input_work_dir">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="button_select_work_dir">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="input_result_dir">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Выберите директорию для файла с результатом</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="input_file_name"/>
</item>
<item row="2" column="2">
<widget class="QLabel" name="label_4">
<property name="text">
<string>.xlsx</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Введите название файла с результатом</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Выберите рабочую директорию</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="button_open_result_file">
<property name="text">
<string>Открыть файл с результатом</string>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>0</number>
</property>
<property name="textVisible">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>750</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>
37 changes: 22 additions & 15 deletions xgtf_to_excel/xgtf_to_excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
from argparse import ArgumentParser
import cv2
from dataclasses import dataclass, field
from typing import Optional, Tuple
from typing import Optional, Tuple, Callable
from math import isnan
from numpy import sum as npsum
from alive_progress import alive_it


# Константы
Expand Down Expand Up @@ -94,17 +95,12 @@ def append(self, element:XgtfData):
pass
pass



if __name__ == "__main__":
# Аргументы
parser = ArgumentParser()
parser.add_argument('--work-dir', required=True)
parser.add_argument('--result-dir',nargs="?", default='result.xlsx')
namespace = parser.parse_args()
#
def xgtf_to_excel_work(work_dir, result_dir = os.path.join(os.getcwd(), 'result.xlsx'), callback:Optional[Callable[[int], None]]=None):
allData = AllXgtfData()
for file_name in os.listdir(namespace.work_dir):
bar = alive_it(os.listdir(work_dir)) if callback is None else os.listdir(work_dir)
for file_name in bar:
if callback is not None:
callback(int((bar.index(file_name)+1) * 100 / len(bar)))
# Условие для обработки .xgtf
if file_name.find(".xgtf") == -1:
continue
Expand All @@ -113,11 +109,11 @@ def append(self, element:XgtfData):
data = XgtfData(file_name)

try:
tree = ET.parse(os.path.join(namespace.work_dir, file_name))
tree = ET.parse(os.path.join(work_dir, file_name))
except ET.ParseError:
allData.append(data)
continue
print(os.path.join(namespace.work_dir, file_name))
print(os.path.join(work_dir, file_name))
root_data_sourcefile = tree.getroot().find(f'./{VIPER}data/{VIPER}sourcefile')

# Количество рамок объектов
Expand All @@ -140,7 +136,7 @@ def append(self, element:XgtfData):
if data.framesCount == 0 or framerate == 0:
raise AttributeError
except AttributeError:
data.framesCount,framerate = get_fps_and_numframes_from_video(namespace.work_dir, file_name)
data.framesCount,framerate = get_fps_and_numframes_from_video(work_dir, file_name)

if framerate != 0:
# Расчет времени
Expand All @@ -152,7 +148,7 @@ def append(self, element:XgtfData):

# Вывод в файл
df = pd.DataFrame(allData.to_excel(), columns=['Имя', 'Количество объектов', 'Длинна видео (секунд)', 'Длинна видео (кадры)', 'Среднее кол-во рамок объектов на кадре', 'Классы'])
writer = pd.ExcelWriter(namespace.result_dir, engine='xlsxwriter')
writer = pd.ExcelWriter(result_dir, engine='xlsxwriter')
df.style.applymap(painting_errors).to_excel(writer, sheet_name='Sheet1', index=False, na_rep='NaN')

for column in df:
Expand All @@ -161,3 +157,14 @@ def append(self, element:XgtfData):
writer.sheets['Sheet1'].set_column(col_idx, col_idx, column_length)

writer.close()


if __name__ == "__main__":
# Аргументы
parser = ArgumentParser()
parser.add_argument('--work-dir', required=True)
parser.add_argument('--result-dir',nargs="?", default='result.xlsx')
namespace = parser.parse_args()
#
xgtf_to_excel_work(namespace.work_dir, namespace.result_dir)

Loading