cifilter

CoreImage coordinate system

╄→гoц情女王★ 提交于 2020-08-04 10:53:12
问题 I have CVPixelBufferRef from an AVAsset . I'm trying to apply a CIFilter to it. I use these lines: CVPixelBufferRef pixelBuffer = ... CVPixelBufferRef newPixelBuffer = // empty pixel buffer to fill CIContex *context = // CIContext created from EAGLContext CGAffineTransform preferredTransform = // AVAsset track preferred transform CIImage *phase1 = [CIImage imageWithCVPixelBuffer:pixelBuffer]; CIImage *phase2 = [phase1 imageByApplyingTransform:preferredTransform]; CIImage *phase3 = [self

CoreImage coordinate system

微笑、不失礼 提交于 2020-08-04 10:53:04
问题 I have CVPixelBufferRef from an AVAsset . I'm trying to apply a CIFilter to it. I use these lines: CVPixelBufferRef pixelBuffer = ... CVPixelBufferRef newPixelBuffer = // empty pixel buffer to fill CIContex *context = // CIContext created from EAGLContext CGAffineTransform preferredTransform = // AVAsset track preferred transform CIImage *phase1 = [CIImage imageWithCVPixelBuffer:pixelBuffer]; CIImage *phase2 = [phase1 imageByApplyingTransform:preferredTransform]; CIImage *phase3 = [self

How to not cause dark gray color to be transparent removing background from image

好久不见. 提交于 2020-04-13 17:10:11
问题 I'm having an issue where when I try to remove the green from an image (in this case the image background) but all the dark grays (within the part of the image I want to keep) become semi-transparent. I am unsure why, would like some advice on how to: func chromaKeyFilter(fromHue: CGFloat, toHue: CGFloat) -> CIFilter? { let size = 64 var cubeRGB = [Float]() for z in 0 ..< size { let blue = CGFloat(z) / CGFloat(size-1) for y in 0 ..< size { let green = CGFloat(y) / CGFloat(size-1) for x in 0 .

rotate CIImage around center with CIFilter

别说谁变了你拦得住时间么 提交于 2020-03-28 04:15:13
问题 I'm trying to rotate the pixel data of a CMSampleBuffer (coming from the camera) and display it in a UIImageView. I Don't want to rotate the view itself. It has to be the actual pixel data. I grab the feed, convert it to a CIImage and with a CIFilter I rotate it. I'm having trouble with setting the point around which it has to rotate. Right now it rotates around the lower left point. I want to rotate it around its center. func captureOutput(_ captureOutput: AVCaptureOutput!,

Metal: vertexFunction defined in .metal file becomes nil once setting Compiler and Linker Options for MSL cikernel

亡梦爱人 提交于 2020-02-23 07:14:48
问题 VertexFunction and FragmentFunction defined in .metal file worked nicely, but they became nil once I specified Compiler and Linker Options following Apple's doc: -fcikernel flag in the Other Metal Compiler Flags option, and -cikernel flat in MTLLINKER_FLAGS in User-Defined setting. I need the settings above for cikernel with MSL (metal shading language). Indeed, cikernel with Core Image Kernel Language deprecated in 12.0. How could I use both vertex/fragment Metal shader and MSL cikernel

How-to generate a QR code with the logo in the middle using CIQRCodeGenerator

本秂侑毒 提交于 2020-01-22 19:40:45
问题 I am trying to generate a QR code that has a logo in the middle, as it is: . I am using a code I found here, my code is: func generateQrCode(message: String!) -> CIImage! { var data = message.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false) var filter: CIFilter = CIFilter(name: "CIQRCodeGenerator") filter.setValue(data, forKey: "inputMessage") filter.setValue("H", forKey: "inputCorrectionLevel") return filter.outputImage } How could adapt the code to generate a QR with a

How-to generate a QR code with the logo in the middle using CIQRCodeGenerator

孤者浪人 提交于 2020-01-22 19:40:30
问题 I am trying to generate a QR code that has a logo in the middle, as it is: . I am using a code I found here, my code is: func generateQrCode(message: String!) -> CIImage! { var data = message.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false) var filter: CIFilter = CIFilter(name: "CIQRCodeGenerator") filter.setValue(data, forKey: "inputMessage") filter.setValue("H", forKey: "inputCorrectionLevel") return filter.outputImage } How could adapt the code to generate a QR with a

Reset button to original image from filtered image

ぐ巨炮叔叔 提交于 2020-01-06 14:45:44
问题 I tried to add filters to my image in image view, when i tried to click on filter buttons they are stacking. Can you help me to create a reset or undo button to go to original image with iam getting original image from camera and camera roll? (IBAction)filter:(id)sender { CIContext *context=[CIContext contextWithOptions:nil]; CIImage *image =[CIImage imageWithCGImage:imageview.image.CGImage]; CIFilter *filter =[CIFilter filterWithName:@"CISepiaTone"]; [filter setValue:image forKey

Colorize a UIImage in Swift

做~自己de王妃 提交于 2020-01-06 06:42:16
问题 I am trying to write an helper function that applies a color mask to a given image. My function has to set all opaque pixels of an image to the same color. Here is what I have so far : extension UIImage { func applyColorMask(color: UIColor, context: CIContext) -> UIImage { guard let cgImageInput = self.cgImage else { print("applyColorMask: \(self) has no cgImage attribute.") return self } // Throw away existing colors, and fill the non transparent pixels with the input color // s.r = dot(s,

Metal Custom CIFilter different return value

你离开我真会死。 提交于 2020-01-02 08:15:21
问题 I'm writing CIFilter, but result pixel colors are different than returned values from metal function. kernel.metal #include <CoreImage/CoreImage.h> extern "C" { namespace coreimage { float4 foo(sample_t rgb){ return float4(0.3f, 0.5f, 0.7f, 1.0f); } } MetalFilter.swift import CoreImage class MetalFilter: CIFilter { private let kernel: CIColorKernel var inputImage: CIImage? override init() { let url = Bundle.main.url(forResource: "default", withExtension: "metallib")! let data = try! Data