This commit is contained in:
威勝 張 2024-04-19 19:24:34 +08:00
commit 4ac15f886c
418 changed files with 757 additions and 0 deletions

BIN
CLASS/python_class.pptx Normal file

Binary file not shown.

BIN
CLASS/python_oop.pptx Normal file

Binary file not shown.

24
Logging/LOG.txt Normal file
View File

@ -0,0 +1,24 @@
2023-12-01 14:08:23,270 - LOG.txt - INFO - Start
2023-12-01 14:08:23,270 - LOG.txt - INFO - A : 0
2023-12-01 14:08:23,270 - LOG.txt - INFO - Start
2023-12-01 14:08:23,271 - LOG.txt - INFO - Start
2023-12-01 14:08:23,271 - LOG.txt - INFO - B : 0
2023-12-01 14:08:23,271 - LOG.txt - INFO - Start
2023-12-01 14:08:23,271 - LOG.txt - INFO - C : 0
2023-12-01 14:08:23,272 - LOG.txt - INFO - D : 0
2023-12-01 14:08:23,772 - LOG.txt - INFO - A : 1
2023-12-01 14:08:23,774 - LOG.txt - INFO - D : 1
2023-12-01 14:08:23,774 - LOG.txt - INFO - B : 1
2023-12-01 14:08:23,774 - LOG.txt - INFO - C : 1
2023-12-01 14:08:24,274 - LOG.txt - INFO - A : 2
2023-12-01 14:08:24,276 - LOG.txt - INFO - B : 2
2023-12-01 14:08:24,276 - LOG.txt - INFO - D : 2
2023-12-01 14:08:24,276 - LOG.txt - INFO - C : 2
2023-12-01 14:08:24,775 - LOG.txt - INFO - A : 3
2023-12-01 14:08:24,777 - LOG.txt - INFO - C : 3
2023-12-01 14:08:24,777 - LOG.txt - INFO - D : 3
2023-12-01 14:08:24,777 - LOG.txt - INFO - B : 3
2023-12-01 14:08:25,277 - LOG.txt - INFO - A : 4
2023-12-01 14:08:25,279 - LOG.txt - INFO - B : 4
2023-12-01 14:08:25,279 - LOG.txt - INFO - D : 4
2023-12-01 14:08:25,279 - LOG.txt - INFO - C : 4

View File

@ -0,0 +1,6 @@
20231201 14:03:59 - INFO - Start
20231201 14:03:59 - INFO - A : 0
20231201 14:03:59 - INFO - A : 1
20231201 14:04:00 - INFO - A : 2
20231201 14:04:00 - INFO - A : 3
20231201 14:04:01 - INFO - A : 4

View File

@ -0,0 +1,6 @@
20231201 14:03:59 - INFO - Start
20231201 14:03:59 - INFO - B : 0
20231201 14:03:59 - INFO - B : 1
20231201 14:04:00 - INFO - B : 2
20231201 14:04:00 - INFO - B : 3
20231201 14:04:01 - INFO - B : 4

View File

@ -0,0 +1,6 @@
20231201 14:03:59 - INFO - Start
20231201 14:03:59 - INFO - C : 0
20231201 14:03:59 - INFO - C : 1
20231201 14:04:00 - INFO - C : 2
20231201 14:04:00 - INFO - C : 3
20231201 14:04:01 - INFO - C : 4

View File

@ -0,0 +1,6 @@
20231201 14:03:59 - INFO - Start
20231201 14:03:59 - INFO - D : 0
20231201 14:03:59 - INFO - D : 1
20231201 14:04:00 - INFO - D : 2
20231201 14:04:00 - INFO - D : 3
20231201 14:04:01 - INFO - D : 4

View File

View File

View File

View File

View File

View File

View File

View File

80
Logging/Process_class.py Normal file
View File

@ -0,0 +1,80 @@
import threading
import multiprocessing as mp
from queue import Queue #Thread 無法回傳值,所以要使用 Queue.put() 將要傳回的值存入 Queue再用 Queue.get() 取出
import time
import os
import datetime
import logging
import cv2
class Process_class(mp.Process):
def __init__(self, code_name,q):
mp.Process.__init__(self)
self.code_name = code_name
# log 設定
#self.log_setting()
self.q = q
#self.log_setting_1()
def run(self):
self.t = self.code_name
self.q.put(self.t)
print('process {} '.format(os.getpid())) # 查看進程
print('thread {} '.format(threading.current_thread().name)) # 查看線程
# log 設定
self.log_setting()
self.logger = self.logger
self.logger.info("Start")
for i in range(0,5):
self.logger.info(f'{self.code_name} : {i}')
time.sleep(0.5)
def test_return(self):
return(f'{(self.q.get_nowait())}=END')
# log setting
def log_setting(self):
day_date = (datetime.datetime.now().strftime("%Y%m%d"))
log_file = f'LOG\\Process\\{self.code_name}-{day_date}.txt'
# 创建一个 Logger 对象
self.logger = logging.getLogger(log_file)
# 设置 Logger 级别
self.logger.setLevel(logging.INFO)
# 创建一个处理程序并将其级别设置为 INFO
ch = logging.StreamHandler()
ch.setLevel(logging.INFO)
# 创建一个格式器并将其添加到处理程序
formatter = logging.Formatter('%(asctime)s - %(levelname)-8s - %(message)s', datefmt='%Y%m%d %H:%M:%S')
ch.setFormatter(formatter)
# 将处理程序添加到 logger
self.logger.addHandler(ch)
# 创建一个文件处理程序并将其添加到 logger
file_handler = logging.FileHandler(log_file)
file_handler.setFormatter(formatter)
self.logger.addHandler(file_handler)
def log_setting_1(self):
log_file = f'LOG.txt'
# create logger
self.logger = logging.getLogger(log_file)
self.logger.setLevel(logging.DEBUG)
# create console handler and set level to debug
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
# create file handler and set level to info
fh = logging.FileHandler(log_file)
fh.setLevel(logging.INFO)
# create formatter
formatter = logging.Formatter(
'%(asctime)s - %(name)-36s - %(levelname)-8s - %(message)s')
# add formatter to console handler and file handler
ch.setFormatter(formatter)
fh.setFormatter(formatter)
# add console handler and file handler to logger
self.logger.addHandler(ch)
self.logger.addHandler(fh)

