mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +04:00
Swift native in/out array handling
This commit is contained in:
@@ -12,6 +12,11 @@ public extension ByteVector {
|
||||
self.init(data:data);
|
||||
}
|
||||
|
||||
convenience init(_ array:[UInt8]) {
|
||||
let data = array.withUnsafeBufferPointer { Data(buffer: $0) }
|
||||
self.init(data:data);
|
||||
}
|
||||
|
||||
subscript(index: Int) -> Int8 {
|
||||
get {
|
||||
return self.get(index)
|
||||
@@ -25,6 +30,14 @@ public extension ByteVector {
|
||||
return ret
|
||||
}
|
||||
}
|
||||
|
||||
var unsignedArray: [UInt8] {
|
||||
get {
|
||||
var ret = Array<UInt8>(repeating: 0, count: data.count/MemoryLayout<UInt8>.stride)
|
||||
_ = ret.withUnsafeMutableBytes { data.copyBytes(to: $0) }
|
||||
return ret
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension ByteVector : Sequence {
|
||||
|
||||
Reference in New Issue
Block a user