{"id":21373772,"url":"https://github.com/yeatse/opencv-spm","last_synced_at":"2025-12-11T22:55:43.560Z","repository":{"id":135967488,"uuid":"540080014","full_name":"yeatse/opencv-spm","owner":"yeatse","description":"Integrate OpenCV into your project using Swift Package Manager.","archived":false,"fork":false,"pushed_at":"2025-07-23T10:43:13.000Z","size":208,"stargazers_count":132,"open_issues_count":4,"forks_count":31,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-10-21T10:11:28.743Z","etag":null,"topics":["ios","macos","opencv","swift","swift-package-manager","visionos"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yeatse.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":"2022-09-22T16:51:46.000Z","updated_at":"2025-09-23T08:32:50.000Z","dependencies_parsed_at":"2023-12-29T04:27:31.151Z","dependency_job_id":"a16be149-2de7-4906-b7f4-b51c37aa1fc5","html_url":"https://github.com/yeatse/opencv-spm","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/yeatse/opencv-spm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeatse%2Fopencv-spm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeatse%2Fopencv-spm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeatse%2Fopencv-spm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeatse%2Fopencv-spm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yeatse","download_url":"https://codeload.github.com/yeatse/opencv-spm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeatse%2Fopencv-spm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27672063,"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-12-11T02:00:11.302Z","response_time":56,"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":["ios","macos","opencv","swift","swift-package-manager","visionos"],"created_at":"2024-11-22T08:29:30.704Z","updated_at":"2025-12-11T22:55:43.518Z","avatar_url":"https://github.com/yeatse.png","language":"Swift","funding_links":[],"categories":["OOM-Leaks-Crash"],"sub_categories":["Graphs Processing And Rendering"],"readme":"# OpenCV-SPM\n\nUse [OpenCV](https://github.com/opencv/opencv) in your Swift project in a more elegant way.\n\nThis Swift package simplifies the process of importing the prebuilt `opencv2.xcframework` into your project, eliminating the need for manual building. It monitors release events in the [OpenCV Github Project](https://github.com/opencv/opencv) and automatically generates new releases using [Github Actions](https://github.com/features/actions).\n\n## Installation\n\nAdd `https://github.com/yeatse/opencv-spm.git` to your package dependencies\n\n![add dependency](screenshots/add%20dependency.png)\n\n## Usage\n\nImport `opencv2` and use it as documented in [opencv.org](opencv.org). For example, a swift version of [Extract horizontal and vertical lines by using morphological operations](https://docs.opencv.org/4.6.0/dd/dd7/tutorial_morph_lines_detection.html):\n\n```swift\nimport opencv2\n\n// Show source image\nlet src = Mat(uiImage: image)\n\n// Transform source image to gray if it is not already\nlet gray: Mat\nif (src.channels() == 3) {\n    gray = Mat()\n    Imgproc.cvtColor(src: src, dst: gray, code: .COLOR_BGR2GRAY)\n} else {\n    gray = src\n}\n\n// Apply adaptiveThreshold at the bitwise_not of gray, notice the ~ symbol\nlet notGray = Mat()\nCore.bitwise_not(src: gray, dst: notGray)\n\nlet bw = Mat()\nImgproc.adaptiveThreshold(src: notGray, dst: bw, maxValue: 255, adaptiveMethod: .ADAPTIVE_THRESH_MEAN_C, thresholdType: .THRESH_BINARY, blockSize: 15, C: -2)\n\n// Create the images that will use to extract the horizontal lines\nlet horizontal = bw.clone()\nlet vertical = bw.clone()\n\n// Specify size on horizontal axis\nlet horizontalSize = horizontal.cols() / 30\n// Create structure element for extracting horizontal lines through morphology operations\nlet horizontalStructure = Imgproc.getStructuringElement(shape: .MORPH_RECT, ksize: .init(width: horizontalSize, height: 1))\n// Apply morphology operations\nImgproc.erode(src: horizontal, dst: horizontal, kernel: horizontalStructure, anchor: .init(x: -1, y: -1))\nImgproc.dilate(src: horizontal, dst: horizontal, kernel: horizontalStructure, anchor: .init(x: -1, y: -1))\n\n// Specify size on vertical axis\nlet verticalSize = vertical.rows() / 30\n\n// Create structure element for extracting vertical lines through morphology operations\nlet verticalStructure = Imgproc.getStructuringElement(shape: .MORPH_RECT, ksize: .init(width: 1, height: verticalSize))\n\n// Apply morphology operations\nImgproc.erode(src: vertical, dst: vertical, kernel: verticalStructure, anchor: .init(x: -1, y: -1))\nImgproc.dilate(src: vertical, dst: vertical, kernel: verticalStructure, anchor: .init(x: -1, y: -1))\n\n// Inverse vertical image\nCore.bitwise_not(src: vertical, dst: vertical)\n\n// Extract edges and smooth image according to the logic\n// 1. extract edges\n// 2. dilate(edges)\n// 3. src.copyTo(smooth)\n// 4. blur smooth img\n// 5. smooth.copyTo(src, edges)\n// Step 1\nlet edges = Mat();\nImgproc.adaptiveThreshold(src: vertical, dst: edges, maxValue: 255, adaptiveMethod: .ADAPTIVE_THRESH_MEAN_C, thresholdType: .THRESH_BINARY, blockSize: 3, C: -2)\n\n// Step 2\nlet kernel = Mat.ones(rows: 2, cols: 2, type: CvType.CV_8UC1)\nImgproc.dilate(src: edges, dst: edges, kernel: kernel)\n\n// Step 3\nlet smooth = Mat();\nvertical.copy(to: smooth)\n\n// Step 4\nImgproc.blur(src: smooth, dst: smooth, ksize: .init(width: 2, height: 2))\n\n// Step 5\nsmooth.copy(to: vertical, mask: edges)\n\n// Show final result\nlet result = vertical.toUIImage()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyeatse%2Fopencv-spm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyeatse%2Fopencv-spm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyeatse%2Fopencv-spm/lists"}