cgimage

NSImage to cv::Mat and vice versa

↘锁芯ラ 提交于 2019-11-28 06:04:51
while working with OpenCV I need to convert a NSImage to an OpenCV multi-channel 2D matrix (cvMat) and vice versa. What's the best way to do it? Greets, Dom dom Here's my outcome, which works pretty well. NSImage+OpenCV.h: // // NSImage+OpenCV.h // #import <AppKit/AppKit.h> @interface NSImage (NSImage_OpenCV) { } +(NSImage*)imageWithCVMat:(const cv::Mat&)cvMat; -(id)initWithCVMat:(const cv::Mat&)cvMat; @property(nonatomic, readonly) cv::Mat CVMat; @property(nonatomic, readonly) cv::Mat CVGrayscaleMat; @end NSImage+OpenCV.mm: // // NSImage+OpenCV.mm // #import "NSImage+OpenCV.h" static void

takepicture() vs UIGetScreenImage()

北战南征 提交于 2019-11-28 04:14:29
问题 I'm trying to build a QRCodeReader for a project our research group is working on for the iPhone. After much research I found the program called QuickMark . This program scans automatically for QRCodes. What it appears to do is load the UIImagePicker and read off data from the camera. I suspect it is using UIGetScreenImage and taking a screenshot from the camera and decoding it. Now I tried using the new takepicture() method from the 3.1 iPhone API but that seems not to be able to do what the

CGBitmapContextCreateImage - vm_copy failed - iPhone SDK

不想你离开。 提交于 2019-11-28 03:10:23
问题 I am having an issue using CGBitmapContextCreateImage in my iPhone app. I am using AV Foundation Framework to grab camera frames using this method: - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection { CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); CVPixelBufferLockBaseAddress(imageBuffer,0); uint8_t *baseAddress = (uint8_t *)CVPixelBufferGetBaseAddress

iPhone CGContextRef CGBitmapContextCreate unsupported parameter combination

匆匆过客 提交于 2019-11-27 23:47:18
In my application I need to resize and crop some images, stored locally and online. I am using Trevor Harmon's tutorial which implements UIImage+Resize . On my iPhone 4(iOS 4.3.1) everything works OK, I have no problems. But on my iPhone 3G (iOS 3.2) the resizing and crop methods are not working for any picture (the locally stored ones are PNGs). This is the console output: Tue Apr 5 02:34:44 Andreis-MacBook-Pro.local Puzzle[12453] <Error>: CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 32 bits/pixel; 3-component color space; kCGImageAlphaLast; 288 bytes

Getting a CGImage from CIImage

爷,独闯天下 提交于 2019-11-27 23:09:41
问题 I have a UIImage which is loaded from a CIImage with: tempImage = [UIImage imageWithCIImage:ciImage]; The problem is I need to crop tempImage to a specific CGRect and the only way I know how to do this is by using CGImage . The problem is that in the iOS 6.0 documentation I found this: CGImage If the UIImage object was initialized using a CIImage object, the value of the property is NULL. A. How to convert from CIImage to CGImage? I'm using this code but I have a memory leak (and can't

Get pixel data as array from UIImage/CGImage in swift

狂风中的少年 提交于 2019-11-27 21:16:53
I have an app so far that allows the user to free draw (like a sketch pad) on a UIImageView element. I want to get the raw RGB pixel data (as 0 to 255 integer values) as a multidimensional array so I can feed it into a machine learning algorithm . Or is there some other way I can send the raw image data over to separate C++ function? Is there an easy way to do this in Swift? Converting a CGImage to an array of intensity values My function takes a CGImage and returns an array of unsigned 8-bit integers as well as the width and height of the image. I wrote this code for use with grayscale images

Should I use UIImage or CGImage in a Swift iOS App?

情到浓时终转凉″ 提交于 2019-11-27 16:30:05
问题 All the code I can find revolves around loading images directly into visual controls. However, I have my own cache system (converting a project from another language) and so I as efficient as possible want the following: Load jpg/png images - probably into a bitmap / cgimage. (his can either be from the file system or from images downloaded online) Possibly save image back as a compressed/resized png/jpg file Supply an image reference for a visual control I am new to swift and ios platform,

How exactly to make a CGImageRef from an image on disk

浪尽此生 提交于 2019-11-27 12:35:11
问题 I've looked around everywhere to no avail. I'm doing some image loading in a thread and since UIKit is not thread safe I'm going to have to store the images as CGImageRefs but I can't figure out how to do this. I haven't played with any of the Quartz stuff before so it's confusing me. Basically I just need to load a JPG from the disk into a CGImageRef. Also for bonus points, is there anyway to load a GIF into a CGImageRef? 回答1: gcamp is more or less correct, you are pretty safe to use this on

iPhone: Changing CGImageAlphaInfo of CGImage

﹥>﹥吖頭↗ 提交于 2019-11-27 10:21:43
问题 I have a PNG image that has an unsupported bitmap graphics context pixel format. Whenever I attempt to resize the image, CGBitmapContextCreate() chokes on the unsupported format I receive the following error (error formatted for easy reading): CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 32 bits/pixel; 3-component colorspace; kCGImageAlphaLast; 1344 bytes/row. The list of supported pixel formats definitely does not support this combination. It appears I

How to merge the perspective image(3D Transform)?

天大地大妈咪最大 提交于 2019-11-27 08:48:33
问题 How to merge these two images(see attached image).I am using the below code. Its working for ordinary images not for 3D transform images. How to handle this issue. I have searched lot of times still not getting the proper result. Please help me. Thanks in advance. UIImage *mergedImage; UIGraphicsBeginImageContext(backgroundImageView.frame.size); [backgroundImageView.layer renderInContext:UIGraphicsGetCurrentContext()]; //bacgroundImageView here mergedImage =