OpenCV_with_Python

OpenCV Python3 tutorial_2

decom0405 2018. 4. 6. 21:30

OpenCV Python3 2번째


첫번째 시간엔 특정 영상을 불러온 실습을 진행. 


이번 시간엔 불러온 영상의 특징(정보)을 불러오는 내용.


1
2
3
4
5
6
7
8
9
#Let's take a closer look at how images are stored
 
import numpy as np
import cv2
 
input = cv2.imread('./images/input.jpg')
 
print(input.shape)
 
cs

위에 import한 numpy는 쓰지 않음.

해당 파이썬 스크립트를 실행하면 불러온 영상의 정보가 터미널 창에 출력.

(830, 1245, 3) #(Height, Width, channel) 순서로 출력

1
2
3
4
5
6
import cv2
 
input = cv2.imread('./images/input.jpg')
 
print('Height of Image:'int(input.shape[0]), 'pixels')
print('Width of Image:'int(input.shape[1]), 'pixels')
cs

이렇게 작성하고 출력하면 

Height of Image: 830 pixels
Width of Image: 1245 pixels

이렇게 출력됨.


반응형