Presentation is loading. Please wait.

Presentation is loading. Please wait.

Opencv 32121847 이민권.

Similar presentations


Presentation on theme: "Opencv 32121847 이민권."— Presentation transcript:

1 Opencv 이민권

2 목차 Computer Vision OpenCV OpenCV 설치 OpenCV 입출력 OpenCV 히스토그램
OpenCV Feature Matching OpenCV 물체 인식

3

4 ( 130 , 17 , 217 )( 13 , 119 , 11 )( 130 , 174 , 234 )( 155 , 218 , 142 )( 236 , 30 , 26 )( 72 , 52 , 156 )( 26 , 125 , 202 )( 191 , 123 , 87 )( 154 , 134 , 69 )( 93 , 121 , 130 )( 72 , 73 , 29 )( 37 , 142 , 204 )( 211 , 122 , 67 )( 95 , 11 , 43 )( 210 , 15 , 251 )( 69 , 247 , 16 )( 101 , 110 , 40 )( 89 , 93 , 228 )( 222 , 17 , 172 )( 75 , 17 , 10 )( 154 , 124 , 88 )( 5 , 205 , 48 )( 99 , 10 , 223 )( 179 , 127 , 86 )( 134 , 78 , 103 )( 192 , 29 , 232 )( 1 , 39 , 181 )( 244 , 158 , 158 )( 222 , 219 , 151 )( 117 , 99 , 130 )( 254 , 87 , 170 )( 133 , 138 , 214 )( 185 , 168 , 183 )( 37 , 225 , 6 )( 28 , 232 , 173 )( 106 , 56 , 37 )( 25 , 43 , 69 )( 229 , 133 , 147 )( 40 , 7 , 191 )( 192 , 231 , 70 )( 222 , 163 , 241 )( 202 , 88 , 224 )( 246 , 105 , 71 )( 50 , 181 , 24 )( 241 , 235 , 224 )( 94 , 20 , 185 )( 86 , 165 , 248 )( 24 , 139 , 213 )( 58 , 36 , 11 )( 37 , 121 , 9 )( 255 , 41 , 213 )( 188 , 174 , 220 )( 104 , 41 , 232 )( 236 , 90 , 79 )( 80 , 211 , 118 )( 251 , 26 , 103 )( 80 , 111 , 95 )( 89 , 74 , 5 )( 45 , 244 , 44 )( 182 , 196 , 214 )( 72 , 173 , 118 )( 147 , 72 , 230 )( 93 , 150 , 171 )( 210 , 103 , 77 )( 192 , 200 , 237 )( 138 , 30 , 60 )( 53 , 169 , 68 )( 7 , 88 , 236 )( 51 , 150 , 41 )( 63 , 189 , 5 )( 16 , 133 , 217 )( 157 , 196 , 10 )( 255 , 137 , 121 )( 106 , 124 , 31 )( 202 , 127 , 39 )( 166 , 20 , 206 )( 195 , 54 , 138 )( 90 , 109 , 237 )( 151 , 49 , 144 )( 5 , 231 , 100 )( 41 , 73 , 105 )( 103 , 20 , 157 )( 86 , 32 , 192 )( 126 , 152 , 76 )( 190 , 56 , 197 )( 123 , 187 , 93 )( 11 , 44 , 181 )

5 Computer Vision 컴퓨터가 이미지나 비디오를 어떻게 높은 수준으로 이해하게 할 것인가를 연구하는 학문
컴퓨터가 이미지나 비디오를 어떻게 높은 수준으로 이해하게 할 것인가를 연구하는 학문 인간의 눈이 하는 기능을 기계가 수행하도록 하는 것

6 OpenCV 널리 이용되는 다양한 이미지 프로세싱을 구현 쉽게 사용할 수 있도록 추상화 되어 있음

7 OpenCV 설치 http://opencv.org/releases.html
C/C++의 경우 추가 포함/라이브러리 설정, 추가 종속성에opencv_world320.lib, opencv_world320.dll파일 이동 (3.2.0 버전 기준) Python의 경우 (Python Path)\Lib\site-packages에 cv2.pyd 복사

8 Opencv 사용 Python에서 import를 사용 import cv2 출력을 위해 matplotlib.pyplot 도 이용
from matplotlib import pyplot as plt

9 Opencv 입출력 내부적으로 다양한 이미지 포맷에 대하여 자동으로 입력 imread() 사용
cv2.imread(filename[, flags]) 출력은 opencv에서 제공되는 imshow()를 이용하거나 matplotlib에서 제공되는 imshow()가 있다 cv2.imshow(winname, mat) matplotlib.pyplot.imshow(mat[,options])

10 OPENCV 입출력 import cv2 from matplotlib import pyplot as plt img = cv2.imread('Cat.png',1) plt.subplot(121),plt.imshow(img) plt.subplot(122),plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB)) cv2.imshow('Cat',img) plt.show() cv2.waitKey(0) cv2.destroyAllWindows()

11 OPENCV 입출력

12 Opencv 히스토그램 이미지의 밝기 분포를 나타내는 그래프 이미지 데이터 값의 노출 레벨 분포와 전체적인 밝기를 표시

13 Opencv 히스토그램 calcHist() 사용
cv2.calcHist(images, channels, mask, histSize, ranges[, hist[, accumulate]]) 히스토그램 출력을 위해 plot() 사용 matplotlib.pyplot.plot(*args, **kwarg)

14 Opencv 히스토그램 import cv2 from matplotlib import pyplot as plt img = cv2.imread('Cat.png',1) color = ('b','g','r') for i,col in enumerate(color): histr = cv2.calcHist([img],[i],None,[256],[0,256]) plt.subplot(122),plt.plot(histr,color = col) plt.xlim([0,256]) plt.subplot(121),plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB)) plt.show()

15 Opencv 히스토그램

16 Opencv 히스토그램 평활화 한쪽으로 치우친 명도 값을 조절 각 픽셀의 밝기 값을 평탄하게 조정
equalizeHist() 사용 cv2.equalizeHist(src[, dst])

17 Opencv 히스토그램 평활화 import cv2 from matplotlib import pyplot as plt img = cv2.imread('Cat.png',0) plt.subplot(221),plt.imshow(cv2.cvtColor(img, cv2.COLOR_GRAY2RGB)) histr = cv2.calcHist([img],[0],None,[256],[0,256]) plt.subplot(222),plt.plot(histr) plt.xlim([0,256]) img2 = cv2.equalizeHist(img) plt.subplot(223),plt.imshow(cv2.cvtColor(img2, cv2.COLOR_GRAY2RGB)) histr = cv2.calcHist([img2],[0],None,[256],[0,256]) plt.subplot(224),plt.plot(histr) plt.show()

18 Opencv 히스토그램 평활화

19 OPENCV 선 검출 이미지에서의 윤곽선만을 검출 다양한 방식 존재
Canny Edge Detector을 추상화한 Canny() 이용 cv2.Canny(image, threshold1, threshold2[, edges[, apertureSize[, L2gradient]]])

20 OPENCV 선 검출 import cv2 from matplotlib import pyplot as plt img = cv2.imread('Cat.png',0) edges = cv2.Canny(img,50,200) plt.subplot(121),plt.imshow(img,cmap = 'gray') plt.title('Original Image') plt.subplot(122),plt.imshow(edges,cmap = 'gray') plt.title('Edge Image') plt.show()

21 OPENCV 선 검출

22 OPENCV 선 검출

23 OPENCV Feature Matching
다양한 이미지 매칭 방식 중 하나 특정 방법으로 특징을 추출하여 이를 이미지 매칭에 이용 OpenCV는 다양한 방식의 특징 추출 방식을 제공 detectAndCompute()을 이용하여 특징 추출 detectAndCompute(image, mask[, descriptors[, useProvidedKeypoints]]) OpenCV는 몇가지 방식의 match 방식 제공 match()를 이용하여 비교 match (queryDescriptors, trainDescriptors)

24 OPENCV Feature Matching
import cv2 from matplotlib import pyplot as plt img1 = cv2.imread('Cat.png',0) img2 = cv2.imread('CatTrain.png',0) alg = cv2.BRISK_create() #Binary Robust Invariant Scalable Keypoints kp1, des1 = alg.detectAndCompute(img1,None) kp2, des2 = alg.detectAndCompute(img2,None) bf = cv2.BFMatcher() matches = bf.match(des1,des2) matches = sorted(matches, key = lambda x:x.distance) img3 = cv2.drawMatches(img1,kp1,img2,kp2,matches[:20],None) plt.imshow(img3),plt.show()

25 OPENCV Feature Matching

26 OPENCV 물체 인식 OpenCV는 특정 사물을 훈련하여 인식하는 클래스 제공 기본적으로 특징을 통해 훈련
CascadeClassifier detectMultiScale()을 이용하여 인식 CascadeClassifier.detectMultiScale(image[, scaleFactor[, minNeighbors[, flags[, minSize[, maxSize]]]]])

27 OPENCV 물체 인식 import cv2 from matplotlib import pyplot as plt img = cv2.imread('Lena.png') gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) hC=cv2.CascadeClassifier('haarcascade_frontalcatface.xml') headRect=hC.detectMultiScale(gray) for (x,y,w,h) in headRect: cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2) cv2.imshow('Img',img) cv2.waitKey(0) cv2.destroyAllWindows()

28 OPENCV 물체 인식

29 Q & A


Download ppt "Opencv 32121847 이민권."

Similar presentations


Ads by Google