본문 바로가기
728x90

OpenCV4

[OpenCV] Python - Flip Image import cv2 img = cv2.imread('panda.png', cv2.IMREAD_COLOR) # code == 0 상하 res = cv2.flip(img, 0) # code 0 좌우 cv2.imshow('panda', img) cv2.imshow('reverse', res) cv2.waitKey() cv2.destroyAllWindows() 2023. 8. 23.
[OpenCV] Python - ImageRead 프로젝트 생성시, 위와같은 샘플 코드가 같이 생성되는데, 모두 삭제한다. import cv2 기입할경우 빨간줄 나오는데, 마우스 커서를 데면 아래와 같이 설치 가능하다 import cv2 img = cv2.imread('Lenna.png', cv2.IMREAD_ANYCOLOR) cv2.imshow('Lenna', img) height, width, channel = img.shape print(height, width, channel) cv2.waitKey() cv2.destroyAllWindows() Read Flags 더보기 cv2.IMREAD_UNCHANGED : 원본 사용 cv2.IMREAD_GRAYSCALE : 1 채널, 그레이스케일 적용 cv2.IMREAD_COLOR : 3 채널, BGR 이미.. 2023. 8. 23.
[OpenCV] Python Camera Read import cv2 # 노트북 카메라 - 0번 cameraCapture = cv2.VideoCapture(0) # 사이즈 지정 cameraCapture.set(cv2.CAP_PROP_FRAME_WIDTH, 640) cameraCapture.set(cv2.CAP_PROP_FRAME_HEIGHT, 480) while cv2.waitKey(100) < 0: ret, frame = cameraCapture.read() cv2.imshow("Camera", frame) #정리 cameraCapture.release() cv2.destroyAllWindows() 2023. 8. 23.
[OpenCV] Python - Image read/write import cv2 import numpy as np import matplotlib.pyplot as plt img_basic = cv2.imread('Lenna.png', cv2.IMREAD_COLOR) cv2.imshow('Image Basic', img_basic) cv2.waitKey() cv2.imwrite('result1.png', img_basic) img_gray = cv2.cvtColor(img_basic, cv2.COLOR_BGR2GRAY) cv2.imshow('Image Gray', img_gray) cv2.waitKey() cv2.imwrite('result2.png', img_gray) cv2.destroyAllWindows() 2023. 8. 22.
728x90