What Software Make Sense for Machine Vision?
Machine-vision software offers choices between ease of use and overall control.
Jon Titus, Editorial Director -- Test & Measurement World, 4/15/2000
| Youve started working
on a machine-vision application and youre wondering about software tradeoffs.
Ready-to-run machine-vision software looks good, but will such standardized software run
your specific hardware, and will it produce useful results? On the other hand, programmers
at your company continue to push you to look at C++, a language that can produce compact,
fast code. Its difficult to decide which route to take. The best bet is to start simple and first determine whether any machine-vision software will meet your requirements. You may need to put together a prototype system to see what machine-vision software can do. (Such a setup also lets you experiment with lights, optics, and cameras.) At the prototype stage, you can get quick proof-of-concept results by spending as little as a few hundred dollars on commercial software. Such software, which lets you rapidly set up a machine-vision system, will help you determine if you can achieve the goals set for the machine-vision system. Those goals could cover throughput, ease of use, interfacing with existing equipment, and producing quality reports. Several companies offer graphical programs or menu-based programs that will let you get a prototype up and running quickly. Graphical programs such as WiT from Coreco, LabView from National Instruments, and Vision Program Manager (VPM) from PPT Vision (see Product Information, p. 26) provide graphic elements, or icons, that represent machine-vision or image-processing tasks and algorithms. By connecting the elements, you can prototype image-acquisition and image-processing operations, and you can produce graphical-user interface (GUI) designs. So running new tests is easy; you just rearrange the graphical building blocks to try a new approach.1
The software you choose for prototyping depends on your preferencesconnecting icons or making menu choices. Both packages provide useful tools for processing images.2 Before you buy a software package, be sure it will work with the hardware you plan to use during prototyping and in your complete system. The hardware drivers and the software packages must interface easily. Software vendors provide drivers for the hardware they sell, but if you need drivers for other hardware, ask about them when youre talking with software suppliers. If youre new at using machine-vision software, you might gain by buying at least your prototype hardware and software from one supplier. Youll ensure the hardware and software work together, and you wont get caught in the middle of technicians from several suppliers blaming each other for any problems you encounter. Which Option Is Better? But despite the versatility of ready-to-use commercial packages, those pesky programmers keep pitching C++ as an alternative. They say C++ code offers more flexibility and will run faster than point-and-click software. By using C++, you get the most control over the machine-vision system because youre working close to the components. Higher-level software insulates you from the details of the system, and it may prevent you from doing some things, such as directly controlling I/O ports. For some applications, the programmers are right: C++ makes sense. But its not for everyone. Heres a rule of thumb for deciding which software route to take: If you need high throughput and need to tweak algorithms to get the best performance from a system, or if youre making dozens or more of the same machine-vision system, and if youre an intermediate to advanced C++ programmer, then choose C++ as your development language. On the other hand, if youre more concerned with getting a system set up and working quickly, and you are unfamiliar with application programming interface (API) calls, dynamic link libraries (DLLs), and ActiveX controls, stay with a graphic or menu-based package. The majority of machine-vision applications work well using either the graphical or menu-based programs. So, unless you can see a pressing need for the speed, flexibility, and low-level I/O control provided by C++, leave it to system integrators and machine-vision experts. Take Advantage of Prior Work How would you make an easy jump from using a commercial package to C++, in which youre responsible for almost everything? Youll want to take advantage of the work put into the prototype. So if youre even slightly serious about using C++, before you buy a graphical or menu-based package for prototyping, see if the supplier either makes available its underlying APIs, DLLs, ActiveX controls, and drivers or if it provides a set of equivalent functions. Data Translation takes the former approach in its DT Vision Foundry package. Imaging Technology offers Sherlock for rapid prototype development and offers MVTools as a package of library functions and DLLs for C and C++. About 90% of the tools in National Instruments IMAQ Vision Builder are available as equivalent APIs. The availability of these software tools improves your chance of success when moving to C++. Say your prototype software, developed using a commercial package, includes an edge-detection task, and the package provides the equivalent algorithm written in C++. You can move the edge-detection task from the prototype code to C++ code and be sure the algorithms work the same way. You wont waste time trying to locate a C++ algorithm or trying to figure out how to code an edge-detection routine.
Manufacturers offer a variety of software you can use with C++, and libraries of functions and procedures give the most control over a PC. Examples of such C++ add-in products include MVTec Softwares Halcon library of ActiveX controls, the ActiveX controls in the VisionBlox package from Integral Vision, and the Fast series of C libraries from Coreco. Data Translation supplies a frame-grabber software-design kit (SDK) that includes basic functions that control frame-grabber operations. (Youll find other image-analysis software vendors in the Buyers Guide section of our Web site.) Dont rush out and buy a C++ library of functions or ActiveX controls to tackle machine-vision tasks unless youre an intermediate or advanced C++ programmer. You wont be able to take on a complex project after only a semester class in C++. Just getting used to working with the APIs, drivers, and DLLs will take time. You may decide the best way to approach C++ code is through the efforts of a system integrator. C++ Needs Drivers, Too Its unlikely youll have to write your own drivers, because hardware suppliers provide them with their products. Be sure you ask suppliers what drivers they provide, and read the documentation to ensure youll have easy access to driver routines for C++ programs. Documentation should include a list of compatible hardware. Because your prototype included some hardwarea camera, a frame-grabber board, and lights at a minimumyou probably have most of the drivers you need. Keep in mind, before you can use these hardware devices, you must configure them; that is, set them up to operate properly by loading registers with starting values, setting timers, activating interrupts, and so on. Different manufacturers perform their setup procedures in different ways, so you may have to master several setup techniques just to get started. A manufacturer offering a broad range of products may offer a single configuration tool that will handle all its hardware in a consistent manner. Is C++ Worth the Effort? Unfortunately, C++ doesnt offer the nice user interfaces provided by commercial software. Youll need to design and program display screens, controls, and the like using C++ along with Microsoft Foundation Class libraries and third-party ActiveX controls.3 Another drawback to using C++ is that youll spend considerable time testing and debugging your code. If youre a system integrator, you can amortize the cost of debugging over many systems, and you can use canned, or reusable, software developed for other projects. But if youre developing only a few systems, you may not have the luxury of the steep learning curvedebug, reprogram, and testrequired to master C++. A graphical program may be a better bet. Youll still do some debugging, but youll spend time determining what algorithms to use instead of figuring out how to pass pointers to a C++ matrix-math library. Each path has its own benefits and liabilities. C++ requires a great deal of programming knowledge and familiarity with many program-development tools and techniques. But it can yield tight, fast code that exactly meets system needs. Graphical and menu-based programs get you running quickly so you can prove a concept. In many cases, they run real applications, too. But they dont answer every need and sometimes may not offer all the functions you want. Even if youre fairly sure which path you want to follow, take a careful look down the other one, too, just to see what it offers. T&MW FOOTNOTES 2. Hanks, John, Basic Functions Ease Entry into Machine Vision, Test & Measurement World, March 2000, p. 69. 3. Rothe, Darrin, Foundation Classes Simplify C/C++ Programming, Test & Measurement World, February 2000, p. 65. All of these articles are available at www.tmworld.com/archives. Contact Jon Titus at jontitus@cahners.com |




















