일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- DFS
- gpdb
- SWEA
- Vue.js
- Priority Queue
- Data Structure
- Bruth Force
- CSV
- BFS
- 모의SW역량테스트
- boj
- spring boot
- Algorithm
- programmers
- 코테
- SQL
- 알고리즘
- Linked list
- Python
- hash table
- django
- 구현
- JavaScript
- Back tracking
- 코딩테스트
- 시뮬레이션
- Trie
- 알고리듬
- aws
- GitHub
- Today
- Total
목록Python (8)
hotamul의 개발 이야기
>>> number = 123 >>> number 123 >>> del number >>> number Traceback (most recent call last): File "", line 1, in NameError: name 'number' is not defined Python에서 del keyword를 사용하면 위와 같이 number은 더 이상 사용할 수 없게 된다. number에 접근하려고 하면 더 이상 해당 변수가 없기 때문에 NameError가 발생한다. 하지만 del은 객체를 제거하는 것이 아니라 변수와 같은 reference를 제거하는 것이 주요 목표이다. 다음 이상한 예시를 확인해 보자. >>> class MyClass: ... def __del__(self): ... print("M..
sysstat, sar을 이용한 resource 모니터링에서 sar을 이용해 resource 사용량 확인 방법에 대해서 알아보았다. 아래는 python으로 해당 명령을 실행하고 결과를 print 하기 예시 import subprocess # sar 명령어 실행 sar_process = subprocess.Popen(['sar', '-u', '1', '3'], stdout=subprocess.PIPE) # sar 결과를 딕셔너리로 파싱 output = sar_process.communicate()[0].decode() lines = output.split('\n') header = lines[2].split() cpu_usage = {} for line in lines[3:]: if line: fields..

Github - OpenCV에서 data/haarcascades/haarcascade_frontalface*.xml 이름의 파일들이 있는데 이 xml 파일을 복사/다운로드 해서 아래와 같이 얼굴 인식을 테스트 해볼 수 있다. 저는 haarcascade_frontalface_default.xml을 이용해서 진행했다. # detectMultiScale Signature cv.CascadeClassifier.detectMultiScale(image\[, scaleFactor\[, minNeighbors\[, flags\[, minSize\[, maxSize]]]]] -> objects 참고: OpenCV - CascadeClassifier detectMultiScale 메소드 인자인 scaleFactor와 m..
Interpolation Methods for resizing cv2.INTER_AREA: 주로 이미지 크기를 줄이는데 사용한다. cv2.INTER_CUBIC: 속도는 느리지만 Interpolation 성능이 좋다. cv2.INTER_LINEAR: 주로 이미지 크기를 늘리는데 사용하고 OpenCV의 default Interpolation method이다. 참고: OpenCV - InterpolationFlags Shrink & Enlarge Image $ pip install opencv-python-headless numpy import numpy as np import cv2 # loading image img = cv2.imread('./testimg.jpg') # shrinking ..
image 파일을 numpy.ndarray로 불러오는 방법은 3가지가 있다. OpenCV $ pip install opencv-python-headless import cv2 img_cv = cv2.imread('./testimg.jpg') print(img_cv) [[[ 21 48 92] [ 19 46 90] [ 16 42 88] ... [ 0 14 13] [ 0 11 10] [ 0 15 14]] [[ 17 44 88] ... OpenCV의 imread는 BGR (Blue, Green, Red) 순서의 numpy.ndarray를 리턴한다. matplotlib.image $ pip install matplotlib import matplotlib.image as matimg img_mat ..
Post에 image 컬럼이 없으면 태그 이름을 통해 기본 이미지를 제공하는 기능을 추가했다. # api/utils.py ... if obj.image: post['image'] = obj.image.url else: post['image'] = get_default_img(post['tags']) ... # api/utils.py ... def get_default_img(tags): ret = 'share-blog' default_img_list = [ 'django', 'git', 'github', 'python', 'vuejs' ] while len(tags): tag_name = tags.pop().replace(".", "").lower() if tag_name in default_img_li..
보호되어 있는 글입니다.
보호되어 있는 글입니다.