Here it is.  There can be two capture views that use this (one within
the main presentation window plus a miniature in the A/V inspector panel),
or switch to one capture view in a separate video window.  We hope to
eventually encode and stream same video.

    I'd like to get control of the iSight camera to reduce its resolution
since the displayed video is generally much smaller that my internal
iSight's 1280 x 1024.  Lower frame rate would also be good.

    If no clipping, the bezier returns nil and "clippedImage" returns same
CIImage.  Works great with no clipping, even with flipped/rotated images.

    BTW, if anyone knows how to get rid of the black background and window
fill in a QTCaptureView, please let me know.  I've tried about everything --
setting opacity, fillcolor clear, etc.

    I would also like to clip QTMovieView;  I used to do this stuff in MacOS
9 with sequence grabbers.  I wish the QTKit stuff had an easy way to do it.



- (CIImage*)clippedImage:(CIImage*)image {
    NSRect rect = NSRectFromCGRect([image extent]);
    NSBezierPath* clipPath = [self clipPathInRect:rect];    //  Nil if no
clipping.
    if(clipPath == nil) return image;    //    Nothing to do.
    
    NSImage *clippedImage = [[NSImage alloc] initWithSize:rect.size];
    
    [clippedImage lockFocus];
    [clipPath addClip];
    [image drawAtPoint:NSZeroPoint fromRect:rect operation:NSCompositeCopy
fraction:1.0f];
    [clippedImage unlockFocus];
    
    // Create CIImage from data  (Better way to do this?)
    CIImage * ciImage = [[CIImage alloc] initWithData:[clippedImage
                                                       TIFFRepresentation]];
    return ciImage;
}


//    Delegate of NSCaptureView
- (CIImage *)view:(QTCaptureView *)view willDisplayImage :(CIImage *)image {
    CIImage* newImage = image;
    CIImage* returnImage = nil;
    
    if([self usesTransform]) newImage = [image
imageByApplyingTransform:transform]; //  90 deg rotation and flips -- not
used in trial.
    
    {... Freeze/capture -- not used in trial}

    returnImage = [self clippedImage:returnImage];
    return returnImage;
}



> Gordon,
> 
> Would you post a snippet of your code.  I'm curious as to how you're
> approaching this.
> 
> regards,
> 
> douglas
> 
> On Jun 5, 2008, at 9:26 PM, Gordon Apple wrote:
> 
>>    After receiving this, I tried something similar for clipping.
>> After I
>> cut in the filter, it worked for a few seconds, then slowed to
>> crawl, then
>> crashed.  The images from the internal iSight are large.  My theory
>> is that
>> all those NSImages (and associated caches) simply overwhelmed the
>> garbage
>> collector and eventually crashed it.  There's got to be a better way.
>> 
>>    I thought about Keeping one NSImage, erasing it, and redrawing it
>> each
>> time, but the filter delegate gets used by more than one
>> QTCaptureView.
>> 
>> Ideally, the clipping should be done in the GPU and set up only once.
>> 

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to