Skip to content

Add Mat data pointer bridging method for Objective-C/Swift#18566

Merged
opencv-pushbot merged 1 commit intoopencv:masterfrom
mtfrctl:mat-objc-swift-data-pointer
Oct 14, 2020
Merged

Add Mat data pointer bridging method for Objective-C/Swift#18566
opencv-pushbot merged 1 commit intoopencv:masterfrom
mtfrctl:mat-objc-swift-data-pointer

Conversation

@mtfrctl
Copy link
Copy Markdown
Contributor

@mtfrctl mtfrctl commented Oct 11, 2020

Added because there was no method to get Mat data directly in Objective-C or Swift.

Usage example in Swift:

let mat = Mat.zeros(Size(width: 256, height: 256), type: CvType.CV_8UC4)
let dataPointer = mat.dataPointer() // <- UnsafeMutablePointer<UInt8>
let data = Data(bytes: dataPointer, count: bytesPerPixel * pixels)

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
force_builders=Custom Mac
build_image:Custom Mac=osx_framework

buildworker:iOS=macosx-1

@mtfrctl mtfrctl mentioned this pull request Oct 11, 2020
4 tasks
Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you 👍

@opencv-pushbot opencv-pushbot merged commit 57c894f into opencv:master Oct 14, 2020
@mtfrctl mtfrctl deleted the mat-objc-swift-data-pointer branch October 15, 2020 06:15
@alalek alalek mentioned this pull request Nov 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants