Questions tagged [cvpixelbuffer]
159 questions
26
votes
1 answer
How to convert a UIImage to a CVPixelBuffer
Apple's new CoreML framework has a prediction function that takes a CVPixelBuffer. In order to classify a UIImage a conversion must be made between the two.
Conversion code I got from an Apple Engineer:
1 // image has been defined earlier
2
3 …

Ryan
- 269
- 1
- 3
- 3
19
votes
4 answers
Get pixel value from CVPixelBufferRef in Swift
How can I get the RGB (or any other format) pixel value from a CVPixelBufferRef? Ive tried many approaches but no success yet.
func captureOutput(captureOutput: AVCaptureOutput!,
didOutputSampleBuffer sampleBuffer:…

scord
- 1,375
- 1
- 17
- 34
15
votes
5 answers
Get RGB "CVPixelBuffer" from ARKit
I'm trying to get a CVPixelBuffer in RGB color space from the Apple's ARKit. In func session(_ session: ARSession, didUpdate frame: ARFrame) method of ARSessionDelegate I get an instance of ARFrame. On page Displaying an AR Experience with Metal I…

tomas789
- 1,280
- 1
- 9
- 21
13
votes
2 answers
Unknown underlying OSStatus error -16364 when using AVAssetWriter
I'm building a video export feature for one of my apps. In essence, the video is a series of one of six different images lasting for different (short) durations.
The export works fine when I export something containing 283 images of varying…

Linuxios
- 34,849
- 13
- 91
- 116
11
votes
3 answers
Duplicate / Copy CVPixelBufferRef with CVPixelBufferCreate
I need to create a copy of a CVPixelBufferRef in order to be able to manipulate the original pixel buffer in a bit-wise fashion using the values from the copy. I cannot seem to achieve this with CVPixelBufferCreate, or with…

Maxi Mus
- 795
- 1
- 6
- 20
10
votes
1 answer
Difficulty Writing Pixel Buffer To Asset Writer on Certain Devices
I am working on a function in my app to write images from my sample buffer to an AVAssetWriter. Curiously, this works fine on a 10.5" iPad Pro, but causes a crash on a 7.9" iPad Mini 2. I can't fathom how the same code could be problematic on two…

ZbadhabitZ
- 2,753
- 1
- 25
- 45
10
votes
0 answers
create CMSampleBuffer from CVPixelBuffer
I am provided with pixelbuffer, which I need to attach to rtmpStream object from lf.swift library to stream it to youtube. it looks like this: rtmpStream.appendSampleBuffer(sampleBuffer: CMSampleBuffer, withType: CMSampleBufferType)
So, I need to…

Tornike Kikalishvili
- 190
- 2
- 11
9
votes
4 answers
How do I update a CALayer with a CVPixelBuffer/IOSurface?
I have an IOSurface-backed CVPixelBuffer that is getting updated from an outside source at 30fps. I want to render a preview of the image data in an NSView -- what's the best way for me to do that?
I can directly set the .contents of a CALayer on…

andrew
- 1,173
- 2
- 18
- 28
9
votes
1 answer
Convert ARFrame's captured image to UIImage orientation issue
I want to detect ball and have AR model interact with it. I used opencv for ball detection and send center of ball which I can use in hitTest to get coordinates in sceneView. I have been converting CVPixelBuffer to UIImage using following…

Alok Subedi
- 1,601
- 14
- 26
9
votes
1 answer
Get RAW Bayer pixel data from CVPixelBufferRef
I am using AVCaptureSession & AVCapturePhotoOutput to capture RAW photo data from device's camera in the kCVPixelFormatType_14Bayer_RGGB format.
I have got as far as getting the raw photo sample buffer in the AVCapturePhotoCaptureDelegate…

Matt Colliss
- 1,394
- 1
- 11
- 21
8
votes
3 answers
How can you make a CVPixelBuffer directly from a CIImage instead of a UIImage in Swift?
I am recording filtered video through an iPhone camera, and there is a huge increase in CPU usage when converting a CIImage to a UIImage in real time while recording. My buffer function to make a CVPixelBuffer uses a UIImage, which so far requires…

Chewie The Chorkie
- 4,896
- 9
- 46
- 90
7
votes
1 answer
ScreenCaptureKit/CVPixelBuffer format yields unexpected results
I have a project where I use ScreenCaptureKit. For various reasons out of the scope of the question, the format that I configure ScreenCaptureKit to use is kCVPixelFormatType_32BGRA -- I need the raw BGRA data, which gets manipulated later on.
When…

jnpdx
- 45,847
- 6
- 64
- 94
7
votes
2 answers
Copy a CVPixelBuffer on any iOS device
I'm having a great deal of difficulty coming up with code that reliably copies a CVPixelBuffer on any iOS device. My first attempt worked fine until I tried it on an iPad Pro:
extension CVPixelBuffer {
func deepcopy() -> CVPixelBuffer? {
…

Nestor
- 2,753
- 2
- 29
- 34
7
votes
2 answers
What is plane in a CVPixelbuffer?
In CVPixelBuffer object, have one or many planes. (reference)
We have methods to get number, heigh, the base address of plane.
So what exactly the plane is? And how it constructed inside a CVPixelBuffer?
Sample:

Nhat Dinh
- 3,378
- 4
- 35
- 51
7
votes
1 answer
swift - CGImage to CVPixelBuffer
How can I convert a CGImage to a CVPixelBuffer in swift?
I'm aware of a number of questions trying to do the opposite, and of some objective C answers, like this one but I could not get them to work in swift. Here's the closest I've got:
func…

Guig
- 9,891
- 7
- 64
- 126