ImageSnap: Capturing a Video Image with QTKit on Snow Leopard September 14, 2009
Posted by Robert Harder in : Utility , trackbackImageSnap is a Public Domain command-line tool that lets you capture still images from an iSight or other video source. You might remember Axel Bauer’s original isightcapture tool (that is no longer supported but still works on most systems). I wanted a similar tool with source available so I could make feature changes or at least recompile with Apple’s ever-changing architectures.
At some point Apple introduced QTKit, a new and oh-so-welcome abstraction bringing QuickTime programming into the 21st century. Nothing against die-hard ANSI C programming, but it fits awkwardly into what are otherwise clean Objective-C Cocoa programs.
Rather than provide a detailed tutorial about using QTKit (sorry if you wanted one), I’ll just point you to the ImageSnap code so you can take a look at a few useful things like starting a QTCaptureSession, capturing output with QTCaptureDecompressedVideoOutput, and saving an NSImage to disk.
Comments»
Hi,
Thanks for this tool, wich works as a charm,
but…the pict is a little bit to large 5,3 Mo, is there a way to reduce it ?
That’s pretty big. Are you saving as an uncompressed image like TIFF or PNG?
Found and fixed a bug that caused images to save as TIFF. Probably explains problem above. Fixed in v0.2.3. -Rob
Cool idea, but I’m getting this error when I run imagesnap:
_NXCreateWindow: error setting window property (1002)
_NXTermWindow: error releasing window (1002)
I read somewhere (http://cocoadev.com/forums/comments.php?DiscussionID=372) about using this:
[NSApplication sharedApplication];
Do you think that would solve the problem? I don’t have XCode (Linux at Work, Mac at home), so I’m not able to compile and test. Email me directly if you get this anytime soon.
Thanks,
Jesse
thouin @ verypopularemailthatstartswithG
Hello.
The imagesnap program seems to be very useful, however I’m having the same problem Jesse Thouin just described. The iSight camera briefly tuns on, then shows these messages:
2010-01-10 23:01:37.064 imagesnap[4577:807] _NXCreateWindow: error setting window property (1002)
Error.
2010-01-10 23:01:37.318 imagesnap[4577:807] _NXTermWindow: error releasing window (1002)
Capturing image from device “Built-in iSight”…
And finally exits, with no image captured.
It would be great if you could make it work.
Thanks in advance for such a useful replacement of isightcapture.
JP
Hi Robert,
thanks for releasing imagesnap. i’ve had fun messing around with running it from applescript, mainly as an attempt to start learning some programming skills, and have just submitted a hint using it to Mac OS X Hints. Hopefully someone might find it useful.
I didn’t have any of the problems mentioned above. It worked straight out of the tin, unlike iSightCapture, which I could only seem to run from a terminal window rather than as a ‘do shell script’
thanks again
EHB, that’s good to hear. I wish we could figure out where these _NXCreateWindow errors are coming from. -Rob
I made the Debug version, and it errors out with this (followed by the stack trace):
imagesnap[9714:10b] *** Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘Error (1002) creating CGSWindow’
It’s on Leopard, not Snow Leopard. Does that make a difference?
This seems to be a Leopard/Snow Leopard thing. One technique works in L and not SL, and the other technique is the opposite. -Rob
In order to prevent this “CGSWindow” thing, you need to call NSApplicationLoad() in main().
Need some beta testers to try out the version with NSApplicationLoad(). It doesn’t crash 10.6 (as the sharedApplication call did), but I don’t have 10.5 to test on, so I need some help. Thanks.
http://dl.dropbox.com/u/4303707/ImageSnap-v0.2.4beta.tgz
-Rob
Just letting you know that the Beta 0.2.4 did work on 10.5.8.
OK, the ImageSnap home page now links to v0.2.4 (no longer beta). Hope it works for everyone! -Rob
http://iharder.sourceforge.net/current/macosx/imagesnap/
I’m having a strange issue with ImageSnap. When executing it over ssh, it will work the first one or two times, but thereafter the saved image consists solely of uniform green pixels. The light on the iSight does blink, so it does seem to be accessing the camera.
@Syl That does seem strange. Nothing comes to mind that mind account for it. -Rob