ciimage

How to draw text into CIImage?

牧云@^-^@ 提交于 2020-01-06 06:52:13
问题 How to draw into CIImage (or maybe into CVPixelBuffer , but I guess it easier to add text to CIImage )? not to UIImage I record video (.mp4 file) using AVAssetWriter and CMSampleBuffer (from video, audio inputs). While recording I want to add text on the video frames, I'm already converting CMSampleBuffer to CIImage , now I need somehow add text to CIImage and convert back to CVPixelBuffer . I didn't really find any simple examples in Swift how to add (draw) text to CIImage or add anything

Rotate UIImage and Move

这一生的挚爱 提交于 2020-01-06 03:18:07
问题 I have searched stack overflow too many times and also posted a question but in vain. I need to implement a function in my collage app where user can rotate a uiimage and move it as rotated image. Any idea of how to do it? I will try all of them if needed. Am being frustrated searching for it for last two days. At first i have rotated the frame of the UIImage using CGAffineTransformMakeRotation(angle). It was working but when moving the image after rotation, it was creating distortion. So any

How to convert from YUV to CIImage for iOS

☆樱花仙子☆ 提交于 2019-12-30 03:34:10
问题 I am trying to convert a YUV image to CIIMage and ultimately UIImage. I am fairly novice at these and trying to figure out an easy way to do it. From what I have learnt, from iOS6 YUV can be directly used to create CIImage but as I am trying to create it the CIImage is only holding a nil value. My code is like this -> NSLog(@"Started DrawVideoFrame\n"); CVPixelBufferRef pixelBuffer = NULL; CVReturn ret = CVPixelBufferCreateWithBytes( kCFAllocatorDefault, iWidth, iHeight, kCVPixelFormatType

Creating a blur effect in iOS7

a 夏天 提交于 2019-12-28 03:30:29
问题 I have been searching for an answer to this question in a few hours now, and I just can't figure it out. I want to add a gaussian blur effect to the image when i press the button "Button". The user is the one that is adding the image. I have created an action for the "Button" based on sources from SO and other places on the web. It will not work. What am I doing wrong? Any code would be greatly appreciated. Here is my "Button" action: - (IBAction)test:(id)sender { CIFilter *gaussianBlurFilter

Objective-C : No Matter what I do CIDetector is always nil

孤人 提交于 2019-12-22 14:04:15
问题 Trying to get a simple Proof of concept going with Apple's face detection API. I've looked at a couple of other examples including Apple's SquareCam, and this one https://github.com/jeroentrappers/FaceDetectionPOC based on these, it seems like I am following the correct pattern to get the APIs going, but I am stuck. No matter what I do, the CIDetector for my face detector is always nil!!! I would seriously appreciate any help, clues - hints - suggestions! -(void)initCamera{ session = [

Image rotating after CIFilter

白昼怎懂夜的黑 提交于 2019-12-22 10:44:58
问题 I'm applying a CIFilter to a portrait image. For some reason, it gets rotated 90 clockwise. How can I fix this? My code is below var imgOrientation = oImage.imageOrientation var imgScale = oImage.scale let originalImage = CIImage(image: oImage) var filter = CIFilter(name: "CIPhotoEffect"+arr[sender.tag-1000]) filter.setDefaults() filter.setValue(originalImage, forKey: kCIInputImageKey) var outputImage = filter.outputImage var newImage = UIImage(CIImage:outputImage, scale:imgScale, orientation

Creating transparent gradient and use it as an alpha-mask in SpriteKit

自古美人都是妖i 提交于 2019-12-21 19:30:10
问题 I am trying to make a gradient and use it as an alpha mask. Right now, I am able to make an image similar to this (from black to transparent): This is the code which I use to make all this: private func createImage(width: CGFloat, height: CGFloat) -> CGImageRef?{ if let ciFilter = CIFilter(name: "CILinearGradient"){ let ciContext = CIContext() ciFilter.setDefaults() let startColor = CIColor(red: 0, green: 0, blue: 0, alpha: 0) let endColor = CIColor(red: 0, green: 0, blue: 0, alpha: 1) let

Creating transparent gradient and use it as an alpha-mask in SpriteKit

不羁的心 提交于 2019-12-21 19:30:06
问题 I am trying to make a gradient and use it as an alpha mask. Right now, I am able to make an image similar to this (from black to transparent): This is the code which I use to make all this: private func createImage(width: CGFloat, height: CGFloat) -> CGImageRef?{ if let ciFilter = CIFilter(name: "CILinearGradient"){ let ciContext = CIContext() ciFilter.setDefaults() let startColor = CIColor(red: 0, green: 0, blue: 0, alpha: 0) let endColor = CIColor(red: 0, green: 0, blue: 0, alpha: 1) let

How to output a CIFilter to a Camera view?

若如初见. 提交于 2019-12-20 14:44:49
问题 I'm just starting out in Objective-C and I'm trying to create a simple app where it shows the camera view with a blur effect on it. I got the Camera output working with the AVFoundation framework. Now, I'm trying to hook up the Core image framework but to no knowledge how to, Apple documentation is confusing for me and searching for guides and tutorials online leads to no results. Thanks in advance for the help. #import "ViewController.h" #import <AVFoundation/AVFoundation.h> @interface

How to blur an existing image in a UIImageView with Swift?

风流意气都作罢 提交于 2019-12-18 11:47:45
问题 The setup is simple. A ViewController with UIImageView that has an image assigned. A UIButton that when clicked blurs the image in the UIImageView. import UIKit class ViewController: UIViewController { @IBOutlet weak var bg: UIImageView! @IBAction func blur(_ sender: Any) { let inputImage = CIImage(cgImage: (bg.image?.cgImage)!) let filter = CIFilter(name: "CIGaussianBlur") filter?.setValue(inputImage, forKey: "inputImage") filter?.setValue(10, forKey: "inputRadius") let blurred = filter?