Почему FPS (кадров в секунду) упал после того, как я добавил задержку в 30 мс между отправкой кадров клиенту с использовPython

Программы на Python
Anonymous
Почему FPS (кадров в секунду) упал после того, как я добавил задержку в 30 мс между отправкой кадров клиенту с использов

Сообщение Anonymous »


I modified the below code to the code just below it to send frames after 30ms delay to get better FPS but to my surprise they dropped drastically instead of going up, earlier I was receiving 22 fps after modification I got just 2 fps

Before:
def _producer(self): old_frame = None self._setReady(True) while not self._shouldClose: if not context.context_dict[context.rtc_connections]: time.sleep(0.1) continue frame_to_send = context.context_dict[context.currentFrame] if old_frame is None: self._put_nowait(frame_to_send) else: is_similar = old_frame == frame_to_send if isinstance(is_similar, np.ndarray): is_similar = is_similar.all() if not is_similar: self._put_nowait(frame_to_send) if frame_to_send is not None: old_frame = frame_to_send self._setReady(False) self._log.info("Ended camera capture")
After: def _producer(self): self._setReady(True) last_frame_time = None while not self._shouldClose: if not context.context_dict[context.rtc_connections]: time.sleep(0.1) continue if last_frame_time is None: last_frame_time = time.time() frame_to_send = context.context_dict[context.currentFrame] self._put_nowait(frame_to_send) current_frame_time = time.time() if round(current_frame_time - last_frame_time, 2) < 0.03: continue last_frame_time = current_frame_time frame_to_send = context.context_dict[context.currentFrame] if frame_to_send is not None: self._put_nowait(frame_to_send) self._setReady(False) self._log.info("Ended camera capture")

Источник: https://stackoverflow.com/questions/780 ... -frames-se

Вернуться в «Python»