| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
- ubuntu
- 채보
- error
- VS Code
- 컨테이너
- label
- nvidia-smi
- 프로그래머스
- JSON
- SSH
- OpenCV
- C
- 오류
- pip
- C#
- pandas
- Python
- Visual Studio
- Numpy
- C++
- Docker
- Linux
- YOLO
- Selenium
- mysql
- 핑거스타일
- 기타 연주
- windows forms
- paramiko
- pytorch
- Today
- Total
목록Python (107)
기계는 거짓말하지 않는다
OpenCV를 이용하여 영상을 read 한 후 확인 시, 회전되어 있는 경우가 있다. 영상의 메타데이터를 확인하면 (ffmpeg 사용) rotate에 회전된 각도가 있다. OpenCV 4.5 버전 미만에서, 원본 영상을 회전시켜 수정한 영상일 경우 OpenCV로 프레임을 읽으면 반영이 되지않고 원본 그대로 출력되는 현상이 있다. 4.5 버전 미만이라도 메타데이터를 읽어 다시 회전시켜 줘도 되지만 4.5 버전 이상을 설치하면 정상적으로 출력된다.
디렉터리 내의 파일들의 경로를 텍스트 파일로 저장한다. 특정 확장자만 제한하려면 argparser로 넘겨준다. argparser 명령어 예시 image_files 디렉터리 내의 png, jpg, jpeg 확장자를 가진 파일들의 경로를 file_list.txt 텍스트 파일로 저장 python file_path_list_to_text.py -p ./image_files -t file_list.txt -e png jpg jpeg import glob import argparse import os def parse_opt(): parser = argparse.ArgumentParser() parser.add_argument('-p', '--path', default=".", help="data path") pa..
리스트의 선언, 할당 과정을 간단하게 한 줄로 처리할 수 있다. 리스트 내포의 간단한 사용 예시이다. # 순차 할당 temp_list = [i for i in range(10)] print(temp_list, "\n", "-" * 40) # 2중 반복 temp_list = [j for i in range(3) for j in range(5)] print(temp_list, "\n", "-" * 40) # 조건문 temp_list = [i for i in range(10) if i > 5 or i < 2] print(temp_list, "\n", "-" * 40) # 대입 값 조건문 temp_list = [i if i < 5 else -1 for i in range(10)] print(temp_list, ..
직접 구현해도 상관없지만 os.path 모듈에서 지원한다. import os file_path = "D:/TempRoot/TempChild/temp_file.txt" # 경로에서 확장자 분리 후 튜플로 반환 print(os.path.splitext(file_path)) split_ext = os.path.splitext(file_path) print("Type:", type(split_ext)) print("Index[0]:", split_ext[0]) print("Index[1]:", split_ext[1], "\n") # 경로에서 파일이름 분리 후 튜플로 반환 print(os.path.split(file_path)) split_file_name = os.path.split(file_path) prin..
datetime 모듈의 timedelta 를 이용한다. timedelta 객체 datetime — 기본 날짜와 시간 형 — Python 3.10.7 문서 datetime — 기본 날짜와 시간 형 소스 코드: Lib/datetime.py datetime 모듈은 날짜와 시간을 조작하는 클래스를 제공합니다. 날짜와 시간 산술이 지원되지만, 구현의 초점은 출력 포매팅과 조작을 위한 docs.python.org from datetime import timedelta import time delta = timedelta(days=50, seconds=27, microseconds=10, milliseconds=4, minutes=5, hours=8, weeks=1) print(delta) start_time = t..
import datetime import time now = datetime.datetime.now() print(now) # 2022-08-25 09:11:41.090583 # yyyy-mm-dd 형식 formatted_date = now.strftime("%Y-%m-%d") print(formatted_date) # 2022-08-25 print(type(formatted_date)) # print(type(now)) # strftime() 반환 결과는 string이다. strftime() 포맷 코드는 다음 문서를 참조 strftime() 포맷 코드 datetime — 기본 날짜와 시간 형 — Python 3.10.6 문서 datetime — 기본 날짜와 시간 형 소스 코드: Lib/datetime...
Mutex와 유사하다고 생각하면 된다. https://docs.python.org/ko/3/library/threading.html#rlock-objects threading — 스레드 기반 병렬 처리 — Python 3.10.5 문서 threading — 스레드 기반 병렬 처리 소스 코드: Lib/threading.py 이 모듈은 저수준 _thread 모듈 위에 고수준 스레딩 인터페이스를 구축합니다. queue 모듈도 참조하십시오. 버전 3.7에서 변경: 이 모듈은 docs.python.org RLock은 재귀 호출 시 문제를 고려한 lock이다. RLock 미사용 import threading number = 0 def multi_call_function(call_name : str): global ..
Thread 사용 시 args 매개 변수를 튜플로 전달할 때 오류이다. 튜플로 하나의 매개 변수만 전달 할 시, # 오류 t = threading.Thread(target=custom_function, args=(value1)) 아래와 같이 하나의 매개 변수만 전달하더라도 콤마(,)가 필요하다. # Comma , t = threading.Thread(target=custom_function, args=(value1,))
