iperov / DeepFaceLive

Real-time face swap for PC streaming or video calls
GNU General Public License v3.0
24.81k stars 4.13k forks source link

How to use this code without frontend QT? #143

Closed dandelion915 closed 1 year ago

dandelion915 commented 1 year ago

Thanks for your wonderful work! I would like to know how to use this code to bypass the QT interface and accomplish the function of calling the camera and outputting the result video in real time.Now I found that the buttons in the QT interface call the start method of each function to open a separate thread, I commented out the QT related codes in DeepFaceLiveApp.py and added the .start methods one by one, but I found that the threads blocked although I was able to call camera and face detection and face alignment, but could not get to face swap and merge. Could you please give me some hint about how to proceed?

line66 of DeepFaceLiveApp.py : face_detector.start() face_marker.start() face_aligner.start() face_swapper.start() frame_adjuster.start() face_merger.start() stream_output.start()

    camera_source.start()
    # 
    # self.q_file_source    = QFileSource(self.file_source)
    # self.q_camera_source  = QCameraSource(self.camera_source)
    # self.q_face_detector  = QFaceDetector(self.face_detector)
    # self.q_face_marker    = QFaceMarker(self.face_marker)
    # self.q_face_aligner   = QFaceAligner(self.face_aligner)
    # self.q_face_animator  = QFaceAnimator(self.face_animator, animatables_path=animatables_path)
    # self.q_face_swapper   = QFaceSwapper(self.face_swapper, dfm_models_path=dfm_models_path)
    # self.q_frame_adjuster = QFrameAdjuster(self.frame_adjuster)
    # self.q_face_merger    = QFaceMerger(self.face_merger)
    # self.q_stream_output  = QStreamOutput(self.stream_output)
    # 
    # self.q_ds_frame_viewer = QBCFrameViewer(backend_weak_heap, multi_sources_bc_out)
    # self.q_ds_fa_viewer    = QBCFaceAlignViewer(backend_weak_heap, face_aligner_bc_out, preview_width=256)
    # self.q_ds_fc_viewer    = QBCFaceSwapViewer(backend_weak_heap, face_merger_bc_out, preview_width=256)
    # self.q_ds_merged_frame_viewer = QBCMergedFrameViewer(backend_weak_heap, face_merger_bc_out)
    # 
    # q_nodes = qtx.QXWidgetHBox([    qtx.QXWidgetVBox([self.q_file_source, self.q_camera_source], spacing=5, fixed_width=256),
    #                                 qtx.QXWidgetVBox([self.q_face_detector,  self.q_face_aligner,], spacing=5, fixed_width=256),
    #                                 qtx.QXWidgetVBox([self.q_face_marker, self.q_face_animator, self.q_face_swapper], spacing=5, fixed_width=256),
    #                                 qtx.QXWidgetVBox([self.q_frame_adjuster, self.q_face_merger, self.q_stream_output], spacing=5, fixed_width=256),
    #                             ], spacing=5, size_policy=('fixed', 'fixed') )
    # 
    # q_view_nodes = qtx.QXWidgetHBox([   (qtx.QXWidgetVBox([self.q_ds_frame_viewer], fixed_width=256), qtx.AlignTop),
    #                                     (qtx.QXWidgetVBox([self.q_ds_fa_viewer], fixed_width=256), qtx.AlignTop),
    #                                     (qtx.QXWidgetVBox([self.q_ds_fc_viewer], fixed_width=256), qtx.AlignTop),
    #                                     (qtx.QXWidgetVBox([self.q_ds_merged_frame_viewer], fixed_width=256), qtx.AlignTop),
    #                                 ], spacing=5, size_policy=('fixed', 'fixed') )
    # 
    # self.setLayout(qtx.QXVBoxLayout( [ (qtx.QXWidgetVBox([q_nodes, q_view_nodes], spacing=5), qtx.AlignCenter) ]))
    # 
    # self._timer = qtx.QXTimer(interval=5, timeout=self._on_timer_5ms, start=True)
iperov commented 1 year ago

issue not related to dflive