重写隐藏光标
This commit is contained in:
parent
eb4da825d0
commit
dd10ab4fad
34
face_rec.py
34
face_rec.py
@ -18,10 +18,44 @@ import queue
|
||||
from compreface import CompreFace
|
||||
from compreface.service import RecognitionService, DetectionService
|
||||
|
||||
# 隐藏鼠标光标(Linux/GDK)
|
||||
def hide_cursor():
|
||||
"""隐藏鼠标光标"""
|
||||
try:
|
||||
import ctypes
|
||||
from ctypes import cdll
|
||||
|
||||
libgdk = cdll.LoadLibrary('libgdk-3.so.0')
|
||||
libgtk = cdll.LoadLibrary('libgtk-3.so.0')
|
||||
|
||||
# 初始化 GTK
|
||||
libgtk.gtk_init_none()
|
||||
|
||||
# 获取默认显示
|
||||
display = libgdk.gdk_display_get_default()
|
||||
|
||||
# 创建空白光标(GDK_BLANK_CURSOR = -2)
|
||||
cursor = libgdk.gdk_cursor_new_for_display(display, -2)
|
||||
|
||||
# 获取默认屏幕和根窗口
|
||||
screen = libgdk.gdk_display_get_default_screen(display)
|
||||
root = libgdk.gdk_screen_get_root_window(screen)
|
||||
|
||||
# 设置光标
|
||||
libgdk.gdk_window_set_cursor(root, cursor)
|
||||
libgdk.gdk_display_flush(display)
|
||||
|
||||
print("Cursor hidden via GDK")
|
||||
except Exception as e:
|
||||
print(f"Hide cursor error: {e}")
|
||||
|
||||
|
||||
class FaceRecognitionSystem:
|
||||
def __init__(self, config_path: str = "config.yaml"):
|
||||
"""初始化人脸识别系统"""
|
||||
# 先隐藏鼠标光标(在任何窗口创建之前)
|
||||
hide_cursor()
|
||||
|
||||
# 加载配置
|
||||
with open(config_path, 'r', encoding='utf-8') as f:
|
||||
self.config = yaml.safe_load(f)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user