Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
78ac065
Merge pull request #4 from Oh-JongJin/update_ui
Oh-JongJin Feb 7, 2022
74883a6
Modify name what ND-01 to JS-06 in README file
Oh-JongJin Feb 7, 2022
23bd903
Merge pull request #5 from Oh-JongJin/update_ui
Oh-JongJin Feb 8, 2022
ed5fdc0
Modify to connect functions of QSettings
Oh-JongJin Feb 10, 2022
de409c6
Merge pull request #8 from Oh-JongJin/update_ui
Oh-JongJin Feb 10, 2022
3a8d25d
Replace plot module to QChartView
Oh-JongJin Feb 11, 2022
1d1276a
Merge pull request #9 from Oh-JongJin/update_ui
Oh-JongJin Feb 11, 2022
295d275
Apply sprint requirements
Oh-JongJin Feb 14, 2022
508ef48
Merge pull request #11 from Oh-JongJin/update_ui
Oh-JongJin Feb 14, 2022
ace006f
Fix a part of save csv file in save_target function
Oh-JongJin Feb 14, 2022
734ef93
Modify target paintEvent when camera direction flip
Oh-JongJin Feb 15, 2022
072d170
Rearrange image capture path
Oh-JongJin Feb 15, 2022
00f55b5
Update docstring
Oh-JongJin Feb 17, 2022
51cc145
Remove unused modules
Oh-JongJin Feb 17, 2022
964fc79
Apply file deletion function completely
Oh-JongJin Feb 18, 2022
52d7974
Modify data for save image file name
Oh-JongJin Feb 18, 2022
74e9b73
Merge pull request #12 from Oh-JongJin/update_ui
Oh-JongJin Feb 21, 2022
6098491
Apply file delete through QCalender widget
Oh-JongJin Feb 23, 2022
9351225
Simplified file delete UI
Oh-JongJin Feb 23, 2022
0c6ec66
Delete useless code
Oh-JongJin Feb 23, 2022
7112c98
Merge pull request #13 from Oh-JongJin/update_ui
Oh-JongJin Feb 28, 2022
407931b
Add login view
Oh-JongJin Feb 28, 2022
0450857
Simplified codes
Oh-JongJin Mar 2, 2022
8cd1520
Merge pull request #18 from Oh-JongJin/update_ui
Oh-JongJin Mar 4, 2022
6e16e4c
Add Target table, Value chart in setting window
Oh-JongJin Mar 4, 2022
0827135
Version 0.1
Oh-JongJin Mar 8, 2022
8861aa4
Merge pull request #20 from Oh-JongJin/update_ui
Oh-JongJin Mar 8, 2022
62e1edd
Add azimuth angle image line in setting view
Oh-JongJin Mar 15, 2022
bba3dd7
Modify image storage path and store front and rear images simultaneou…
Oh-JongJin Mar 16, 2022
95149f8
Arrange code
Oh-JongJin Mar 17, 2022
2de8eb3
Version 0.1 to be installed
Oh-JongJin Apr 8, 2022
f98050c
JS08 version 1.0.0
Oh-JongJin May 23, 2022
481c6ad
Merge pull request #23 from Oh-JongJin/update_ui
Oh-JongJin May 23, 2022
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
6 changes: 4 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
PyQt5 >= 5.13
python-vlc
PyQtGraph
pyechart
PyQtChart
influxdb
opencv-python
pandas
pandas
psutil
scipy
29 changes: 27 additions & 2 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,31 @@
# [email protected] (Seong Min Chae)
# [email protected] (Jongjin Oh)

from src.__main__ import main
import multiprocessing as mp
from src.nd01 import clock, ND01MainWindow

main()

if __name__ == '__main__':
import sys
from PyQt5.QtWidgets import QApplication
print(f'Start time: {time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())}')

mp.freeze_support()
q = Queue()
_q = Queue()

_producer = producer

p = Process(name='clock', target=clock, args=(q,), daemon=True)
_p = Process(name='producer', target=_producer, args=(_q,), daemon=True)

p.start()
_p.start()

os.makedirs(f'{JS06Settings.get("data_csv_path")}', exist_ok=True)
os.makedirs(f'{JS06Settings.get("target_csv_path")}', exist_ok=True)
os.makedirs(f'{JS06Settings.get("image_save_path")}', exist_ok=True)

