Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to apply CIFilters on live camera #242

Open
nilisha-simformsolutions opened this issue Feb 12, 2021 · 2 comments
Open

Not able to apply CIFilters on live camera #242

nilisha-simformsolutions opened this issue Feb 12, 2021 · 2 comments

Comments

@nilisha-simformsolutions
Copy link

nilisha-simformsolutions commented Feb 12, 2021

I have tried with this particular code but it freezes the camera when we record a video with fast and slow motion and also there are so many bugs occurs like after record a video filter is applied only on half part of the video and sometimes app crashed.

// enabled by isCustomContextVideoRenderingEnabled
func nextLevel(_ nextLevel: NextLevel, renderToCustomContextWithImageBuffer imageBuffer: CVPixelBuffer, onQueue 
    queue: DispatchQueue) {
        DispatchQueue.main.async {
            nextLevel.videoCustomContextImageBuffer = self.renderWithTransformationWithPixelBuffer(sampleBuffer: imageBuffer)
        }
}
func renderWithTransformationWithPixelBuffer(sampleBuffer: CVPixelBuffer) -> CVPixelBuffer {
        var ciImage = CIImage(cvPixelBuffer: sampleBuffer)
        if let filteredCIImage = filteredCIImage(ciImage) {
            ciImage = filteredCIImage
        }
        let ciContext = nextLevel.session?.ciContext
        ciContext?.render(ciImage, to: sampleBuffer, bounds: ciImage.extent, colorSpace: CGColorSpaceCreateDeviceRGB())
        return sampleBuffer
}

I have referred this - #18

@nilisha-simformsolutions nilisha-simformsolutions changed the title Not able to apply CIFilters Not able to apply CIFilters on live camera Feb 12, 2021
@NirajCapermint
Copy link

@nilisha-simformsolutions did you find any solution?

@patthehuman
Copy link

if you did some research you would probably find this pretty easily:
#18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants