OpenCV MCP(Open Source Computer Vision Machine Learning Processing)服务器是基于Python的图像与视频处理工具。它融合了OpenCV库功能和机器学习模型,支持实时处理、批量处理和云部署,为图像和视频处理提供了强大的解决方案。
使用以下命令安装 OpenCV MCP 服务器:
pip install opencv-mcp-server
resize_image_tool):调整图像的宽度和高度。result = resize_image_tool(
image_path="input.jpg",
width=800,
height=600
)
resized_image_path = result["output_path"]
apply_filter_tool):应用不同类型的图像滤镜。result = apply_filter_tool(
image_path="input.jpg",
filter_type="gaussian",
kernel_size=5
)
filtered_image_path = result["output_path"]
detect_objects_tool):使用预训练的模型在图像中检测目标。detections = detect_objects_tool(
image_path="input.jpg",
confidence_threshold=0.7,
nms_threshold=0.3
)
for detection in detections:
print(f"Detected object: {detection['label']}, Confidence: {detection['confidence']}")
extract_video_frames_tool):从视频文件中提取特定帧。frames = extract_video_frames_tool(
video_path="input.mp4",
start_frame=0,
step=10,
max_frames=50
)
for frame in frames:
print(f"Frame {frame['index']} extracted at path: {frame['path']}")
detect_video_objects_tool):在视频流中实时检测目标。detections = detect_video_objects_tool(
video_path="input.mp4",
model_paths=["model1.pth", "model2.pth"],
confidence_threshold=0.5,
frame_step=1
)
for detection in detections:
print(f"Detected object: {detection['label']}, Confidence: {detection['confidence']}")
generate_histogram_tool):生成图像的颜色直方图。histogram = generate_histogram_tool(
image_path="input.jpg",
color_space="RGB",
bins=256
)
detections = detect_objects_tool(
image_path="input.jpg",
confidence_threshold=0.7,
nms_threshold=0.3
)
for detection in detections:
print(f"Detected object: {detection['label']}, Confidence: {detection['confidence']}")
frames = extract_video_frames_tool(
video_path="input.mp4",
start_frame=0,
step=10,
max_frames=50
)
for frame in frames:
print(f"Frame {frame['index']} extracted at path: {frame['path']}")
resize_image_tool)调整图像的宽度和高度。 参数:
image_path: 输入图像路径。width: 调整后的宽度。height: 调整后的高度。apply_filter_tool)应用不同类型的图像滤镜。 参数:
image_path: 输入图像路径。filter_type: 滤镜类型("gaussian", "median", "blur" 等)。kernel_size: 核大小(默认为3)。sigma: 高斯标准差(仅适用于高斯滤镜)。detect_objects_tool)使用预训练的模型在图像中检测目标。 参数:
image_path: 输入图像路径。confidence_threshold: 置信度阈值(默认为0.5)。nms_threshold: 非极大值抑制阈值(默认为0.4)。extract_video_frames_tool)从视频文件中提取特定帧。 参数:
video_path: 输入视频路径。start_frame: 开始帧数(默认为0)。step: 帧步长(默认为1)。max_frames: 最大提取帧数(默认为无限制)。detect_video_objects_tool)在视频流中实时检测目标。 参数:
video_path: 输入视频路径。model_paths: 预训练模型路径列表。confidence_threshold: 置信度阈值(默认为0.5)。frame_step: 帧处理步长(默认为1)。generate_histogram_tool)生成图像的颜色直方图。 参数:
image_path: 输入图像路径。color_space: 颜色空间("RGB", "HSV", "LUV" 等)。bins: 直方图的 bins 数量(默认为256)。如需商业用途,请联系项目维护者获取授权和相关支持服务。