{"id":51024006,"url":"https://github.com/x0root/cvbridge","last_synced_at":"2026-06-21T18:01:04.429Z","repository":{"id":362073293,"uuid":"1257008420","full_name":"x0root/CVBridge","owner":"x0root","description":"OpenCV for android/termux","archived":false,"fork":false,"pushed_at":"2026-06-02T12:10:58.000Z","size":965,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-02T14:10:46.323Z","etag":null,"topics":["android","app","image","image-processing","kotlin","opencv","termux"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/x0root.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-02T09:26:51.000Z","updated_at":"2026-06-02T12:11:02.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/x0root/CVBridge","commit_stats":null,"previous_names":["x0root/cvbridge"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/x0root/CVBridge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x0root%2FCVBridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x0root%2FCVBridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x0root%2FCVBridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x0root%2FCVBridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/x0root","download_url":"https://codeload.github.com/x0root/CVBridge/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x0root%2FCVBridge/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34620358,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-21T02:00:05.568Z","response_time":54,"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":["android","app","image","image-processing","kotlin","opencv","termux"],"created_at":"2026-06-21T18:01:03.327Z","updated_at":"2026-06-21T18:01:04.399Z","avatar_url":"https://github.com/x0root.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CVBridge - Zero-Install Native OpenCV Server\n![CVBridge Banner](https://raw.githubusercontent.com/opencv/opencv/master/doc/pattern.png)\n\n**CVBridge** transforms your Android device into a completely standalone, robust network-based computer vision microservice. Without requiring any complex C++ build tools, Python pip installations, or convoluted toolchains on your client computers, you can simply stream images via REST API directly to your phone, where the native OpenCV engine will instantly process them. It acts as a powerful bridge connecting your terminal (e.g. Termux, bash, python requests) immediately with the world of Computer Vision.\n\n## 🌟 Core Philosophy\nMost developers who want to perform operations like Face Detection or Gaussian blurring either need to setup heavy OpenCV Python environments or compile C++ programs. **CVBridge completely eliminates this overhead.** \nYour phone now serves as a high-speed, local computer vision \"API provider\".\n\n## 🔥 Features Summary\n\n- **⚡ Zero-Install Network Processing:** Features a built-in Netty Ktor server that handles REST requests. Runs efficiently as an **Android Foreground Service** (`dataSync`), meaning you can minimize the app or turn off your screen, and the processing engine will stay alive in the background without getting killed by the OS!\n- **📸 Live Camera Feed with CV Processing:** Switch on your device's camera inside the app's `Live Camera` tab to view real-time filtering (Front \u0026 Back camera supported properly handling mirroring and rotation!). **Test all 30+ native OpenCV operations directly via horizontal scrolling tabs** instantly to find the best algorithms before implementing them over the network.\n- **🌐 Network-to-Screen `imshow` Emulator:** No screen attached to your server? Send standard `POST /imshow` and see the result instantly in the CVBridge API Docs dashboard GUI. \n- **🔗 Instant REST Endpoints to Test:** Hit the processing queue by just invoking basic cURL commands; results are sent back as `.jpeg` binaries!\n- **🤖 Built-in Haar Cascade \u0026 HOG Detections:** The application comes with **OpenCV 4.x engine** (the latest stable native Android distribution), bundled internally for instant offline edge detection, human tracking, and facial tracking. Processing has been highly optimized with automatic internal downsampling to ensure lightning-fast detection times.\n- **📝 Live Network Logging Tab:** See all server interactions, errors, endpoints hit, and detailed diagnostics immediately via the \"Live Logs\" tab inside the app.\n\n---\n\n## 🛠️ API \u0026 Endpoint Reference\n\nAll REST endpoints operate on `HTTP`. The `Network \u0026 Photo` tab inside the Application will display the active IP (e.g. `192.168.x.x:8080`) assigned to your phone. \n\nAll endpoints return standard HTTP codes:\n- **`200 OK`**: Task processed successfully.\n- **`400 Bad Request`**: Received an invalid image, or an invalid task query parameter. \n- **`413 Payload Too Large`**: The image exceeds your set \"Max Image Size\" limit.\n\n### 1. The Main Process Command\n**Endpoint:** `POST /process?task=[TASK_NAME]`\nDirectly transform a raw image and download the results.\n\n**Basic Setup:**\n- `face`, `head`: Haar Cascade Frontal Face Detector.\n- `person`, `human`: HOG People Detector (Standard SVM).\n- `grayscale`, `gray`: Convert color dimensions to Gray.\n- `blur`: Standard Gaussian blurring (`15x15` kernel).\n- `edges`, `canny`: Canny Edge detector matrices.\n\n**Advanced OpenCV Mappings (Native OpenCV 4.x operations):**\nYou can also directly invoke these comprehensive, natively bound OpenCV functions by passing the function name (e.g., `task=resize`, `task=gaussianBlur`). Optional processing parameters can be passed in the URL string.\n\n*Supported Core / Image Processing:*\n- `resize`, `cvtColor`, `flip`, `rotate`, `warpAffine`, `warpPerspective`, `getPerspectiveTransform`, `getRotationMatrix2D`\n- `threshold`, `adaptiveThreshold`, `equalizeHist`, `calcHist`, `inRange`, `split`, `merge`\n- `gaussianBlur`, `medianBlur`, `bilateralFilter`\n- `sobel`, `laplacian`, `scharr`\n- `erode`, `dilate`, `morphologyEx`\n- `findContours`, `drawContours`, `contourArea`, `boundingRect`, `minAreaRect`, `convexHull`, `approxPolyDP`, `matchShapes`\n- `matchTemplate`\n\n*Feature Detection / Primitive Drawing:*\n- `orb`, `sift`, `drawKeypoints`, `qrCode` (detects and draws bounding boxes on QRs)\n- `line`, `rectangle`, `circle`, `putText`, `polylines`, `fillPoly`\n- `bitwise_not`, `bitwise_and`, `bitwise_or`, `bitwise_xor`, `add`, `subtract`\n\n*Example Usage in Bash (or Termux):*\n```bash\n# Apply the Canny Edge Detection and save output.jpg\ncurl -X POST --data-binary @input.jpg \"http://192.168.x.x:8080/process?task=edges\" \u003e output.jpg\n\n# Requesting an invalid task returns an error message:\ncurl -X POST --data-binary @input.jpg \"http://192.168.x.x:8080/process?task=ede\"\n# Returns: Error: Invalid task 'ede'. Supported tasks are: face, person, grayscale, blur, edges\n```\n\n### 2. View Stream Real-Time \"Camera Process\" \n**Endpoint:** `GET /camera/process?task=[TASK_NAME]`\nThis pulls the *current frame* from the live camera stream inside the `Live Camera` tab, applies the computer vision task requested, and returns it.\n*(Note: Requires the Engine to be ON, 'Live Camera' tab must be actively rendering, and camera permissions granted!)*\n\n### 3. Emulate `cv2.imshow()`\n**Endpoint:** `POST /imshow`\nSends bytes through the network and the CVBridge application instantly displays it on its screen. Ideal for remote Python scripts over Wi-Fi!\n\n```python\nimport requests\nwith open('my_plot.png', 'rb') as f:\n    requests.post('http://192.168.x.x:8080/imshow', data=f.read())\n```\n\n---\n\n## ⚙️ Advanced Customizability \u0026 Engine Control\nNavigate to the **Settings** tab within CVBridge to fine-tune operations. These parameters strictly alter the mathematical tracking algorithms used natively by the C++ core:\n\n- **Resolution Max Dimension**: Computer vision requires dense matrix operations. Large images can trigger Out-Of-Memory exceptions or lag. Set this value (e.g., `1024` px) to automatically downscale huge inputs safely *before* OpenCV processing.\n- **Max Image Size Limit**: Keeps the Netty server from crashing by rejecting REST payloads larger than your set limit (e.g. `5` MB). You can define this completely manually or restore defaults.\n  - The API will accurately return a `413 Payload Too Large` error immediately using robust `Content-Length` and stream size validations, saving processing power.\n- **Robust Error Handling**: Any invalid endpoint API tasks (e.g. `task=bur` instead of `blur`) are strictly rejected with a `400 Bad Request` and helpful hints without crashing or locking the server thread.\n\n### Open CV Model Options:\n- **Haar Cascade Scale Factor**: Defines how much the image size is reduced at each image scale. \n  - `1.05`: Slow but extremely thorough (finds smaller faces).\n  - `1.15` (Default): Balance between speed and detection rate.\n  - `1.30`: Very fast, missing smaller faraway faces.\n- **Min Neighbors**: How strict the scanner is when classifying a group of pixels as a 'Face'.\n  - `3`: Typical value. Lower numbers lead to higher false positives. Higher numbers lead to missed faces.\n- **Canny Edge Detection Thresholds (T1 / T2)**: The well-known dual-threshold levels. \n  - Pixels with gradients above `T2` are definitely edges.\n  - Pixels below `T1` are definitely ignored.\n  - Gradients between `T1` and `T2` are considered edges *only if* they connect directly to strong edges. Tuning this clarifies messy/noisy images.\n\n## 🏗️ Technical Stack\n\n- **Primary Language**: Kotlin `1.9.0`\n- **Native CV Module**: OpenCV 4.x compiled native binaries for ARM64 loaded securely via `.so`.\n- **UI Framework**: Modern Jetpack Compose \u0026 Material Design 3.\n- **Server Engine**: Embedded Netty powered by Ktor APIs.\n- **Camera Pipeline**: Jetpack CameraX.\n\n## 👨‍💻 Quick Setup \u0026 Integration\n1. Run the App on Android and accept permissions.\n2. Under \"Network \u0026 Photo\" click **Toggle On** for the **OpenCV Processing Engine**.\n3. Access the IP address shown locally on any computer/device in the same network.\n4. Experiment using the Web Sandbox Dashboard directly on your PC browser!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fx0root%2Fcvbridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fx0root%2Fcvbridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fx0root%2Fcvbridge/lists"}