Deep Learning/Computer Vision

Deep Learning/Computer Vision

얼굴 탐지

import numpy as np import cv2 import matplotlib.pyplot as plt %matplotlib inline nadia = cv2.imread('../DATA/Nadia_Murad.jpg',0) denis = cv2.imread('../DATA/Denis_Mukwege.jpg',0) solvay = cv2.imread('../DATA/solvay_conference.jpg',0) plt.imshow(nadia,cmap='gray') plt.imshow(denis,cmap='gray') plt.imshow(solvay,cmap='gray') 이렇게 3개의 사진을 각각 불러옴. 우선 필요한 것은 classifier를 만들고 XML classifier를 진행하는것이다 fac..

Deep Learning/Computer Vision

feature matching

feature matching에는 세가지가 있다 Brute -Force Matching with ORB Descriptors Brute-Force Matching with SiFT Descriptors and Ratio Test FLANN based Matcher import cv2 import numpy as np import matplotlib.pyplot as plt %matplotlib inline def display(img,cmap='gray'): fig = plt.figure(figsize=(12,10)) ax = fig.add_subplot(111) ax.imshow(img,cmap='gray') reeses = cv2.imread('../DATA/reeses_puffs.png',0) di..

Deep Learning/Computer Vision

Contour Detection

import cv2 import numpy as np import matplotlib.pyplot as plt %matplotlib inline img = cv2.imread('../DATA/internal_external.png',0) plt.imshow(img,cmap='gray') grayscale로 설정함. openCV의 윤곽 함수가 좋은 점은 내부 윤곽뿐만 아니라 얼굴이나 삼각형, 피자와 같은 외부 윤곽도 감지할 수 있음. cv2.RETR_EXTERNAL:외부 contour만 추출 cv2.RETR_CCOMP: 두 개의 계층으로 구성된 내외부 contour 모두 추출 cv2.RETR_TREE: 나무 그래프로 구성된 내외부 contour 모두 추출 cv2.RETR_LIST: 내외부 관계 없이 모든 ..

Deep Learning/Computer Vision

그리드 검출

import cv2 import matplotlib.pyplot as plt %matplotlib inline flat_chess = cv2.imread('../DATA/flat_chessboard.png') plt.imshow(flat_chess,cmap='gray') 그리드 검출 시 그리드가 본질적으로 체스판같이 정형화되어야함 found, corners = cv2.findChessboardCorners(flat_chess,(7,7)) 그리드 사이즈 지정 전체 이미지가 8*8라면, 끝에 있는 가장자리를 탐지하기 위해 7*7로 지정함 found는 체스보드 타입의 모서리를 찾았는지를 나타냄 if found: print('OpenCV was able to find the corners') else: prin..

Deep Learning/Computer Vision

엣지 검출

Canny Edge detection 검출기에 탑재된 기술을 적용하기 전에 여러분의 스무딩 및 블러링 기술을 적용하는 경우가 많을 것 가우스 필터를 적용하여 이미지를 스무딩하면 이미지의 강도 증감률을 찾을 수 있음. 다음 단계 알고리즘이 가장자리 검출에 대한 가짜 반응을 제거하기 위해 최대치가 아닌 억제를 실행 -> 그런 다음 잠재적 모서리를 선택하기 위해 이중 임계값을 적용 -> 모서리를 히스테리시스(hysteresis, 이력현상)로 추적 , 이때 강한 모서리에 연결되지 않은 다른 약한 모서리는 전부 억제되고 모서리 감지가 종료될 것 즉, 약한 모서리를 없애고 강한 모서리를 찾는 일종의 여과과정, 사용자가 낮은 임계값과 높은 임계값을 정해야 함 import cv2 import numpy as np im..

Deep Learning/Computer Vision

코너 검출

코너 검출을 공부하기 전에 알아야 할 지식 몇 개가 있다. Harris corner Detection 전방향에서 나타나는 상당한 변화를 찾으면 코너가 검출된다 식: (람다1*람다2)-k(람다의 합) https://en.wikipedia.org/wiki/Harris_corner_detector Harris corner detector - Wikipedia From Wikipedia, the free encyclopedia The Harris corner detector is a corner detection operator that is commonly used in computer vision algorithms to extract corners and infer features of an image. ..

Deep Learning/Computer Vision

템플릿 매칭

템플릿 매칭 Template Matching -> 객체 탐지 매치되는 것을 찾을때까지 전체를 본다. 템플릿 매칭은 상관관계에 기초된다. import cv2 import numpy as np import matplotlib.pyplot as plt %matplotlib inline full = cv2.imread('../DATA/sammy.jpg') full = cv2.cvtColor(full, cv2.COLOR_BGR2RGB) plt.imshow(full) 데이터를 불러오고, 색이 제대로 나올 수 있게 RGB컬러로 변환하는 과정을 거친다. full.shape 1367 * 1025 * 3 사진의 shape은 세로 1367 * 가로 1025* 3컬러가 나옴 템플릿 이미지로 강아지 얼굴 사진의 일부를 따온다 ..

Deep Learning/Computer Vision

파이썬 카메라에 도형 그리기

1. 파이썬 카메라에 직사각형 그리기 일단 모두 하나의 셀로 실행해야 할 것을 염두에 둘것 import cv2 cap = cv2.VideoCapture(0) width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) #에러 피하기 위함 int 프레임 혹 정수로 height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) # 직사각형 만들기 #top left corner x = width//2 #정수가 되기 위함 소수점 안나오게 하는 정수값 y = height//2 # Width and height w = width//4 h = height//4 #bottom right x+w, y+h while True: # 프레임 캡쳐 ret, frame = cap...

해파리냉채무침
'Deep Learning/Computer Vision' 카테고리의 글 목록