79
Logging/Thread_class.py Normal file
View File

@ -0,0 +1,79 @@
import threading
import multiprocessing as mp
from queue import Queue #Thread 無法回傳值,所以要使用 Queue.put() 將要傳回的值存入 Queue再用 Queue.get() 取出
import time
import os
import datetime
import logging
import cv2
class Thread_class(threading.Thread):
def __init__(self,code_name,logeer):
threading.Thread.__init__(self)
self.code_name = code_name
# log 設定
#self.log_setting()
self.log_setting_1()
def run(self):
print('process {} '.format(os.getpid())) # 查看進程
print('thread {} '.format(threading.current_thread().name)) # 查看線程
# log 設定
#self.log_setting_1()
#logger = self.logger
self.logger.info("Start")
for i in range(0,5):
self.logger.info(f'{self.code_name} : {i}')
time.sleep(0.5)
def test_return(self):
return(f'{self.code_name}=END')
# log setting
def log_setting(self):
day_date = (datetime.datetime.now().strftime("%Y%m%d"))
log_file = f'LOG\\Thread\\{self.code_name}-{day_date}.txt'
# 创建一个 Logger 对象
self.logger = logging.getLogger(log_file)
# 设置 Logger 级别
self.logger.setLevel(logging.INFO)
# 创建一个处理程序并将其级别设置为 INFO
ch = logging.StreamHandler()
ch.setLevel(logging.INFO)
# 创建一个格式器并将其添加到处理程序
formatter = logging.Formatter('%(asctime)s - %(levelname)-8s - %(message)s', datefmt='%Y%m%d %H:%M:%S')
ch.setFormatter(formatter)
# 将处理程序添加到 logger
self.logger.addHandler(ch)
# 创建一个文件处理程序并将其添加到 logger
file_handler = logging.FileHandler(log_file)
file_handler.setFormatter(formatter)
self.logger.addHandler(file_handler)
def log_setting_1(self):
log_file = f'LOG.txt'
day_date = (datetime.datetime.now().strftime("%Y%m%d"))
log_file = f'LOG\\Thread\\{self.code_name}-{day_date}.txt'
# create logger
self.logger = logging.getLogger(log_file)
self.logger.setLevel(logging.DEBUG)
# create console handler and set level to debug
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
# create file handler and set level to info
fh = logging.FileHandler(log_file)
fh.setLevel(logging.WARNING)
# create formatter
formatter = logging.Formatter(
'%(asctime)s - %(name)-36s - %(levelname)-8s - %(message)s')
# add formatter to console handler and file handler
ch.setFormatter(formatter)
fh.setFormatter(formatter)
# add console handler and file handler to logger
self.logger.addHandler(ch)
self.logger.addHandler(fh)

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,63 @@
import threading
import multiprocessing as mp
from multiprocessing import Queue
#from queue import Queue #Thread 無法回傳值,所以要使用 Queue.put() 將要傳回的值存入 Queue再用 Queue.get() 取出
import time
import os
import datetime
import logging
import cv2
from Process_class import Process_class
from Thread_class import Thread_class
log_file = f'LOG.txt'
# create logger
logger = logging.getLogger(log_file)
logger.setLevel(logging.DEBUG)
# create console handler and set level to debug
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
# create file handler and set level to info
fh = logging.FileHandler(log_file)
fh.setLevel(logging.INFO)
# create formatter
formatter = logging.Formatter(
'%(asctime)s - %(name)-36s - %(levelname)-8s - %(message)s')
# add formatter to console handler and file handler
ch.setFormatter(formatter)
fh.setFormatter(formatter)
# add console handler and file handler to logger
logger.addHandler(ch)
logger.addHandler(fh)
if __name__=='__main__':
q = Queue()
name_list = ["A", "B", "C", "D"]
process_list = []
for i in range(0, len(name_list)):
process_list.append(Thread_class(name_list[i],q))
for i in range(0, len(process_list)):
process_list[i].start()
for i in range(0, len(process_list)):
process_list[i].join()
for i in range(0, len(process_list)):
#print(q.get())
print(process_list[i].test_return())

BIN
Thread/python_thread.pptx Normal file

Binary file not shown.

Binary file not shown.

BIN
Yolo/PPT/yolov5.pptx Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 854 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Some files were not shown because too many files have changed in this diff Show More