opencv 화면 캡처후 이미지 저장, 파이썬 코드


opencv 화면 캡처후 이미지 저장, 파이썬 코드

import cv2 import os # 이미지 저장 초기 경로 SAVE_PATH = "C:/senow/" # 이미지 저장 함수 def displayCapture(screenshot): # screenshot을 통해 opencv 창 정보를 받아옴 # 이미지 저장 폴더, 없는 경우 생성, 있는 경우 pass if not os.path.exists(SAVE_PATH): os.makedirs(SAVE_PATH) try: # 현재 시간을 파일 이름으로 사용하여 png 파일로 저장 current_time = datetime.datetime.now().strftime("%Y-%m-%d %H-%M-%S") file_name = f"{SAVE_PATH}/{current_time}.png" cv2.imwrite(file_name, screenshot) # 이미지 저장 print(f"Screenshot saved to {file_name}") # 출력 except: print("에러 발생")...



원문링크 : opencv 화면 캡처후 이미지 저장, 파이썬 코드