Take picture with iSight?
-
Hi there.
I'm looking for a way to take a picture with an iSight or any external
camera in my Cocoa-application. I've been googling and searching the
archives without success. I've also looked at the QTCaptureWidget and
QTRecorder samplecode to see if there's anything I could use, but they
only show how to record movies with the camera.
I understand that I have to use the QT-framework, but could somebody
please give me some pointers in the right direction?
Kind regards,
Tim Andersson -
If you don't need to support pre-Leopard, check out IKPictureTaker
cheers, Graham
On 18 Nov 2008, at 11:25 pm, Tim Andersson wrote:> Hi there.
>
> I'm looking for a way to take a picture with an iSight or any
> external camera in my Cocoa-application. I've been googling and
> searching the archives without success. I've also looked at the
> QTCaptureWidget and QTRecorder samplecode to see if there's anything
> I could use, but they only show how to record movies with the camera.
> I understand that I have to use the QT-framework, but could somebody
> please give me some pointers in the right direction?
>
> Kind regards,
> Tim Andersson -
Sorry, forgot to say that I have looked at the IKPictureTaker and it
isn't really what I'm looking for. I don't want the user to be able to
choose a picture or anything like that, I just want to take a picture
when the user clicks a button for example or when I call a method in
my code. Is this possible?
I don't need to support pre-Leopard.
Cheers,
Tim
18 nov 2008 kl. 13.31 skrev Graham Cox:> If you don't need to support pre-Leopard, check out IKPictureTaker
>
> cheers, Graham
>
>
>
>
> On 18 Nov 2008, at 11:25 pm, Tim Andersson wrote:
>
>> Hi there.
>>
>> I'm looking for a way to take a picture with an iSight or any
>> external camera in my Cocoa-application. I've been googling and
>> searching the archives without success. I've also looked at the
>> QTCaptureWidget and QTRecorder samplecode to see if there's
>> anything I could use, but they only show how to record movies with
>> the camera.
>> I understand that I have to use the QT-framework, but could
>> somebody please give me some pointers in the right direction?
>>
>> Kind regards,
>> Tim Andersson
> -
You've looked at QTKit.h with its QTCapturexxxx classes?
Gary
On Nov 18, 2008, at 5:38 AM, Tim Andersson wrote:>
> Sorry, forgot to say that I have looked at the IKPictureTaker and
> it isn't really what I'm looking for. I don't want the user to be
> able to choose a picture or anything like that, I just want to take
> a picture when the user clicks a button for example or when I call
> a method in my code. Is this possible?
>
> I don't need to support pre-Leopard.
>
> Cheers,
> Tim
>
> 18 nov 2008 kl. 13.31 skrev Graham Cox:
>
>> If you don't need to support pre-Leopard, check out IKPictureTaker
>>
>> cheers, Graham
>>
>>
>>
>>
>> On 18 Nov 2008, at 11:25 pm, Tim Andersson wrote:
>>
>>> Hi there.
>>>
>>> I'm looking for a way to take a picture with an iSight or any
>>> external camera in my Cocoa-application. I've been googling and
>>> searching the archives without success. I've also looked at the
>>> QTCaptureWidget and QTRecorder samplecode to see if there's
>>> anything I could use, but they only show how to record movies
>>> with the camera.
>>> I understand that I have to use the QT-framework, but could
>>> somebody please give me some pointers in the right direction?
>>>
>>> Kind regards,
>>> Tim Andersson
>> -
On 18 Nov 2008, at 11:38 pm, Tim Andersson wrote:>
> Sorry, forgot to say that I have looked at the IKPictureTaker and it
> isn't really what I'm looking for. I don't want the user to be able
> to choose a picture or anything like that, I just want to take a
> picture when the user clicks a button for example or when I call a
> method in my code. Is this possible?
>
> I don't need to support pre-Leopard.
A cursory scan of the docs suggests to me that a good place to start
looking would be QTCaptureDecompressedVideoOutput. This sends a
CVBufferRef to the delegate during capture, and there are methods
associated with that class to get basic information such as base
address, row bytes, height and so on, which would allow you to wrap
that buffer in a NSBitMapImageRep and from there to an NSImage and so
on....
So, that's probably what I'd be initially pursuing if it were me, but
take that with a pinch of salt as I might be way off.
hth,
Graham -
Yay, thanks to you I found a tutorial showing me how to do what Graham
mentioned. :) I didn't know how to look inside QTKit.h, so I googled
"QTKit.h" and I found the tutorial -> http://developer.apple.com/documentation/QuickTime/Conceptual/QTKitCaptureP
rogrammingGuide/Introduction/chapter_1_section_1.html
Thanks for your help guys :)
Cheers,
Tim
18 nov 2008 kl. 14.05 skrev M Pulis:> You've looked at QTKit.h with its QTCapturexxxx classes?
>
> Gary
>
>
>
> On Nov 18, 2008, at 5:38 AM, Tim Andersson wrote:
>
>>
>> Sorry, forgot to say that I have looked at the IKPictureTaker and
>> it isn't really what I'm looking for. I don't want the user to be
>> able to choose a picture or anything like that, I just want to take
>> a picture when the user clicks a button for example or when I call
>> a method in my code. Is this possible?
>>
>> I don't need to support pre-Leopard.
>>
>> Cheers,
>> Tim
>>
>> 18 nov 2008 kl. 13.31 skrev Graham Cox:
>>
>>> If you don't need to support pre-Leopard, check out IKPictureTaker
>>>
>>> cheers, Graham
>>>
>>>
>>>
>>>
>>> On 18 Nov 2008, at 11:25 pm, Tim Andersson wrote:
>>>
>>>> Hi there.
>>>>
>>>> I'm looking for a way to take a picture with an iSight or any
>>>> external camera in my Cocoa-application. I've been googling and
>>>> searching the archives without success. I've also looked at the
>>>> QTCaptureWidget and QTRecorder samplecode to see if there's
>>>> anything I could use, but they only show how to record movies
>>>> with the camera.
>>>> I understand that I have to use the QT-framework, but could
>>>> somebody please give me some pointers in the right direction?
>>>>
>>>> Kind regards,
>>>> Tim Andersson
>>>
> -
I use the delegate:
-(CIImage *) view:(QTCaptureView *)view willDisplayImage : (CIImage *)
image
to grab a frame and bypass the basics. I found it straightforward to
transform and filter the frame as needed.
Found the technique in Apple sample code - forget which one now...
core image, core filters and nstransforms, qt .. all blurring a bit.
Gary
On Nov 18, 2008, at 6:14 AM, Graham Cox wrote:>
> On 18 Nov 2008, at 11:38 pm, Tim Andersson wrote:
>
>>
>> Sorry, forgot to say that I have looked at the IKPictureTaker and
>> it isn't really what I'm looking for. I don't want the user to be
>> able to choose a picture or anything like that, I just want to
>> take a picture when the user clicks a button for example or when I
>> call a method in my code. Is this possible?
>>
>> I don't need to support pre-Leopard.
>
>
> A cursory scan of the docs suggests to me that a good place to
> start looking would be QTCaptureDecompressedVideoOutput. This sends
> a CVBufferRef to the delegate during capture, and there are methods
> associated with that class to get basic information such as base
> address, row bytes, height and so on, which would allow you to wrap
> that buffer in a NSBitMapImageRep and from there to an NSImage and
> so on....
>
> So, that's probably what I'd be initially pursuing if it were me,
> but take that with a pinch of salt as I might be way off.
>
> hth,
>
> Graham


