This repository has been archived by the owner on Apr 18, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a87b538
Showing
69 changed files
with
56,189 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Webcam/FaceTracking/Custom Views example project - jamesghurley<at>gmail.com | ||
* This project emulates 1-on-1 video conferencing using modern Cocoa frameworks and techniques. | ||
* | ||
* CGImageWrapper.h/.m - Used to pass a CGImageRef to the main thread. | ||
*/ | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
|
||
@interface CGImageWrapper : NSObject { | ||
@public | ||
CGImageRef image; | ||
} | ||
@property CGImageRef image; | ||
|
||
-(id) initWithCGImage: (CGImageRef) _image; | ||
-(id) initWithCVImageBufferRef: (CVImageBufferRef) _imageBuffer; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Webcam/FaceTracking/Custom Views example project - jamesghurley<at>gmail.com | ||
* This project emulates 1-on-1 video conferencing using modern Cocoa frameworks and techniques. | ||
* | ||
* CGImageWrapper.h/.m - Used to pass a CGImageRef to the main thread. | ||
*/ | ||
#import "CGImageWrapper.h" | ||
#import <CoreVideo/CoreVideo.h> | ||
|
||
|
||
@implementation CGImageWrapper | ||
@synthesize image; | ||
// ----------------------------------------------------------------------------- | ||
- (id) initWithCGImage:(CGImageRef)_image{ | ||
if((self = [super init])){ | ||
image = _image; | ||
} | ||
return self; | ||
} | ||
// ----------------------------------------------------------------------------- | ||
-(id) initWithCVImageBufferRef: (CVImageBufferRef) _imageBuffer{ | ||
|
||
if((self = [super init])){ | ||
|
||
CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); | ||
void *baseAddr = CVPixelBufferGetBaseAddress(_imageBuffer); | ||
size_t bytesPerRow = CVPixelBufferGetBytesPerRow(_imageBuffer); | ||
size_t width = CVPixelBufferGetWidth(_imageBuffer); | ||
size_t height = CVPixelBufferGetHeight(_imageBuffer); | ||
|
||
CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, baseAddr, bytesPerRow*height, NULL); | ||
|
||
image = CGImageCreate(width, height, 8, 24, bytesPerRow, colorSpace, kCGImageAlphaNone, provider, NULL, false, kCGRenderingIntentDefault); | ||
|
||
CGColorSpaceRelease(colorSpace); | ||
CGDataProviderRelease(provider); | ||
} | ||
|
||
return self; | ||
} | ||
// ----------------------------------------------------------------------------- | ||
- (void) dealloc{ | ||
CGImageRelease(image); | ||
[super dealloc]; | ||
} | ||
@end |
Oops, something went wrong.