OpenCV 그리기 특정 윤곽선 (OpenCV drawing specific contours)


문제 설명

OpenCV 그리기 특정 윤곽선 (OpenCV drawing specific contours)

감지하려는 GUI 요소가 있고 배경색이 많이 다르며 다이아몬드 모양 윤곽선을 감지하는 데 문제가 있습니다.

원본 이미지:

원본 이미지

지금까지 가지고 있는 것:

Input

이 이미지는 단순 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)

내가 원하는 결과는 다음과 같은 아이콘 프레임을 찾는 것입니다.

expected

나는 이미 형태학적 변환의 일부 조합을 사용하여 다른 기술을 시도했지만 이미지 처리에 대한 경험이 부족하여 이것을 알아내기가 어렵습니다.

편집: 원본 이미지 추가

나는 이미 형태학적 변형의 몇 가지 조합을 사용하여 다른 기술을 시도했지만 이미지 처리에 대한 경험이 부족하여 이것을 알아내기가 어렵습니다.

편집: 원본 이미지 추가

나는 이미 형태학적 변형의 몇 가지 조합을 사용하여 다른 기술을 시도했지만 이미지 처리에 대한 경험이 부족하여 이것을 알아내기가 어렵습니다.

편집: 원본 이미지 추가


참조 솔루션

방법 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 KiKoSyilmazdoga)

참조 문서

  1. OpenCV drawing specific contours (CC BY‑SA 2.5/3.0/4.0)

#Python #image-processing #opencv-python #OpenCV






관련 질문

Python - 파일 이름에 특수 문자가 있는 파일의 이름을 바꿀 수 없습니다. (Python - Unable to rename a file with special characters in the file name)

구조화된 배열의 dtype을 변경하면 문자열 데이터가 0이 됩니다. (Changing dtype of structured array zeros out string data)

목록 목록의 효과적인 구현 (Effective implementation of list of lists)

for 루프를 중단하지 않고 if 문을 중지하고 다른 if에 영향을 줍니다. (Stop if statement without breaking for loop and affect other ifs)

기본 숫자를 10 ^ 9 이상으로 늘리면 코드가 작동하지 않습니다. (Code fails to work when i increase the base numbers to anything over 10 ^ 9)

사용자 지정 대화 상자 PyQT5를 닫고 데이터 가져오기 (Close and get data from a custom dialog PyQT5)

Enthought Canopy의 Python: csv 파일 조작 (Python in Enthought Canopy: manipulating csv files)

학생의 이름을 인쇄하려고 하는 것이 잘못된 것은 무엇입니까? (What is wrong with trying to print the name of the student?)

다단계 열 테이블에 부분합 열 추가 (Adding a subtotal column to a multilevel column table)

여러 함수의 변수를 다른 함수로 사용 (Use variables from multiple functions into another function)

리프 텐서의 값을 업데이트하는 적절한 방법은 무엇입니까(예: 경사하강법 업데이트 단계 중) (What's the proper way to update a leaf tensor's values (e.g. during the update step of gradient descent))

Boto3: 조직 단위의 AMI에 시작 권한을 추가하려고 하면 ParamValidationError가 발생합니다. (Boto3: trying to add launch permission to AMI for an organizational unit raises ParamValidationError)







코멘트