meiyouruguo 发表于 2024-7-26 19:05:21

deepfacelive调整摄像头分辨率和鼠标调节输出窗口大小

修改X:\DeepFaceLive_NVIDIA\_internal\DeepFaceLive\apps\DeepFaceLive\backend
目录下CameraSource.py文件的参数即可添加竖屏(X表示你自己存放Live的盘符)



增加分辨率:修改CameraSource.py文件

    RES_320x240 = 0
    RES_640x480 = 1
    RES_720x480 = 2
    RES_1280x720 = 3
    RES_1280x960 = 4
    RES_1366x768 = 5
    RES_1920x1080 = 6
    RES_960x1280 = 7
    RES_768x1366 = 8
    RES_1080x1920 = 9
    RES_576x1024 = 10

_ResolutionType_names = {_ResolutionType.RES_320x240 : '320x240',
                        _ResolutionType.RES_640x480 : '640x480',
                         _ResolutionType.RES_720x480 : '720x480',
                         _ResolutionType.RES_1280x720 : '1280x720',
                         _ResolutionType.RES_1280x960 : '1280x960',
                         _ResolutionType.RES_1366x768 : '1366x768',
                         _ResolutionType.RES_1920x1080 : '1920x1080',
                         _ResolutionType.RES_960x1280 : '960x1280',
                         _ResolutionType.RES_768x1366 : '768x1366',
                         _ResolutionType.RES_1080x1920 : '1080x1920',
                         _ResolutionType.RES_576x1024 : '576x1024',
                        }

_ResolutionType_wh = {_ResolutionType.RES_320x240: (320,240),
                      _ResolutionType.RES_640x480: (640,480),
                      _ResolutionType.RES_720x480: (720,480),
                      _ResolutionType.RES_1280x720: (1280,720),
                      _ResolutionType.RES_1280x960: (1280,960),
                      _ResolutionType.RES_1366x768: (1366,768),
                      _ResolutionType.RES_1920x1080: (1920,1080),
                      _ResolutionType.RES_960x1280: (960,1280),
                      _ResolutionType.RES_768x1366: (768,1366),
                      _ResolutionType.RES_1080x1920: (1080,1920),
                      _ResolutionType.RES_576x1024: (576,1024),
                      }

大分辨率下,输出窗口显示不完整,增加鼠标缩放输出窗口功能,修改StreamOutput.py 文件


    # def show_window(self):
      # state, cs = self.get_state(), self.get_control_sheet()
      # cv2.namedWindow(self._wnd_name)
      # self._wnd_showing = True

修改为下方代码

    def show_window(self):
      state, cs = self.get_state(), self.get_control_sheet()
      cv2.namedWindow(self._wnd_name, cv2.WINDOW_NORMAL)# 确保窗口为可调整大小的模式
      self._wnd_showing = True
________________________________________________________

    # def on_cs_show_hide_window_signal(self,):
      # state, cs = self.get_state(), self.get_control_sheet()

      # state.is_showing_window = not state.is_showing_window
      # if state.is_showing_window:
            # cv2.namedWindow(self._wnd_name)
      # else:
            # cv2.destroyAllWindows()
      # self.save_state()
      # self.reemit_frame_signal.send()


修改为下方代码

    def on_cs_show_hide_window_signal(self):
      state, cs = self.get_state(), self.get_control_sheet()

      state.is_showing_window = not state.is_showing_window
      if state.is_showing_window:
            cv2.namedWindow(self._wnd_name, cv2.WINDOW_NORMAL)# 确保窗口为可调整大小的模式
      else:
            cv2.destroyAllWindows()
      self.save_state()
      self.reemit_frame_signal.send()


修改show_window 和 on_cs_show_hide_window_signal 方法




jandown 发表于 2024-7-28 15:00:26

有人测试过吗
修改了后,输出窗口被强制压缩成竖屏,而且鼠标滚轮也没有生效,无法滚动调节

meiyouruguo 发表于 2024-7-28 23:03:55

jandown 发表于 2024-7-28 15:00
有人测试过吗
修改了后,输出窗口被强制压缩成竖屏,而且鼠标滚轮也没有生效,无法滚动调节 ...

不是鼠标滑动缩放,是鼠标拖拽窗口缩放

jandown 发表于 2024-7-29 06:35:14

meiyouruguo 发表于 2024-7-28 23:03
不是鼠标滑动缩放,是鼠标拖拽窗口缩放

:lol
理解错了
页: [1]
查看完整版本: deepfacelive调整摄像头分辨率和鼠标调节输出窗口大小