Christopher and vade

Thank you for advices!

I wrote a simple code like folloings.
It works well but only once I saw that monitor View changed black after
monitoring few seconds. So I'll check Reliability
and if you have any advice, I'll welcome.

//

//  QTCaptureTestAppDelegate.m

//  QTCaptureTest

//

// Source:

//
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/QTKitApplicationProgrammingGuide/UsingQTKit/UsingQTKit.html

//  Created on 10/08/07.

//


#import "QTCaptureTestAppDelegate.h"


*...@implementation* QTCaptureTestAppDelegate


*...@synthesize* window;


- (*void*)applicationDidFinishLaunching:(NSNotification *)aNotification {

*BOOL* success = *NO*;

    NSError *error;


 *if*(![qcView loadCompositionFromFile:[[NSBundle mainBundle]
pathForResource: @"QC"

  ofType:@"qtz"]]) {

NSLog (@"QC file load error");

*return*;

}

[ qcView startRendering ];


 // Create the capture session.

mCaptureSession = [[QTCaptureSession alloc] init];

 // Find a video device and connect your inputs and outputs to the session.

QTCaptureDevice *videoDevice = [QTCaptureDevice
defaultInputDeviceWithMediaType:

 QTMediaTypeMuxed  // Video and Audio device

// QTMediaTypeVideo // Video only

];

    success = [videoDevice open:&error];

*if* (success == *NO*) {

NSLog (@"Open device error");

*return*;

}

 // Add the video device to the session as a device input.

mCaptureVideoDeviceInput = [[QTCaptureDeviceInput alloc]
initWithDevice:videoDevice];

success = [mCaptureSession addInput:mCaptureVideoDeviceInput error:&error];

*if* (success == *NO*) {

NSLog (@"Add the video device to the session error");

*return*;

}

  // Associate your capture view in the UI with the session and start it
running.

[mCaptureView setCaptureSession:mCaptureSession];

[mCaptureSession startRunning];

  // Setup QTCaptureDecompressedVideoOutput to get each fames

mCaptureMovieDecomopressOutput = [[QTCaptureDecompressedVideoOutput alloc]
init];

    [mCaptureMovieDecomopressOutput setDelegate:*self*];

    [mCaptureSession addOutput:mCaptureMovieDecomopressOutput error: &
error];

}



 // delegate of QTCaptureDecompressedVideoOutput

// Called whenever the video preview output outputs a new video frame.

// source:

// http://decafish.blog.so-net.ne.jp/2008-08-30-2

- (*void*)captureOutput:(QTCaptureOutput *)captureOutput

  didOutputVideoFrame:(CVImageBufferRef)videoFrame

     withSampleBuffer:(QTSampleBuffer *)sampleBuffer

       fromConnection:(QTCaptureConnection *)connection

{

    *...@synchronized* (*self*) {

        CVBufferRetain(videoFrame);

        CIImage *image = [CIImage imageWithCVImageBuffer:videoFrame];

//        [previewView setCIImage:image];

[qcView setValue: image forInputKey:@"Image"];

        CVBufferRelease(videoFrame);

    }

}


*...@end*
*
*

Regards,



2010/8/7 vade <[email protected]>

> A work around, if you are so inclined is to use QTKit Capture classes and
> feed images to a published input port. Using a QTCaptureSession and 'preview
> mode' offers similar (if not the same) performance as Quartz Composers Video
> Input patch.
>
> Publish an image, and then set the value for the key on your QCRenderer
> instance, and then call renderAtTime: withArguments:
>
> This is a bit more involved that a QCView, but totally doable.
>
> On Aug 6, 2010, at 4:52 PM, Christopher Wright wrote:
>
> >> I want to select video device of Video Input in QC loaded
> >> to QCView from my App.
> >> I guess changing "Default" device of Video Input may work.
> >
> > Changing this will allow you to select a different video device, but
> unfortunately it is not programmatically available (your application cannot
> change this value;  only the QuartzComposer Editor can).  This makes it very
> limited.
> >
> > --
> > Christopher Wright
> > [email protected]
> >
> >
> >
> > _______________________________________________
> > Do not post admin requests to the list. They will be ignored.
> > Quartzcomposer-dev mailing list      ([email protected]
> )
> > Help/Unsubscribe/Update your Subscription:
> >
> http://lists.apple.com/mailman/options/quartzcomposer-dev/doktorp%40mac.com
> >
> > This email sent to [email protected]
>
>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to