app = QApplication(sys.argv)
window = ND01MainWindow(q, _q)
sys.exit(app.exec())
100 changes: 100 additions & 0 deletions src/auto_file_delete.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/usr/bin/env python3
#
# Copyright 2021-2022 9th grade 5th class.
#
# Authors:
# [email protected]

import os
import psutil
import shutil

from PyQt5.QtWidgets import (QDialog, QApplication, QMessageBox)
from PyQt5 import uic

from model import JS08Settings


def byte_transform(bytes, to, bsize=1024):
"""
Unit conversion of byte received from shutil

:return: Capacity of the selected unit (int)
"""
unit = {'KB': 1, 'MB': 2, 'GB': 3, 'TB': 4}
r = float(bytes)
for i in range(unit[to]):
r = r / bsize
return int(r)


class FileAutoDelete(QDialog):

def __init__(self):
super().__init__()

ui_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
'resources/auto_file_delete.ui')
uic.loadUi(ui_path, self)

# self.setFixedSize(self.width(), self.height())

drive = []
# Save all of the user's drives in drive variable.
for i in range(len(psutil.disk_partitions())):
drive.append(str(psutil.disk_partitions()[i])[18:19])

self.calendarWidget.activated.connect(self.showDate)

self.path = None
self.date = None
self.date_convert = None

self.exit_pushButton.clicked.connect(self.exit_click)

def exit_click(self):
self.close()

def showDate(self, date):
self.date = date.toString('yyMMdd')
self.date_convert = date.toString('yyyy/MM/dd')
self.check_file_date(os.path.join(JS08Settings.get('image_save_path'),
'vista'))

def check_file_date(self, path: str):
is_old = []

for f in os.listdir(path):
print(f)
if int(f) <= int(self.date):
is_old.append(int(f))

if is_old:
dlg = QMessageBox.question(self, 'Warning', f'Delete folder before {self.date_convert} ?',
QMessageBox.Yes | QMessageBox.No)
if dlg == QMessageBox.Yes:
self.delete_select_date(path, is_old)
else:
QMessageBox.information(self, 'Information', 'There is no data before the selected date.')

def delete_select_date(self, path: str, folder: list):
"""
Delete the list containing the folder name

:param path: Path to proceed with a auto-delete
:param folder: Data older than the date selected as the calendarWidget
"""

for i in range(len(folder)):
a = os.path.join(path, str(folder[i]))
shutil.rmtree(a)
print(f'{a} delete complete.')


if __name__ == "__main__":
import sys

app = QApplication(sys.argv)
window = FileAutoDelete()
window.show()
sys.exit(app.exec_())
132 changes: 132 additions & 0 deletions src/cal_ext_coef.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import itertools
import os

import numpy as np
import pandas as pd
import traceback
import warnings

import scipy
from scipy.optimize import curve_fit

curved_flag = True
hanhwa_dist = []
hanhwa_x = []
hanhwa_r = []
hanhwa_g = []
hanhwa_b = []


def select_max_rgb(r, g, b):
c_list = [r, g, b]

c_index = c_list.index(max(c_list))

if c_index == 0:
select_color = 'red'
elif c_index == 1:
select_color = 'green'
else:
select_color = 'blue'
# select_color = 'green'

return select_color


def cal_curve(hanhwa: pd.DataFrame):
# hanhwa = pd.read_csv(f"{rgbsavedir}/{epoch}.csv")
# print(hanhwa)
global hanhwa_opt_r, hanhwa_opt_g, hanhwa_opt_b
hanhwa = hanhwa.sort_values(by=['distance'])
hanhwa_dist = hanhwa[['distance']].squeeze().to_numpy()
hanhwa_x = np.linspace(hanhwa_dist[0], hanhwa_dist[-1], 100, endpoint=True)
hanhwa_x.sort()
hanhwa_r = hanhwa[['r']].squeeze().to_numpy()
hanhwa_g = hanhwa[['g']].squeeze().to_numpy()
hanhwa_b = hanhwa[['b']].squeeze().to_numpy()

r1_init = hanhwa_r[0] * 0.7
g1_init = hanhwa_g[0] * 0.7

b1_init = hanhwa_b[0] * 0.7
r2_init = hanhwa_r[-1] * 1.3
g2_init = hanhwa_g[-1] * 1.3
b2_init = hanhwa_b[-1] * 1.3

select_color = select_max_rgb(r2_init, g2_init, b2_init)

r_ext_init = [r1_init, r2_init, 1]
g_ext_init = [g1_init, g2_init, 1]
b_ext_init = [b1_init, b2_init, 1]

try:
hanhwa_opt_r, hanhwa_cov_r = curve_fit(func, hanhwa_dist, hanhwa_r, p0=r_ext_init, maxfev=5000)
hanhwa_opt_g, hanhwa_cov_g = curve_fit(func, hanhwa_dist, hanhwa_g, p0=g_ext_init, maxfev=5000)
hanhwa_opt_b, hanhwa_cov_b = curve_fit(func, hanhwa_dist, hanhwa_b, p0=b_ext_init, maxfev=5000)

# hanhwa_opt_r, hanhwa_cov_r = curve_fit(func, hanhwa_dist, hanhwa_r, p0=r_ext_init)
# hanhwa_opt_g, hanhwa_cov_g = curve_fit(func, hanhwa_dist, hanhwa_g, p0=g_ext_init)
# hanhwa_opt_b, hanhwa_cov_b = curve_fit(func, hanhwa_dist, hanhwa_b, p0=b_ext_init)

except RuntimeError:
# Optimal parameters not found: Number of calls to function has reached maxfev = 5000.
# 이 에러는 타겟의 RGB에 대해 최적의 기울기를 찾지 못하여 발생하는 에러로,
# 타겟이 이상할 때 대게 발생함.

# print(traceback.format_exc())
pass

list1 = []
list2 = []
list3 = []

list1.append(hanhwa_opt_r[0])
list1.append(hanhwa_opt_g[0])
list1.append(hanhwa_opt_b[0])

list2.append(hanhwa_opt_r[1])
list2.append(hanhwa_opt_g[1])
list2.append(hanhwa_opt_b[1])

list3.append(hanhwa_opt_r[2])
list3.append(hanhwa_opt_g[2])
list3.append(hanhwa_opt_b[2])

# hanhwa_err_r = np.sqrt(np.diag(hanhwa_cov_r))
# hanhwa_err_g = np.sqrt(np.diag(hanhwa_cov_g))
# hanhwa_err_b = np.sqrt(np.diag(hanhwa_cov_b))

# print_result(hanhwa_opt_r, hanhwa_opt_g, hanhwa_opt_b, hanhwa_err_r, hanhwa_err_g, hanhwa_err_b)

# print(f"Red channel: {extcoeff_to_vis(hanhwa_opt_r[2], hanhwa_err_r[2], 3)} km")
# print(f"Green channel: {extcoeff_to_vis(hanhwa_opt_g[2], hanhwa_err_g[2], 3)} km")
# print(f"Blue channel: {extcoeff_to_vis(hanhwa_opt_b[2], hanhwa_err_b[2], 3)} km")

# os.makedirs(extsavedir, exist_ok=True)

return list1, list2, list3, select_color


# @staticmethod
def func(x, c1, c2, a):
warnings.filterwarnings('ignore')
return c2 + (c1 - c2) * np.exp(-a * x)


# def print_result(opt_r, opt_g, opt_b, err_r, err_g, err_b):
# print(f'Red channel: (',
# f'C1: {opt_r[0]:.2f} ± {err_r[0]:.2f}, ',
# f'C2: {opt_r[1]:.2f} ± {err_r[1]:.2f}, ',
# f'alpha: {opt_r[2]:.2f} ± {err_r[2]:.2f})')
# print(f'Green channel: (',
# f'C1: {opt_g[0]:.2f} ± {err_g[0]:.2f}, ',
# f'C2: {opt_g[1]:.2f} ± {err_g[1]:.2f}, ',
# f'alpha: {opt_g[2]:.2f} ± {err_g[2]:.2f})')
# print(f'Blue channel: (',
# f'C1: {opt_b[0]:.2f} ± {err_b[0]:.2f}, ',
# f'C2: {opt_b[1]:.2f} ± {err_b[1]:.2f}, ',
# f'alpha: {opt_b[2]:.2f} ± {err_b[2]:.2f})')


# def extcoeff_to_vis(optimal, error, coeff=3.912):
# return coeff / (optimal + np.array((1, 0, -1)) * error)
Loading