EDIT (24-11-2011) : Since publishing this post, I have found myself making frequent updates to the CommandCam program, so I’ve created a dedicated page for it instead, with up-to-date information and download links.
Get CommandCam here (binary download and source code available).

Ted,
Thanks for this. I just tested it though – my Toshiba laptop has a built in USB 2.0 Web cam. This is the error I was given:
CommandCom.exe – http://batchloaf.wordpress.com
Written by Ted Burke – this version 15-11-2011
Capture device: USB 2.0 Camera
Could not get buffer size
Let me know if there is anything you need me to check for you.
Stephen
Hi Stephen,
Thanks very much for the feedback. That’s interesting that you’re seeing that message. I get that sometimes on my laptop if I set the time delay to a very short duration (e.g. significantly less than a second). Is it possible that your camera takes a little longer to ‘wake up’ than my one does? Can you please try running it again a few times with a longer time delay. For example, you could try a 5 second delay with the following command:
CommandCam.exe image.bmp 5000
If that works (either reliably or intermittently), then I’ll try to find a way to automatically detect when the camera is definitely ready to take the picture. Because this is the error that you’re seeing, CommandCam must be successfully finding and opening your camera. Otherwise, you would have got a different error earlier in the program.
Thanks again for your help!
By the way, your commandcam.exe link above actually says it is a commandcom.exe link.
Oops! Thanks, I’ve fixed that now. I’ll need to recompile the exe file to fix the typo in the welcome message.
Update: I’ve just fixed a memory leak and I’ve also modified the code that checks whether the camera is ready to capture the image to make it more robust – it should work with more cameras now. If the program runs without printing any errors, but the saved image is completely black, it’s probably just because the image was snapped too soon after your camera turned on. To prevent this, just specify a longer delay (in milliseconds) on the command line (e.g. “CommandCam.exe image.bmp 5000″ will capture an image to the file “image.bmp” after 5 seconds). The default delay (now 2 seconds) is long enough with my laptop and webcam, but if I make the delay much shorter (e.g. 1 second) I only get a black image.
If this program works (or doesn’t work) for you, please let me know so that I can try to improve it! Thanks
It is really good. Thanks!
Thanks S, that’s good to hear!
Be sure to check out the updated version on the new CommandCam page.
Thanks for this. I just tested it though – my Fujitsu laptop has two cam. the first cam is Virtual webcam.can’t use it.only the second one can used. but,when i run the commandcam.
such as:
” commandcam /devnum 2″
“commandcam /devnum 2 /delay 5000″
” commandcam /devnum 2 5000″
This is the error I was given:
http://a3.sphotos.ak.fbcdn.net/hphotos-ak-ash4/321172_2203716374967_1309102920_31943617_1350556545_n.jpg
Capture device: FJ Camera
Could not create capture filter
Hi 刘江,
Thanks very much for the feedback. Sorry to hear you’re having a problem with it. Two suggestions:
1. Have you tried the most recent version of CommandCam? It’s available from this page.
2. Once you have the most recent version of the program, can you please try running “CommandCam /devlist” to see what devices it finds?
Thanks,
Ted
Hi Ted,
first of all thanks for a great tool! I’ve tested it and found it just great.
I would like to save files each minute over a 24 hour period and save the files to an external source. Is this possible?
Cheers,
John
Hi John,
Thanks for your comment. There are two ways you could do this.
The first way is to write a batch file which calls CommandCam every 60 seconds for 24 hours (1440 times in total). Each time an image is saved, you rename it (and / or transfer it the file to another location). For example, save something like the following in a file called “cam.bat”:
FOR /L %%i IN (1,1,1440) DO ( CommandCam.exe rename image.bmp %%i.bmp sleep 60 )When you run “cam.bat” it should snap an image called “image.bmp” every 60 seconds and rename it to “1.bmp”, “2.bmp”, “3.bmp”, etc.
Alternatively, I have another program called RobotEyez that I’ve been working on, which captures multiple images at a specified interval from a webcam. You can download it from http://batchloaf.wordpress.com/2011/11/27/ultra-simple-machine-vision-in-c-with-roboteyes/. Unfortunately, at the moment RobotEyez only saves images as PGM format which is probably not what you want. However, I suppose I could modify it to save BMP files instead if that would do the trick for you. Could you try running it to see if it works as it is? I’ve written a PGM image file viewer that you can download from the same page as RobotEyez, so you should be able to see if the PGM images are being saved correctly. PGM files are black and white, by the way, so if your images appear that way, that’s perfectly normal.
Regards,
Ted
Hi Ted,
Thanks for the prompt reply!
I tried the above batch and it takes the pictures and counts them up, that works fine – but the sleep command doesn’t seem to work properly, the camera takes a picture every couple of seconds, no matter the value (I also tried sleep 180 and sleep 1800 but it had no effect).
Still to try the roboteyes, I’ll get back to you on that one.
Hi John,
I’m not sure whether the “sleep” command is available in every version of Windows. It’s working for me in XP, but if you’re running Vista or Windows 7 perhaps you might try replacing “sleep 60″ with “timeout 60″. I expect it will probably have the same effect.
Do try RobotEyez though – if it works for you, it’s probably more convenient than the batch file anyway.
Regards,
Ted
Actually, I’ve just added a bitmap output option to RobotEyez, so that’s probably the easiest thing to use. Here’s an example command
Here’s the link to the RobotEyez page:
http://batchloaf.wordpress.com/2011/11/27/ultra-simple-machine-vision-in-c-with-roboteyes/