BabitMF / bmf

Cross-platform, customizable multimedia/video processing framework. With strong GPU acceleration, heterogeneous design, multi-language support, easy to use, multi-framework compatible and high performance, the framework is ideal for transcoding, AI inference, algorithm integration, live video streaming, and more.
https://babitmf.github.io/
Apache License 2.0
807 stars 71 forks source link

人脸检测demo代码trt_face_detect.py内关于output_queue_size的逻辑的使用方法 #114

Open QQiangren opened 6 months ago

QQiangren commented 6 months ago

trt_face_detect.py的代码片段 :

def process(self, task):
    input_queue = task.get_inputs()[0]
    output_queue_0 = task.get_outputs()[0]
    output_queue_size = len(task.get_outputs())
    if output_queue_size >= 2:
        output_queue_1 = task.get_outputs()[1]

    while not input_queue.empty():
        pkt = input_queue.get()
        if pkt.timestamp == Timestamp.EOF:
            self.eof_received_ = True
        if pkt.is_(VideoFrame):
            self.frame_cache_.put(pkt.get(VideoFrame))

    while self.frame_cache_.qsize(
    ) >= self.in_frame_num_ or self.eof_received_:
        out_frames, detect_result_list = self.inference()
        for idx, frame in enumerate(out_frames):
            pkt = Packet(frame)
            pkt.timestamp = frame.pts
            output_queue_0.put(pkt)

            if (output_queue_size >= 2):
                pkt = Packet(detect_result_list[idx])
                pkt.timestamp = frame.pts
                output_queue_1.put(pkt)

        if self.frame_cache_.empty():
            break

    if self.eof_received_:
        for key in task.get_outputs():
            task.get_outputs()[key].put(Packet.generate_eof_packet())
            Log.log_node(LogLevel.DEBUG, self.node_, "output stream",
                         "done")
        task.timestamp = Timestamp.DONE

    return ProcessResult.OK

代码中有个判断if (output_queue_size >= 2): 进入逻辑后,会对检测结果:detect_result_list进行额外输出。 但是我执行demo时并不能触发这个逻辑分支。请问做什么操作才能使output_queue_size>=2。额外输出一个关于检测结果的输出。 感谢