Last active
July 25, 2017 22:08
-
-
Save EgorBo/619acd9ce44caff01eb8c2c9c3970f2e to your computer and use it in GitHub Desktop.
CVPixelBuffer issue.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// called 60 times per second (60fps) | |
unsafe void DisplayBackground(CVPixelBuffer capturedImage) | |
{ | |
capturedImage.Lock(CVPixelBufferLock.None); | |
var baseAddress = capturedImage.BaseAddress; | |
var format = capturedImage.PixelFormatType; //CV420YpCbCr8BiPlanarFullRange | |
var width = (int)capturedImage.Width; //1280 | |
var height = (int)capturedImage.Height; //720 | |
cameraTexture.SetData(0, 0, 0, width, height, (void*)baseAddress); | |
capturedImage.Unlock(CVPixelBufferLock.None); | |
//Workaround #1: | |
//CVPixelBufferRelease(capturedImage.Handle); | |
//GC.SuppressFinalize(capturedImage); | |
//Workaround #2: | |
GC.Collect(); | |
} | |
[DllImport("/System/Library/Frameworks/CoreVideo.framework/CoreVideo")] | |
private static extern void CVPixelBufferRelease(IntPtr handle); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment