| ||||||||||||||
| ||||||||||||||
|
||||||||||||||
|
When I started playing with Vision Command, I wanted to use my power stand to pivot the LEGO Cam without having to use the Vision Command interface. The QuickCam software didn't support the RCX, so I thought I'd write a program myself. If you didn't know, the LEGO Cam is simply a Logitech QuickCam - so programming for the LEGO Cam is insanely easy. Simply download the Logitech QuickCam SDK and it will install all the necessary files, examples, redistributables (the majority of the download, unfortunately) and a lot of great documentation. The SDK can be downloaded here (about 9Mb download). Once you've installed it and rebooted your system, you'll immediately be able to develop for the QuickCam.
Programming the LEGO Cam in VC++This tutorial will look at developing in Visual C++, but anybody familiar with component programming should be able to follow. Add the QuickCam component to your Visual C++ project - the component is called "VideoPortal". If you do not know how to add a component to your VC++ project, see the Using spirit.ocx in Visual C++ AISolutions article.Now, in your main dialog (or equivalent) add a VideoPortal control. This is done easily in the Visual C++ dialog editor, since a QuickCam icon will be added to the "Controls" toolbar. Next open up ClassWizard and add a member variable called "m_cVideo" to your dialog associated with your VideoPortal control. Finally, in your OnInitDialog (or equivalent) function add something like:
// Prepare the control and registry settings
if (!m_cVideo.PrepareControl("PivotVC",
"HKEY_CURRENT_USER\\Software\\Logitech\\PivotVC", 0 )) {
AfxMessageBox("Error message");
EndDialog(-1);
}
m_cVideo.ConnectCamera2(); // Restore camera settings
m_cVideo.SetPreviewMaxWidth(320); // Set maximum width
m_cVideo.SetPreviewMaxHeight(240);// Set maximum height
m_cVideo.SetEnablePreview(TRUE); // Turn on the preview
The Logitech documentation is excellent, so you should be able to understand the functions by looking them up in the MFC reference document. It is impressive just how little code is required to get a fully functional camera working within your program. Below is a screenshot of my resultant program - it allowed me to take power the stand, and with a little modification allowed me to drive around. Here you can see the rover I built staring at our CyeSR robot.
Submitted: 20/02/2001 Article content copyright © James Matthews, 2001.
|
|
|||||||||||||
All content copyright © 1998-2007, Generation5 unless otherwise noted.
- Privacy Policy - Legal - Terms of Use -