OpenCV 5

Laplacian Method를 이용해 Blurry Image detect 하기!

input_video.mp4를 이용해서, 얼마나 Blurry 한지를 파악하고, 이를 이용해서 blurry를 detect하는 스크립트를 소개하도록 하겠습니다. 기본적인 원리는, 샤프한 이미지일수록, edge가 잘 define되어있고, blurry 한 이미지일 수록 그렇지 못하다는 점에 착안하여, variance of laplacian 의 값을 찾아서, 그 laplacian 값이 낮을 수록 더 blurry한 이미지라는 사실을 이용하는 것입니다. 이를 이용해서, 더 높은 화질의 이미지를 구할수 있을 것으로 보입니다. 물론 Threshold 값에 대해서는 여러 번 실험을 통해서 최적의 값을 구해야겠죠? reference : https://theailearner.com/2021/10/30/blur-detectio..

Image Processing 2023.05.31

SSIM 흑백 이미지 동영상 저장하기

제 블로그의 인기 포스트 OpenCV를 이용해서 두개의 이미지 비교하기 의 심화편 입니다. 예를 들어, 다음과 같은 영상 이 있을 때, 비디오의 ssim을 비디오로 계속 보고 싶다고 생각하면, 처음 이미지를 기준으로 잡고, 그 이미지를 바탕으로 계속 그 차이를 표시할 수 있습니다. 원봉 영상 diff import cv2 from skimage.metrics import structural_similarity as ssim import numpy as np cap = cv2.VideoCapture('thisvideo.mp4') w, h = round(cap.get(3)), round(cap.get(4)) orig_img, grayA = None, None fps = 0 # 코덱값 fourcc = cv2.V..

opencv 를 이용해서 rtsp 동영상 받기(ft. multithreading)

opencv를 이용해서 rtsp를 이용해서 영상을 받고, 그 영상을 display하는 코드 입니다. import os os.environ["OPENCV_FFMPEG_CAPTURE_OPTIONS"] = "rtsp_transport;udp" import numpy as np import cv2 as cv cap = cv.VideoCapture('rtsp://192.168.0.2:8554/') while cap.isOpened(): ret, frame = cap.read() # if frame is read correctly ret is True if not ret: print("Can't receive frame (stream end?). Exiting ...") break cv.imshow('frame',..

(opencv) 두 이미지의 차이를 박스로 나타내기

저번 포스트에서 walkaroundthedevelop.tistory.com/56 어떻게 하면 두 이미지의 차이를 알 수 있는지에 대해서 알아보았습니다. 그럼 두 개의 이미지를 이용해서 차이를 표시해낼 수 있을까요? 일단 두 개의 이미지를 사용해서 얻어낸 diff를 디스플레이 해 봅시다. 두 개의 이미지에다가 diff를 구하면, 이렇게 됩니다. 이 diff를 보면, 포스트잇을 붙인 곳이 검은색으로 된 것을 볼 수 있습니다. # 이전 포스트에서 diff 가져옴! thresh = cv2.threshold(diff, 100, 255, cv2.THRESH_BINARY_INV)[1] # get contours cnts = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL, c..

OpenCV를 이용해서 두 개의 이미지 비교하기 (SSIM)

레퍼런스 : ourcodeworld.com/articles/read/991/how-to-calculate-the-structural-similarity-index-ssim-between-two-images-with-python opencv를 이용해서 두 개의 이미지를 비교하는 방법에 대해서 알아보겠습니다. # Usage: # # python3 script.py -f original.png -s modified.png # Based on: https://github.com/mostafaGwely/Structural-Similarity-Index-SSIM- # 1. Import the necessary packages #from skimage.measure import compare_ssim as ssim ..