cvpixelbuffer

Duplicate / Copy CVPixelBufferRef with CVPixelBufferCreate

和自甴很熟 提交于 2019-12-22 07:58:16
问题 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 CVPixelBufferCreateWithBytes . According to this question, it could possibly also be done with memcpy(). However, there is no explanation on how this would be achieved, and which Core Video library calls would be needed regardless. 回答1: This seems to work: - (void

Duplicate / Copy CVPixelBufferRef with CVPixelBufferCreate

江枫思渺然 提交于 2019-12-22 07:58:06
问题 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 CVPixelBufferCreateWithBytes . According to this question, it could possibly also be done with memcpy(). However, there is no explanation on how this would be achieved, and which Core Video library calls would be needed regardless. 回答1: This seems to work: - (void

DepthData - Get per-pixel depth data (CVPixelBuffer data analysis)

血红的双手。 提交于 2019-12-11 00:19:00
问题 Now I run AVDepthPhotoFilter that Rendering Depth Deta from a stereo camera of iPhone7Plus. So, I want to access per-pixel depth data, but, I don’t know how to do it. Please advice. 回答1: How to get DepthData and analysis CVPixelBuffer data You need to make sure your AVCapturePhotoSettings() has isDepthDataDeliveryEnabled = true You have to use the function func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?) func photoOutput(_ output:

Why won't AVFoundation accept my planar pixel buffers on an iOS device?

我的未来我决定 提交于 2019-12-10 19:42:51
问题 I've been struggling to figure out what the problem is with my code. I'm creating a planar CVPixelBufferRef to write to an AVAssetWriter . This pixel buffer is created manually through some other process (i.e., I'm not getting these samples from the camera or anything like that). On the iOS Simulator, it has no problem appending the samples and creating a valid output movie. But on the device, it immediately fails at the first sample and provides less than useless error information:

Duplicate / Copy CVPixelBufferRef with CVPixelBufferCreate

北慕城南 提交于 2019-12-05 19:04:22
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 CVPixelBufferCreateWithBytes . According to this question , it could possibly also be done with memcpy(). However, there is no explanation on how this would be achieved, and which Core Video library calls would be needed regardless. This seems to work: - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer

How to convert a UIImage to a CVPixelBuffer [duplicate]

帅比萌擦擦* 提交于 2019-12-03 05:51:00
问题 This question already has answers here : Convert Image to CVPixelBuffer for Machine Learning Swift (3 answers) Closed 2 years ago . 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 var pixelbuffer: CVPixelBuffer? = nil 4 5 CVPixelBufferCreate(kCFAllocatorDefault, Int(image.size.width), Int(image.size

Reliable access and modify captured camera frames under SceneKit

六月ゝ 毕业季﹏ 提交于 2019-11-29 08:21:28
I try to add a B&W filter to the camera images of an ARSCNView, then render colored AR objects over it. I'am almost there with the following code added to the beginning of - (void)renderer:(id<SCNSceneRenderer>)aRenderer updateAtTime:(NSTimeInterval)time CVPixelBufferRef bg=self.sceneView.session.currentFrame.capturedImage; if(bg){ char* k1 = CVPixelBufferGetBaseAddressOfPlane(bg, 1); if(k1){ size_t x1 = CVPixelBufferGetWidthOfPlane(bg, 1); size_t y1 = CVPixelBufferGetHeightOfPlane(bg, 1); memset(k1, 128, x1*y1*2); } } This works really fast on mobile, but here's the thing: sometimes a colored

Reliable access and modify captured camera frames under SceneKit

二次信任 提交于 2019-11-28 01:42:58
问题 I try to add a B&W filter to the camera images of an ARSCNView, then render colored AR objects over it. I'am almost there with the following code added to the beginning of - (void)renderer:(id<SCNSceneRenderer>)aRenderer updateAtTime:(NSTimeInterval)time CVPixelBufferRef bg=self.sceneView.session.currentFrame.capturedImage; if(bg){ char* k1 = CVPixelBufferGetBaseAddressOfPlane(bg, 1); if(k1){ size_t x1 = CVPixelBufferGetWidthOfPlane(bg, 1); size_t y1 = CVPixelBufferGetHeightOfPlane(bg, 1);

Get pixel value from CVPixelBufferRef in Swift

依然范特西╮ 提交于 2019-11-27 22:14:34
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: CMSampleBuffer!, fromConnection connection: AVCaptureConnection!) { let pixelBuffer: CVPixelBufferRef = CMSampleBufferGetImageBuffer(sampleBuffer)! CVPixelBufferLockBaseAddress(pixelBuffer, 0) let baseAddress = CVPixelBufferGetBaseAddress(pixelBuffer) //Get individual pixel values here CVPixelBufferUnlockBaseAddress(pixelBuffer, 0) } baseAddress is an unsafe mutable pointer or more

Get pixel value from CVPixelBufferRef in Swift

陌路散爱 提交于 2019-11-26 20:57:06
问题 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: CMSampleBuffer!, fromConnection connection: AVCaptureConnection!) { let pixelBuffer: CVPixelBufferRef = CMSampleBufferGetImageBuffer(sampleBuffer)! CVPixelBufferLockBaseAddress(pixelBuffer, 0) let baseAddress = CVPixelBufferGetBaseAddress(pixelBuffer) //Get individual pixel values