Core Image: From CIImage to Metal and Beyond · Access the Camera with AVFoundation | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5428948-core-image-from-ciimage-to-metal-and-beyond/lessons/16

hello sam, thanks for the very good explanation of CIIMage
i’m new to ios and started from here with swiftUI, now i wan to implement this in swiftui, how can i get this done with swiftUI, i mean i could achieve it with images, but in case of video, i got stuck, i would appreciate it if you could direct me in the right way.
thanks.

Hi @mostafas

Apologies for the delay in my reply. I’m not an expert in SwiftUI, so I could be wrong, but I don’t think there is “native-SwiftUI” support for videos yet. However, SwiftUI has facility to integrate UIKit views, so you could look at wrapping AVPlayerViewController or an AVPlayerLayer directly.

I expect that that functionality of SwiftUI will improve over future releases, but until then we’ll have to use UIKit directly for some use cases.

Hope that helps

sam

Where exactly Sam did you implement the rosy pink metal filter within the video feed. Really having a hardtime trying to find it

Hi @kekquistador,

I’m not entirely sure what you mean by “rosy pink metal filter”. Is this something referred to in this video? Can you send me a screenshot or a timecode?

Hopefully I’ll be able to point you in the right direction with a little more info.

Thanks

sam

Sorry, lol was accidentally referring to your room color in film. It looked like it was shaded pink and the Apple tutorial for Metalkit involves a pink shader.

Is it possible to do livestreaming with a custom metal based filter?

when I try using your methods I usually get just a white screen

=)

I have never tried live streaming a video that has been through a metal filter, but I think it must be possible. I think you could probably set up your AVFoundation pipeline to include filtering?

Sorry I can’t be of more help…

sam

thats what Im doing now. Ive started the Metals pdf book from your website in an attempt to get a faster working video filters. Is it possible to use metal filters for video filtering?

thank you

Yes!

If you combine the knowledge from:

https://www.raywenderlich.com/5428948-core-image-from-ciimage-to-metal-and-beyond/lessons/11

and

https://www.raywenderlich.com/5428948-core-image-from-ciimage-to-metal-and-beyond/lessons/16

Then you absolutely can use a custom Metal Core Image filter inside the video processing pipeline.

Good luck!

sam

yay i’ll try that
the metal book gives a very good introduction to everything that needs to be included

Screen Shot 2020-05-16 at 6.12.09 PM ![Screen Shot 2020-05-16 at 6.11.33 PM|601x500]

Hey, here is what I got from combining those 2 lessons.
I did put in the 2 custom buildsettings revolving around -fcikernel.

I am not sure, but I always get a blank white screen on my older ipad and the debugging tells me compiler was not able to create the Passthrough kernel from the Metal file.

Should I show you any more screenshots if possible?

I think it’s worth focusing on why the kernel is not compiling. I’m sorry, I don’t have a great memory, so am not sure whether there is anything additional that needs doing to get it to compile.

Did you manage to compile the pass-through kernel with the sample project downloaded from here?

sam

I believe so, but that is with a picture and not the streaming. I am wondering if i have to add something or create something towards the commandque

I have only been using the passthrough kernel on the project as a test

Could there be other procedures Core Image filters go through. I noticed ther eis a CIsampler NSO object

I’m sorry @kekquistador—I don’t have any experience of this, so can’t really offer any significant help. I don’t know what to suggest that you haven’t already tried.

I hope you manage to get to the bottom of it—good luck!

sam

Im working on it. I’ll keep you posted

@kekquistador Do you still have issues with this?