examples: update camera_* with video_*

This commit is contained in:
Aleix Conchillo Flaqué
2025-04-23 13:39:50 -07:00
parent 420912dd4b
commit e79a002e5a
36 changed files with 98 additions and 101 deletions

View File

@@ -27,10 +27,10 @@ load_dotenv(override=True)
class EdgeDetectionProcessor(FrameProcessor):
def __init__(self, camera_out_width, camera_out_height: int):
def __init__(self, video_out_width, video_out_height: int):
super().__init__()
self._camera_out_width = camera_out_width
self._camera_out_height = camera_out_height
self._video_out_width = video_out_width
self._video_out_height = video_out_height
async def process_frame(self, frame: Frame, direction: FrameDirection):
await super().process_frame(frame, direction)
@@ -45,7 +45,7 @@ class EdgeDetectionProcessor(FrameProcessor):
img = cv2.cvtColor(cv2.Canny(img, 100, 200), cv2.COLOR_GRAY2BGR)
# convert the size if needed
desired_size = (self._camera_out_width, self._camera_out_height)
desired_size = (self._video_out_width, self._video_out_height)
if frame.size != desired_size:
resized_image = cv2.resize(img, desired_size)
frame = OutputImageRawFrame(resized_image.tobytes(), desired_size, frame.format)
@@ -71,13 +71,13 @@ Respond to what the user said in a creative and helpful way. Keep your responses
async def run_bot(webrtc_connection):
transport_params = TransportParams(
camera_in_enabled=True,
camera_out_enabled=True,
camera_out_is_live=True,
audio_in_enabled=True,
audio_out_enabled=True,
vad_analyzer=SileroVADAnalyzer(),
audio_out_10ms_chunks=2,
video_in_enabled=True,
video_out_enabled=True,
video_out_is_live=True,
vad_analyzer=SileroVADAnalyzer(),
)
pipecat_transport = SmallWebRTCTransport(
@@ -111,7 +111,7 @@ async def run_bot(webrtc_connection):
rtvi,
llm, # LLM
EdgeDetectionProcessor(
transport_params.camera_out_width, transport_params.camera_out_height
transport_params.video_out_width, transport_params.video_out_height
), # Sending the video back to the user
pipecat_transport.output(),
context_aggregator.assistant(),