[racket] webcam hooks in racket?
I have a few lines to get you going from objc... I use OpenCL and OpenGL in the captureOutput delegate so your on your own there but this would be a start.
- (void)awakeFromNib
{
NSError *error = nil;
if (!mCaptureSession)
{
// Set up a capture session that outputs raw frames
BOOL success;
mCaptureSession = [[QTCaptureSession alloc] init];
// Find a video device
QTCaptureDevice *device = [QTCaptureDevice defaultInputDeviceWithMediaType: QTMediaTypeVideo];
success = [device open:&error];
if (!success)
{
[[NSAlert alertWithError:error] runModal];
return;
}
// Add a device input for that device to the capture session
mCaptureDeviceInput = [[QTCaptureDeviceInput alloc] initWithDevice:device];
success = [mCaptureSession addInput:mCaptureDeviceInput error: &error];
if (!success)
{
[[NSAlert alertWithError:error] runModal];
return;
}
// Add a decompressed video output that returns raw frames to the session
mCaptureDecompressedVideoOutput = [[QTCaptureDecompressedVideoOutput alloc] init];
[mCaptureDecompressedVideoOutput setDelegate:self];
success = [mCaptureSession addOutput:mCaptureDecompressedVideoOutput error: &error];
if (!success)
{
[[NSAlert alertWithError:error] runModal];
return;
}
// Start the session
[mCaptureSession startRunning];
}
}
- (void)dealloc
{
[mCaptureSession release];
[mCaptureDeviceInput release];
[mCaptureDecompressedVideoOutput release];
[super dealloc];
}
// This delegate method is called whenever the QTCaptureDecompressedVideoOutput receives a frame
- (void)captureOutput:(QTCaptureOutput *)captureOutput didOutputVideoFrame:(CVImageBufferRef)videoFrame withSampleBuffer:(QTSampleBuffer *)sampleBuffer fromConnection:(QTCaptureConnection *)connection
{
}
On Jan 11, 2011, at 6:58 AM, Ben Dean wrote:
> Hmm, thanks, I really appreciate the help. Obviously an oversight on my part, but I'm targeting OSX and the built-in apple "iSight" or whatever they iCall it. It looks like it's on the list for UVC. I'm pretty new to this game, and have very little experience with language interop and device drivers, so I'd really value an overall idea what the interface between a driver and Racket would look like. I think the target audience of the UVC site knows more about this sort of thing than I do, so any additional pointers would be great.
>
> On Tue, Jan 11, 2011 at 6:51 AM, Neil Van Dyke <neil at neilvandyke.org> wrote:
> Noel Welsh wrote at 01/11/2011 05:31 AM:
>
> Then depending on the platform and webcam different APIs are available.
>
>
> Yeah, webcam support has always been a mess, on all platforms.
>
> If you're on GNU/Linux, I'm not sure of the current best approach, but I guess would probably start with Linux UVC and some popular, high-quality USB camera that is supported by UVC. http://www.ideasonboard.org/uvc/
>
> I'd have the compatibility list on that page in one hand, and Newegg.com in the other hand. And before buying, I'd do a quick Google for the make&model and "linux" and "uvc" to see if anyone is reporting problems. It happens.
>
> You could also do eBay, where I recall there have been some sweet spots of premium cameras that are supported well by Linux but that are inexpensive now. (Sorry, I don't remember particular models anymore.) One of the nice things about slightly-older devices is that there's been time for Linux device support to be implemented and tested.
>
> If you're using a less-popular slightly-older camera, beware that some manufacturers have made engineering changes to their cameras without changing the model number, sometimes breaking drivers that have been reverse-engineered. Compatibility tables might not be aware of the multiple variants -- sometimes someone just reported that a particular model worked (perhaps with a small patch for the ID or something), so that model would marked as supported in the table, without any awareness that there are multiple variants.
>
> --
> http://www.neilvandyke.org/
>
> _________________________________________________
> For list-related administrative tasks:
> http://lists.racket-lang.org/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110111/18040a8c/attachment.html>