일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 기타 연주
- YOLO
- SSH
- ubuntu
- pip
- 채보
- C
- C++
- Docker
- C#
- OpenCV
- error
- 오류
- VS Code
- 핑거스타일
- paramiko
- Python
- Visual Studio
- Numpy
- Linux
- nvidia-smi
- label
- 프로그래머스
- mysql
- windows forms
- 컨테이너
- pytorch
- pandas
- Selenium
- JSON
- Today
- Total
목록전체 글 (330)
기계는 거짓말하지 않는다

Python 3.7 버전부터 기본 Dict도 삽입 순서를 보장한다. 명시적으로는 collections 모듈의 OrderedDict를 사용할 수 있다. Python Ordered Dict 문서 collections — Container datatypes Source code: Lib/collections/__init__.py This module implements specialized container datatypes providing alternatives to Python’s general purpose built-in containers, dict, list, set, and tuple.,,... docs.python.org 아래와 같이 사용할 수 있다. from collections import..
입력받거나 작성된 경로가 절대 경로인지 확인하고 상대 경로이면 절대 경로로, 절대 경로이면 상대 경로로 변환한다. import os data_path = "../../Temp/aa.txt" if not os.path.isabs(data_path): # 절대 경로 변환 data_path = os.path.abspath(data_path) print("abs path:", data_path) else: # 상대 경로 변환 data_path = os.path.relpath(data_path) print("relative path:", data_path)
Python에서 추상클래스를 생성하는 방법이다. abc 모듈이 필요하고 추상클래스의 추상메소드가 존재할 때, 객체를 생성하면 예외가 발생한다. 추상클래스를 상속받은 하위 클래스는 추상메소드를 구현하지 않으면 예외가 발생한다. from abc import * class TempAbstractClass(metaclass=ABCMeta): @abstractmethod def show_val(self): pass class TempClass(TempAbstractClass): def __init__(self, n: int, s: str): self.number = n self.string = s def show_val(self): print(f"Values: {self.number}, {self.string}"..
cv2를 이용할 때 imread, imwrite 한글(utf-8) 인식 문제가 있다. imread, imwrite 함수를 아래와 같이 선언하고 사용한다. import os import cv2 import numpy as np def imread(file_path): npArr = np.fromfile(file_path, dtype=np.uint8) return cv2.imdecode(npArr, cv2.IMREAD_COLOR) def imwrite(file_path, img, params=None): try: ext = os.path.splitext(file_path)[1] result, n = cv2.imencode(ext, img, params) if result: with open(file_path..

문자열은 immutable이므로 문자 수정이 불가능하다. List 변경 후 다시 문자열로 변환하는 방법이 있다. temp_str = "ABCDEF" temp_str = list(temp_str) temp_str[0] = "g" temp_str[1] = "h" temp_str = "".join(temp_str) print(f"Change String: {temp_str} (Type: {type(temp_str)})")

리스트 내포(List comprehension)와 조건문을 이용하여 필요한 값만 남긴다. 아래와 같이 활용할 수 있다. name_dict = {i:1 for i in range(0, 10, 2)} print("necessary value:", list(name_dict.keys())) origin_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] print("origin value:", origin_list) origin_list = [i for i in origin_list if i in name_dict] print("removed value:", origin_list)

FFPROBE -show_streams를 이용해 RTSP stream 정보를 확인할 때 정보가 나오지 않는 경우가 있다. -rtsp_transport tcp 명령어를 추가하여 확인해본다. ffprobe -i rtsp://x.x.x.x:... -show_streams -rtsp_transport tcp
git clone 명령어로 특정 브랜치만 클론하고 싶을 경우 1) git clone -b [branch_name] [remote-repository-url] git clone --branch [branch_name] [remote-repository-url] # ex) git clone -b sdk/8.1 https://github.com/FFmpeg/nv-codec-headers.git 2) git clone -b [branch_name] --single-branch [remote-repository-url] git clone --branch [branch_name] --single-branch [remote-repository-url] # ex) git clone -b sdk/8.1 -single-b..