OpenCV

OpenCVTools enables agents to capture images and videos from webcam using OpenCV computer vision library.

Example

The following agent can capture images and videos from your webcam:

1from kern.agent import Agent
2from kern.tools.opencv import OpenCVTools
3
4agent = Agent(
5 instructions=[
6 "You are a computer vision assistant that can capture images and videos",
7 "Use the webcam to take photos or record videos as requested",
8 "Provide clear feedback about capture operations",
9 "Help with basic computer vision tasks",
10 ],
11 tools=[OpenCVTools()],
12)
13
14agent.print_response("Take a photo using the webcam", stream=True)

Toolkit Params

ParameterTypeDefaultDescription
show_previewboolFalseWhether to show camera preview window during capture.
enable_capture_imageboolTrueEnable image capture functionality.
enable_capture_videoboolTrueEnable video capture functionality.

Toolkit Functions

FunctionDescription
capture_imageCapture a single image from the webcam.
capture_videoRecord a video from the webcam for a specified duration.

Developer Resources