{"id":30866848,"url":"https://github.com/GongRzhe/opencv-mcp-server","last_synced_at":"2025-09-07T22:07:03.180Z","repository":{"id":287428535,"uuid":"964733342","full_name":"GongRzhe/opencv-mcp-server","owner":"GongRzhe","description":"OpenCV MCP Server  provides OpenCV's image and video processing capabilities through the Model Context Protocol (MCP). Access powerful computer vision tools for tasks ranging from basic image manipulation to advanced object detection and tracking.","archived":false,"fork":false,"pushed_at":"2025-08-04T06:56:09.000Z","size":52802,"stargazers_count":59,"open_issues_count":2,"forks_count":8,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-09-03T12:29:14.551Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GongRzhe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-11T17:38:28.000Z","updated_at":"2025-09-02T09:58:16.000Z","dependencies_parsed_at":"2025-04-11T17:45:59.646Z","dependency_job_id":"d81fc66e-45fe-48a5-8a70-17d1b7ca5564","html_url":"https://github.com/GongRzhe/opencv-mcp-server","commit_stats":null,"previous_names":["gongrzhe/opencv-mcp-server"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/GongRzhe/opencv-mcp-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GongRzhe%2Fopencv-mcp-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GongRzhe%2Fopencv-mcp-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GongRzhe%2Fopencv-mcp-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GongRzhe%2Fopencv-mcp-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GongRzhe","download_url":"https://codeload.github.com/GongRzhe/opencv-mcp-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GongRzhe%2Fopencv-mcp-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274101786,"owners_count":25222448,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-09-07T22:03:19.005Z","updated_at":"2025-09-07T22:07:03.163Z","avatar_url":"https://github.com/GongRzhe.png","language":"Python","funding_links":[],"categories":["Media Processing","MCP Servers for Creative Work","📚 Projects (1974 total)","🤖 AI/ML"],"sub_categories":["Image Processing","Computer Vision","MCP Servers"],"readme":"![logo](https://github.com/user-attachments/assets/2d4527f4-6e2a-48be-8dfe-7b40231aa212)\n\n# 🚀 OpenCV MCP Server\n\nMCP server providing powerful OpenCV computer vision capabilities for AI assistants.\n\n![](https://badge.mcpx.dev?type=server 'MCP Server')\n\n## 🔍 Introduction\n\nOpenCV MCP Server is a Python package that provides OpenCV's image and video processing capabilities through the Model Context Protocol (MCP). This allows AI assistants and language models to access powerful computer vision tools for tasks ranging from basic image manipulation to advanced object detection and tracking.\n\nWith OpenCV MCP Server, AI systems can:\n- Process and analyze images in various formats\n- Perform real-time object detection and tracking\n- Extract meaningful information from visual data\n- Enhance and transform images using advanced algorithms\n- Process video content with frame-by-frame analysis\n\n## ✨ Features\n\n- 📸 **Basic image handling and manipulation** (read, save, convert)\n- 🖼️ **Image processing and enhancement** (resize, crop, filter application)\n- 📊 **Edge detection and contour analysis**\n- 🧠 **Advanced computer vision capabilities** (feature detection, object detection)\n- 😃 **Face detection and recognition**\n- 🎬 **Video processing and analysis** (frame extraction, motion detection)\n- 🔍 **Object tracking in videos**\n- 📹 **Camera integration for real-time object detection**\n\n## 📊 Demo Examples\n\n### Edge Detection\n![Edge Detection](public/DetectEdge.png)\n\n### Face Detection\n![Face Detection](public/DetectFace.png)\n\n### Statistical Analysis\n![Statistical Information](public/GetStatisticalInformation.png)\n\n### Video Processing\n![Video Processing](public/VideoProcess.png)\n\n### Original Video Sample\n![Original Video Demo](public/DemoVideo.gif)\n\n### Contour Detection Processing\n![Contour Detection](public/DemoVideoContourDetection.gif)\n*Example of contour detection processing applied to the original video above*\n\n## 📦 Installation\n\n```bash\npip install opencv-mcp-server\n```\n\nFor development:\n\n```bash\n# Clone the repository\ngit clone https://github.com/yourusername/opencv-mcp-server.git\ncd opencv-mcp-server\n\n# Create a virtual environment\npython -m venv .venv\nsource .venv/bin/activate  # On Windows: .venv\\Scripts\\activate\n\n# Install dependencies\npip install -e .\n```\n\n## 🔧 Usage\n\n### Use in Claude Desktop\n\nAdd to your Claude Desktop configuration:\n\n```json\n{\n    \"mcpServers\": {\n        \"opencv\": {\n            \"command\": \"uvx\",\n            \"args\": [\n                \"opencv-mcp-server\"\n            ]\n        }\n    }\n}\n```\n\nInstall uvx\n\n```bash\nbrew install uv\n```\n\nThen restart Claude Desktop \n\n\u003cimg width=\"1026\" height=\"749\" alt=\"image\" src=\"https://github.com/user-attachments/assets/0355c5a0-92ea-4f5e-a299-4ee8ed9bccd2\" /\u003e\n\n\n### Basic Python Usage\n\n```python\nfrom opencv_mcp_server import opencv_client\n\n# Initialize client\nclient = opencv_client.OpenCVClient()\n\n# Use tools\nresult = client.resize_image(\n    image_path=\"input.jpg\",\n    width=800,\n    height=600\n)\n```\n\n### Advanced Object Detection Example\n\nSince all required models are already configured in the `OPENCV_DNN_MODELS_DIR`, you can use object detection without specifying model paths:\n\n```python\n# Detect objects using pre-configured YOLO model\nresult = detect_objects_tool(\n    image_path=\"street.jpg\",\n    confidence_threshold=0.5,\n    nms_threshold=0.4\n)\n```\n\n### Configuration\n\nThe server can be configured using environment variables:\n\n- `MCP_TRANSPORT`: Transport method (default: \"stdio\")\n- `OPENCV_DNN_MODELS_DIR`: Directory for storing DNN models (default: \"models\")\n- `CV_HAAR_CASCADE_DIR`: Directory for storing Haar cascade files (optional)\n\n## 🧠 Model Files Setup\n\nThe computer vision and object detection tools require pre-trained models to function properly. These models should be placed in the directory specified by the `OPENCV_DNN_MODELS_DIR` environment variable (default: \"./models\").\n\n### Required Models\n\nThe following models have been pre-configured:\n\n- **Face Detection (DNN method)**\n  - `deploy.prototxt` - Face detection configuration\n  - `res10_300x300_ssd_iter_140000.caffemodel` - Face detection model weights\n\n- **Object Detection (YOLO)**\n  - `yolov3.weights` - YOLO model weights\n  - `yolov3.cfg` - YOLO configuration file\n  - `coco.names` - Class names for detected objects\n\n### Model Usage\n\n- The `detect_faces_tool` uses the DNN models when `method=\"dnn\"` is specified\n- The `detect_objects_tool` uses the YOLO models for general object detection\n\nFor those who need to download these models, see the \"Installation\" section or visit:\n- YOLO models: https://pjreddie.com/darknet/yolo/\n- Face detection models: https://github.com/opencv/opencv_3rdparty/tree/dnn_samples_face_detector_20170830\n\n## 🧰 Available Tools\n\nThe OpenCV MCP Server provides a wide range of computer vision tools organized into four categories:\n\n### 📸 Image Basics\n\nThese tools provide fundamental image manipulation capabilities:\n\n- `save_image_tool`: Save an image to a file\n  - Parameters: `path_in` (input image path), `path_out` (output file path)\n  - Returns: Image save status and path information\n  - Example: `save_image_tool(path_in=\"processed.jpg\", path_out=\"final.jpg\")`\n\n- `convert_color_space_tool`: Convert image between color spaces (BGR, RGB, GRAY, HSV, etc.)\n  - Parameters: `image_path`, `source_space`, `target_space`\n  - Returns: Converted image information and path\n  - Example: `convert_color_space_tool(image_path=\"image.jpg\", source_space=\"BGR\", target_space=\"HSV\")`\n\n- `resize_image_tool`: Resize an image to specific dimensions\n  - Parameters: `image_path`, `width`, `height`, `interpolation` (optional)\n  - Returns: Resized image information and path\n  - Example: `resize_image_tool(image_path=\"large.jpg\", width=800, height=600)`\n\n- `crop_image_tool`: Crop a region from an image\n  - Parameters: `image_path`, `x`, `y`, `width`, `height`\n  - Returns: Cropped image information and path\n  - Example: `crop_image_tool(image_path=\"scene.jpg\", x=100, y=150, width=300, height=200)`\n\n- `get_image_stats_tool`: Get statistical information about an image\n  - Parameters: `image_path`, `channels` (boolean, default: true)\n  - Returns: Image statistics and histogram visualization\n  - Example: `get_image_stats_tool(image_path=\"photo.jpg\", channels=True)`\n\n### 🖼️ Image Processing\n\nThese tools provide advanced image processing and transformation capabilities:\n\n- `apply_filter_tool`: Apply various filters to an image (blur, gaussian, median, bilateral)\n  - Parameters: `image_path`, `filter_type`, `kernel_size`, and filter-specific parameters\n  - Returns: Filtered image and filter information\n  - Example: `apply_filter_tool(image_path=\"noisy.jpg\", filter_type=\"gaussian\", kernel_size=5)`\n\n- `detect_edges_tool`: Detect edges in an image using different methods (Canny, Sobel, Laplacian, Scharr)\n  - Parameters: `image_path`, `method`, threshold parameters, and method-specific parameters\n  - Returns: Edge-detected image and method information\n  - Example: `detect_edges_tool(image_path=\"objects.jpg\", method=\"canny\", threshold1=100, threshold2=200)`\n\n- `apply_threshold_tool`: Apply threshold to an image (binary, adaptive, etc.)\n  - Parameters: `image_path`, `threshold_type`, threshold values and method-specific parameters\n  - Returns: Thresholded image and threshold information\n  - Example: `apply_threshold_tool(image_path=\"scan.jpg\", threshold_type=\"binary\", threshold_value=127)`\n\n- `detect_contours_tool`: Detect and optionally draw contours in an image\n  - Parameters: `image_path`, `mode`, `method`, drawing parameters\n  - Returns: Image with contours and contour information\n  - Example: `detect_contours_tool(image_path=\"shapes.jpg\", mode=\"external\", method=\"simple\")`\n\n- `find_shapes_tool`: Find basic shapes in an image (circles, lines)\n  - Parameters: `image_path`, `shape_type`, shape-specific parameters\n  - Returns: Image with shapes and shape information\n  - Example: `find_shapes_tool(image_path=\"geometry.jpg\", shape_type=\"circles\", min_radius=10)`\n\n- `match_template_tool`: Find a template in an image\n  - Parameters: `image_path`, `template_path`, matching parameters\n  - Returns: Image with matches and match information\n  - Example: `match_template_tool(image_path=\"scene.jpg\", template_path=\"object.jpg\", threshold=0.8)`\n\n### 🧠 Computer Vision\n\nThese tools provide high-level computer vision capabilities:\n\n- `detect_features_tool`: Detect features in an image using methods like SIFT, ORB, BRISK\n  - Parameters: `image_path`, `method`, `max_features`, drawing parameters\n  - Returns: Image with keypoints and feature information\n  - Example: `detect_features_tool(image_path=\"landmark.jpg\", method=\"sift\", max_features=500)`\n\n- `match_features_tool`: Match features between two images\n  - Parameters: `image1_path`, `image2_path`, `method`, matching parameters\n  - Returns: Image with matches and match information\n  - Example: `match_features_tool(image1_path=\"scene1.jpg\", image2_path=\"scene2.jpg\", method=\"sift\")`\n\n- `detect_faces_tool`: Detect faces in an image using Haar cascades or DNN\n  - Parameters: `image_path`, `method`, method-specific parameters\n  - Returns: Image with faces and face information\n  - Example: `detect_faces_tool(image_path=\"group.jpg\", method=\"haar\", min_neighbors=5)`\n\n- `detect_objects_tool`: Detect objects using pre-trained DNN models (e.g., YOLO)\n  - Parameters: `image_path`, model paths, detection parameters\n  - Returns: Image with objects and object information\n  - Example: `detect_objects_tool(image_path=\"street.jpg\", confidence_threshold=0.5)`\n\n### 🎬 Video Processing\n\nThese tools provide video analysis and processing capabilities:\n\n- `extract_video_frames_tool`: Extract frames from a video file\n  - Parameters: `video_path`, frame selection parameters\n  - Returns: Extracted frames information and paths\n  - Example: `extract_video_frames_tool(video_path=\"clip.mp4\", start_frame=0, step=10, max_frames=20)`\n\n- `detect_motion_tool`: Detect motion between two frames\n  - Parameters: `frame1_path`, `frame2_path`, detection parameters\n  - Returns: Motion detection results and visualizations\n  - Example: `detect_motion_tool(frame1_path=\"frame1.jpg\", frame2_path=\"frame2.jpg\", threshold=25)`\n\n- `track_object_tool`: Track an object across video frames\n  - Parameters: `video_path`, `initial_bbox`, tracking parameters\n  - Returns: Tracking results and extracted frames\n  - Example: `track_object_tool(video_path=\"tracking.mp4\", initial_bbox=[100, 100, 50, 50])`\n\n- `combine_frames_to_video_tool`: Combine frames into a video file\n  - Parameters: `frame_paths`, `output_path`, video parameters\n  - Returns: Video creation results\n  - Example: `combine_frames_to_video_tool(frame_paths=[\"frame1.jpg\", \"frame2.jpg\"], output_path=\"output.mp4\")`\n\n- `create_mp4_from_video_tool`: Convert a video file to MP4 format\n  - Parameters: `video_path`, `output_path`, conversion parameters\n  - Returns: Conversion results including MP4 path\n  - Example: `create_mp4_from_video_tool(video_path=\"input.avi\", output_path=\"output.mp4\")`\n\n- `detect_video_objects_tool`: Detect objects in a video and create a detection result video\n  - Parameters: `video_path`, model paths, detection parameters\n  - Returns: Object detection results and output video path\n  - Example: `detect_video_objects_tool(video_path=\"traffic.mp4\", confidence_threshold=0.5)`\n\n- `detect_camera_objects_tool`: Detect objects from computer's camera and save to video\n  - Parameters: `camera_id`, recording parameters, model paths, detection parameters\n  - Returns: Object detection results and output video path\n  - Example: `detect_camera_objects_tool(camera_id=0, duration=30, confidence_threshold=0.5)`\n\n## 📝 Advanced Usage Examples\n\n### 📸 Basic Image Processing\n\n```python\n# Resize an image\nresult = resize_image_tool(\n    image_path=\"input.jpg\",\n    width=800,\n    height=600\n)\n# Access the resized image path\nresized_image_path = result[\"output_path\"]\n\n# Apply a Gaussian blur filter\nresult = apply_filter_tool(\n    image_path=\"input.jpg\",\n    filter_type=\"gaussian\",\n    kernel_size=5,\n    sigma=1.5\n)\n```\n\n### 🧠 Object Detection\n\n```python\n# Detect objects in an image using YOLO\nresult = detect_objects_tool(\n    image_path=\"scene.jpg\",\n    confidence_threshold=0.5,\n    nms_threshold=0.4\n)\n# Access detected objects\nobjects = result[\"objects\"]\nfor obj in objects:\n    print(f\"Detected {obj['class_name']} with confidence {obj['confidence']}\")\n```\n\n### 🎬 Video Analysis\n\n```python\n# Extract frames from a video\nresult = extract_video_frames_tool(\n    video_path=\"input.mp4\",\n    start_frame=0,\n    step=10,\n    max_frames=10\n)\n# Access extracted frames\nframes = result[\"frames\"]\n\n# Detect objects in a video\nresult = detect_video_objects_tool(\n    video_path=\"input.mp4\",\n    confidence_threshold=0.5,\n    frame_step=5\n)\n```\n\n### 🔄 Chaining Operations\n\nTools can be chained together by using the `output_path` from one tool as the input to another:\n\n```python\n# First resize an image\nresult1 = resize_image_tool(\n    image_path=\"input.jpg\",\n    width=800,\n    height=600\n)\n\n# Then apply edge detection to the resized image\nresult2 = detect_edges_tool(\n    image_path=result1[\"output_path\"],\n    method=\"canny\",\n    threshold1=100,\n    threshold2=200\n)\n\n# Finally detect contours in the edge-detected image\nresult3 = detect_contours_tool(\n    image_path=result2[\"output_path\"],\n    mode=\"external\",\n    method=\"simple\"\n)\n```\n\n## 🔍 Real-world Applications\n\nOpenCV MCP Server can be used for a wide range of applications:\n\n- 🤖 **Autonomous Systems**: Vision-based navigation and obstacle detection\n- 🚗 **Traffic Analysis**: Vehicle counting, speed estimation, and license plate recognition\n- 🔐 **Security Systems**: Motion detection and facial recognition\n- 📱 **Augmented Reality**: Feature tracking and pose estimation\n- 🏥 **Medical Imaging**: Tissue segmentation and anomaly detection\n- 🏭 **Industrial Inspection**: Defect detection and quality control\n- 🖼️ **Digital Art**: Image filtering and transformation\n- 🎲 **Gaming**: Gesture recognition and player tracking\n\n## 🗺️ Roadmap\n\nFuture enhancements planned for OpenCV MCP Server:\n\n- 📊 Additional statistical analysis tools\n- 🧬 Advanced segmentation algorithms\n- 🧠 Integration with machine learning models\n- 🌐 3D vision capabilities\n- 📱 Mobile-friendly processing options\n- ⚡ Performance optimizations for real-time processing\n\n## 🤝 Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n1. Fork the project\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## 📜 License\n\nMIT License - See the LICENSE file for details.\n\n## 📞 Contact\n\nFor questions or feedback, please open an issue on the GitHub repository.\n\n---\n\nBuilt with ❤️ using OpenCV and Python.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGongRzhe%2Fopencv-mcp-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGongRzhe%2Fopencv-mcp-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGongRzhe%2Fopencv-mcp-server/lists"}