ios - Generate mipmaped MTLTextures from AVFoundation camera stream -
I'm using AVFoundation to get the camera stream. I am using this code to get MTLTextures: Capture Capture (AVCaptureOutput *) capture Capture output: Sample buffer: (CMSampleBufferRef) connection to sampleBuffer: (AVCaptureConnection *) Connection {CVPixelBufferRef pixel buffer = CMSampleBufferGetImageBuffer (sampleBuffer); In the & lt; MTLTexture & gt; Texture = zero; {Size_t width = CVPixelBufferGetWidth (PixelBuffer); Size_t height = cvpxbuffergatehite (pixelbuffer); MTLPixelFormat Pixel Format = MTLPixelFormatBGRA8Unorm; CVMetalTextureRef MetalTextRep = Faucet; CVReturn POS = CVMetalTextureCacheCreateTextureFromImage (Zero, _textureCache, PixelBuffer, Zero, Pixel Format, Width, Height, 0, and Metal RFF); If (position == kCVReturnSuccess) {texture = CVMetalTextxtureGetTtexture (Metals Reflected); If (self.regulate) {[self-made texture: texture]; } CFRlim (Metal Tatifier); }}
This works fine, except that the generated MTLtetexture is not a single object (only a map level). In this call:
CVMetalTestructureCacheCreateTextureFromImage (zero, _accept cache, pixel buffer, faucet, pixel format, width, height, 0, and metallication);
"There is a third parameter called texture content , I think it is possible to specify that I need a duplicate texture , But I did not find any words in the documentation what the heaven actually goes there. Neither I had received a source code in which something was passed rather than zero.
For Open IOS , the same method is with the same parameter, and there is no word in the documentation too.
There is no method to directly obtain a wrapmet text, but you can easily Can generate from
First use your metal tool to make your metal texture, which is the same size and format as your existing texture, but there is a full mipmap series in it.
Use your MTLCommandBuffer object to create a blitEncoder object.
Use the bluetooth encoder to copy from your camera texture to your empty texture. Destination level should be zero because you are only copying top level mimmaps.
Generate Blit Encoder to finally generate all Mix Levels by callingmaxmaxfonts.
At the end of this you have a metal texture perfectly with the camera chain from the camera.
Comments
Post a Comment