opencv

    [OpenCV] imshow 창설정 및 종료 처리 (x버튼 처리).

    창 설정 cv2.namedWindow를 통해 미리 창에 대한 title을 지정하여 놓을 수 있음. cv2.namedWindow('image', cv2.WINDOW_NORMAL) # Using resizeWindow() : Below code does not works with cv2.WINDOW_AUTOSIZE # cv2.resizeWindow("image", 300, 700) cv2.WINDOW_AUTOSIZE가 기본으로 2nd argument없이 호출시 선택됨. 읽어들이는 image 크기에 맞춰 window의 크기가 결정됨. cv2.WINDOW_NORMAL로 설정시 window의 크기를 조정가능함.(마우스로 window의 크기를 조절할 수 있음) cv2.WINDOW_GUI_EXPANDED로 설정시 확..

    [OpenCV] Desired Data Type : ddtype

    OpenCV에서 filter등의 함수에서 주로 등장하는 ddtype parameter는 결과 image의 data type을 의미한다. desired data type이라고도 불리고 이를 줄여서 ddtype라고 기재하는데, 일반적으로 input image와 같은 data type을 유지하도록 -1을 사용하는 경우가 많다. 이 방식은 대부분 큰 문제가 없지만, gradient나 laplacian을 구하는 filter 연산의 경우, 음수값을 결과로 가질 수 있는데 OpenCV에서 image를 나타내기 위해 사용하는 기본 데이터 타입이 np.uint8 (or cv2.CV_8U)이기 때문에 -1로 ddtype를 지정할 경우 문제가 발생한다. 이는 음수를 고려하지 않은 cv2.CV_8U는 음수값의 gradient..

    [DIP] opencv 에서 H264 encoding error

    colab등에서 video를 재생시키는 처리를 하다가 계속 에러가 나서 헤맸다. HTML5에서 표준 비디오인코딩이 H264라 fourcc = cv2.VideoWriter_fourcc(*'H264')로 계속 처리를 했는데... 계속 정상동작을 안하는 문제에 봉착... 새로 테스트하던 부분만 신경쓰느라, cv2.VideoWriter instance가 아예 open이 안된 것을 놓쳤고 때문에 엄한 시간을 날렸다. 비디오는 잘 안다루다보니... 일단 현재 opencv의 python binding은 기본으로 H264 encoding을 제공하지 않는다. GPL 때문... If you installed this package via pip install opencv-python then there&#3..

    [DIP] Kornia 소개

    https://github.com/kornia/kornia GitHub - kornia/kornia: Open Source Differentiable Computer Vision Library Open Source Differentiable Computer Vision Library - GitHub - kornia/kornia: Open Source Differentiable Computer Vision Library github.com Kornia는 PyTorch를 위한 differentiable computer vision library 이다. 일반적인 computer vision problem들을 해결할 수 있는 다양한 함수와 differentiable module들로 구성되어 있다. 기본적으로 P..

    [DIP] Dithering

    다음은 wikipedia의 정의임. Dither is an intentionally applied form of noise used to randomize quantization error, preventing large-scale patterns such as color banding in images. Dither is routinely used in processing of both digital audio and video data. 즉, 의도적으로 삽입된 noise인데 이를 사람이 보거나 들을 때, quantizaiton error를 randomize하여 최소화된 qunantization error를 느끼게 하는 것이다. 실제로 256 단계의 gray-scale이미지를 0,1의 binary im..

    [DIP] opencv : Region of Interest (ROI) :

    cv2.selectROI가 아닌 이벤트 핸들러(MouseCallback)를 이용한 구현임. x button (or close button)을 지원하기 위한 구현을 추가한 것이며, 여러 윈도우를 띄우는 경우엔 메인 윈도우가 닫히는 경우, 다른 윈도우들도 같이 닫히도록 처리하는 처리가 필요하여 `\text{pyautogui}`패키지를 이용하여 처리함. import cv2 import numpy as np import pyautogui is_dragging = False x0,y0 = -1,-1 w0,h0 = -1,-1 red = (0,0,255) def onMouse(event, x, y, flags, param): global is_dragging global x0,y0,w0,h0 if event == c..