Compare commits
4 Commits
03758861a1
...
27a0cca978
Author | SHA1 | Date |
---|---|---|
|
27a0cca978 | |
|
3795e41fd7 | |
|
de27fb8a81 | |
|
c1a6dc693d |
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
"Source x Target Mapper": "소스 x 타겟 매퍼",
|
||||
"select a source image": "소스 이미지 선택",
|
||||
"Preview": "미리보기",
|
||||
"select a target image or video": "타겟 이미지 또는 영상 선택",
|
||||
"save image output file": "이미지 출력 파일 저장",
|
||||
"save video output file": "영상 출력 파일 저장",
|
||||
"select a target image": "타겟 이미지 선택",
|
||||
"source": "소스",
|
||||
"Select a target": "타겟 선택",
|
||||
"Select a face": "얼굴 선택",
|
||||
"Keep audio": "오디오 유지",
|
||||
"Face Enhancer": "얼굴 향상",
|
||||
"Many faces": "여러 얼굴",
|
||||
"Show FPS": "FPS 표시",
|
||||
"Keep fps": "FPS 유지",
|
||||
"Keep frames": "프레임 유지",
|
||||
"Fix Blueish Cam": "푸른빛 카메라 보정",
|
||||
"Mouth Mask": "입 마스크",
|
||||
"Show Mouth Mask Box": "입 마스크 박스 표시",
|
||||
"Start": "시작",
|
||||
"Live": "라이브",
|
||||
"Destroy": "종료",
|
||||
"Map faces": "얼굴 매핑",
|
||||
"Processing...": "처리 중...",
|
||||
"Processing succeed!": "처리 성공!",
|
||||
"Processing ignored!": "처리 무시됨!",
|
||||
"Failed to start camera": "카메라 시작 실패",
|
||||
"Please complete pop-up or close it.": "팝업을 완료하거나 닫아주세요.",
|
||||
"Getting unique faces": "고유 얼굴 가져오는 중",
|
||||
"Please select a source image first": "먼저 소스 이미지를 선택해주세요",
|
||||
"No faces found in target": "타겟에서 얼굴을 찾을 수 없음",
|
||||
"Add": "추가",
|
||||
"Clear": "지우기",
|
||||
"Submit": "제출",
|
||||
"Select source image": "소스 이미지 선택",
|
||||
"Select target image": "타겟 이미지 선택",
|
||||
"Please provide mapping!": "매핑을 입력해주세요!",
|
||||
"At least 1 source with target is required!": "최소 하나의 소스와 타겟이 필요합니다!",
|
||||
"Face could not be detected in last upload!": "최근 업로드에서 얼굴을 감지할 수 없습니다!",
|
||||
"Select Camera:": "카메라 선택:",
|
||||
"All mappings cleared!": "모든 매핑이 삭제되었습니다!",
|
||||
"Mappings successfully submitted!": "매핑이 성공적으로 제출되었습니다!",
|
||||
"Source x Target Mapper is already open.": "소스 x 타겟 매퍼가 이미 열려 있습니다."
|
||||
}
|
|
@ -799,73 +799,39 @@ def webcam_preview(root: ctk.CTk, camera_index: int):
|
|||
|
||||
|
||||
def get_available_cameras():
|
||||
"""Returns a list of available camera names and indices."""
|
||||
"""
|
||||
Safe camera detection for macOS and Unix-like systems that avoids threading and AVX crashes.
|
||||
Returns a tuple of (camera_indices, camera_names).
|
||||
"""
|
||||
import cv2
|
||||
import platform
|
||||
|
||||
if platform.system() == "Windows":
|
||||
try:
|
||||
from pygrabber.dshow_graph import FilterGraph
|
||||
graph = FilterGraph()
|
||||
devices = graph.get_input_devices()
|
||||
|
||||
# Create list of indices and names
|
||||
camera_indices = list(range(len(devices)))
|
||||
camera_names = devices
|
||||
|
||||
# If no cameras found through DirectShow, try OpenCV fallback
|
||||
if not camera_names:
|
||||
# Try to open camera with index -1 and 0
|
||||
test_indices = [-1, 0]
|
||||
working_cameras = []
|
||||
|
||||
for idx in test_indices:
|
||||
cap = cv2.VideoCapture(idx)
|
||||
if cap.isOpened():
|
||||
working_cameras.append(f"Camera {idx}")
|
||||
cap.release()
|
||||
|
||||
if working_cameras:
|
||||
return test_indices[: len(working_cameras)], working_cameras
|
||||
|
||||
# If still no cameras found, return empty lists
|
||||
if not camera_names:
|
||||
return [], ["No cameras found"]
|
||||
|
||||
return camera_indices, camera_names
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error detecting cameras: {str(e)}")
|
||||
return [], ["No cameras found"]
|
||||
else:
|
||||
# Unix-like systems (Linux/Mac) camera detection
|
||||
camera_indices = []
|
||||
camera_names = []
|
||||
|
||||
if platform.system() == "Darwin": # macOS specific handling
|
||||
# Try to open the default FaceTime camera first
|
||||
cap = cv2.VideoCapture(0)
|
||||
if cap.isOpened():
|
||||
camera_indices.append(0)
|
||||
camera_names.append("FaceTime Camera")
|
||||
cap.release()
|
||||
|
||||
# On macOS, additional cameras typically use indices 1 and 2
|
||||
for i in [1, 2]:
|
||||
cap = cv2.VideoCapture(i)
|
||||
if cap.isOpened():
|
||||
camera_indices.append(i)
|
||||
camera_names.append(f"Camera {i}")
|
||||
cap.release()
|
||||
else:
|
||||
# Linux camera detection - test first 10 indices
|
||||
for i in range(10):
|
||||
cap = cv2.VideoCapture(i)
|
||||
if cap.isOpened():
|
||||
camera_indices.append(i)
|
||||
camera_names.append(f"Camera {i}")
|
||||
cap.release()
|
||||
|
||||
if not camera_names:
|
||||
print(f"[Camera Detection Error - Windows]: {e}")
|
||||
return [], ["No cameras found"]
|
||||
|
||||
return camera_indices, camera_names
|
||||
# macOS or Linux
|
||||
try:
|
||||
print("[Info] Safely checking for available cameras...")
|
||||
cap = cv2.VideoCapture(0)
|
||||
if cap is None or not cap.isOpened():
|
||||
print("[Warning] Default camera (index 0) not available.")
|
||||
return [], ["No cameras found"]
|
||||
cap.release()
|
||||
return [0], ["Default Camera (Index 0)"]
|
||||
except Exception as e:
|
||||
print(f"[Camera Detection Error - Unix]: {e}")
|
||||
return [], ["No cameras found"]
|
||||
|
||||
|
||||
def create_webcam_preview(camera_index: int):
|
||||
|
|
Loading…
Reference in New Issue