문제 설명
OpenCV 그리기 특정 윤곽선 (OpenCV drawing specific contours)
감지하려는 GUI 요소가 있고 배경색이 많이 다르며 다이아몬드 모양 윤곽선을 감지하는 데 문제가 있습니다.
원본 이미지:
지금까지 가지고 있는 것:
이 이미지는 단순 bgr을 회색으로 변환, 흐리게 처리한 다음 다음 코드로 가우스 적응 임계값 적용:
crop_img = img.copy()
crop_gray = cv2.cvtColor(crop_img, cv2.COLOR_BGR2GRAY)
blurred = cv2.blur(crop_gray, (5, 5), 0)
thresh = cv2.adaptiveThreshold(blurred, 255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY_INV, 21, 4)
내가 원하는 결과는 다음과 같은 아이콘 프레임을 찾는 것입니다.
나는 이미 형태학적 변환의 일부 조합을 사용하여 다른 기술을 시도했지만 이미지 처리에 대한 경험이 부족하여 이것을 알아내기가 어렵습니다.
편집: 원본 이미지 추가
나는 이미 형태학적 변형의 몇 가지 조합을 사용하여 다른 기술을 시도했지만 이미지 처리에 대한 경험이 부족하여 이것을 알아내기가 어렵습니다.편집: 원본 이미지 추가
나는 이미 형태학적 변형의 몇 가지 조합을 사용하여 다른 기술을 시도했지만 이미지 처리에 대한 경험이 부족하여 이것을 알아내기가 어렵습니다.편집: 원본 이미지 추가
참조 솔루션
방법 1:
As far as I know these GUI elements are from Dead By Daylight(Game). Thus, I assume that you want to process the video feed from the game.
You can use consecutive frames and track the similarities between them. Since the background changes as the player or the in game objects move, the only part which does not change is the GUI elements. I wrote a pseudocode below which compares 2 frames and outputs a mask which shows the unchanged pixels.
from skimage.measure import compare_ssim
frame0 = video_feed.get_next_frame()
frame1 = video_feed.get_next_frame()
gray_frame0 = cv2.cvtColor(frame0, cv2.COLOR_BGR2GRAY)
gray_frame1 = cv2.cvtColor(frame1, cv2.COLOR_BGR2GRAY)
(score, diff) = compare_ssim(gray_frame0, gray_frame1, full=True)
thresh = cv2.threshold(diff, 0, 255, cv2.THRESH_BINARY_INV)
Hope this kind of approach works for your application.
(by KiKoS、yilmazdoga)