영상 입출력
core, videoio, imgcodecs
전처리
imgproc, photo
특징 추출
imgproc, features2d
객체 검출, 영상 분할
imgproc, objdetect
분석 : 객체 인식, 포즈 추정, 움직임 분석, 3D 재구성
calib3d, video, stitching, ml, dnn
화면 출력, 최종 판단
highgui, ml, dnn
import cv2 as cv
img = cv.imread('lenna.bmp') # 배열
if img is None:
print('Image load failed!')
exit()
cv.imshow('image', img)
cv.waitKey() # 결과물을 보여주고 자동적으로 창 닫지 않음
img1 = cv.imread('cat.bmp', cv.IMREAD_GRAYSCALE)
//옵션없으면 원본 그대로
print('type(img):', type(img))
# type(img1): <class 'numpy.ndarray'>
print('img.shape : ', img.shape)
# img1.shape : (1666, 1666)
if len(img.shape) == 2: # 영상 타입 확인
print('grayscale image')
img2 = 255 - img2 # reassign 원본 변경 X
img2[:, :] = 255 - img2 # 참조해주는 곳에 할당, 원본 변경 O
img2 = img[200:400, 200:400] # shallow copy
img3 = img[200:400, 200:400].copy() # deep copy
img2 += 20 #Broadcasting
cv.imshow('img', img) # 밝아짐
cv.imshow('img2', img2) # 부분 밝아짐
cv.imshow('img3', img3) # 원본