Hand machined mechanical pencils

Webcam crosshairs using Processing (29/05/13)

I had previously written software that overlaid crosshairs on to a live webcam feed, for use in aligning the milling machine or router. However, that softwar relied on a "fix" where the crosshairs were displayed in a separate, transparent, window which was placed over the webcam feed. This is far from ideal since the window can be accidentally moved.

I later found a relatively simple way (using AVICAP32) of getting a "real" frame image into a VB6 PictureBox, which let me draw stuff on top of the frame in the PictureBox. However, this used the clipboard for transferring the frame from the video feed to the PictureBox, meaning that the clipboard couldn't be used for anything else while the program was running.

I hunted around for a way of getting frame data directly from AVICAP32 without using the clipboard. It's doable, but requires a lot of code, 90% of which is gibberish to me. Surely there must be a simpler way?

I remembered I'd heard about the programming language "Processing" and that it was widely used for visual programming. Literally 10 minutes after installing it, I had a live webcam feed in a window and was able to draw lines and graphics directly on to it!! The language is so easy to use.

Downloads. You have several options. You could download the Processing environment from their website at https://www.processing.org/download/?processing and then download my source code - either for the simple viewer program (just displays the webcam feed) or the full webcam crosshairs program. These are in the form of "sketches" which can be run from inside the Processing environment. The other option is to download this ZIP file. When extracted, there is a excecutable "webcam_crosshairs.exe" - run this and it should work. It's rather large, because it needs a lot of the Processing framework to run properly. The advantage of using the source code + Processing environment is that you can run it on any system.

Operation. It's pretty easy to use. Everything is through keyboard or mouse shortcuts. The splash page displays a listing of the commands, but here they are again:

Couple of screenshots: