![](https://csdnimg.cn/release/download_crawler_static/11871234/bg12.jpg)
14 How to Develop Applications with HALCON
2.1.3 Parallel HALCON
To put it in a nutshell, Standard HALCON is optimized for running sequential programs on single-
processor or single-core computers. Under Windows NT/2000/XP, Linux, and Solaris, HALCON is
thread-safe, i.e., it can be used in multithreaded programs (with some exceptions listed in the Program-
mer’s Guide, section 1.1 on page 3). However, all HALCON operators are executed exclusively, thus
threads will have to wait for each other.
In contrast, Parallel HALCON supports parallel programming (e.g., multithreaded programs) by being
thread-safe and reentrant. This means that multiple threads can call a HALCON operator simultaneously.
Parallel HALCON is available for Windows NT/2000/XP, Linux, and Solaris.
Besides supporting parallel programming, Parallel HALCON automatically parallelizes operators if
started on multi-processor or multi-core hardware, e.g., a dual-Pentium board. The parallelization mech-
anism is based on distributing the data which has to be processed, i.e., the images, on multiple threads
that run on different processors (so-called data parallelism). For example, for a filtering operation on a
four-processor board the image will be split into four parts which will then be processed in parallel by
four threads executing the (same) filtering operator. Together with HALCON’s philosophy for treating
images and regions, this form of parallelization is very efficient because images need not to be copied.
The degree of parallelization is optimized online to minimize the parallelization overhead. For example,
very small images will not be processed in parallel, as the overhead would surpass the parallelization
speed-up. Moreover, not all HALCON operators lend themselves to parallelization.
Detailed information on using Parallel HALCON can be found in the Programmer’s Guide, section 1.2
on page 4.
Note that Parallel HALCON is designed for shared-memory systems, i.e., systems in which multiple
processors share a common memory as it is the case for typical multi-processor or multi-core boards.
The main reason is that only in a shared-memory system threads can share the HALCON object database
and do not need to copy images. This limitation means that Parallel HALCON is not suited to the use on
workstation clusters or other multi-processor or multi-core hardware that does not offer shared memory.
2.1.4 Image Acquisition
Currently, HALCON provides interfaces for about forty frame grabbers in the form of dynamically
loadable libraries (Windows: DLLs; UNIX: shared libraries). These libraries are installed together with
the HALCON libraries. Library names start with the prefix HFG; the libraries starting with parHFG are
used by Parallel HALCON.
In the following, we give a brief overview of the HALCON frame grabber interface; please refer to the
Application Note on Image Acquisition for detailed information about this topic.
The HALCON frame grabber interface libraries form the bridge between software provided by the frame
grabber’s manufacturer and HALCON. They form a common, generic interface that requires a small set
of operators only.
If you successfully installed your frame grabber, all you need to do to access it from HALCON is to
call the operator
open_framegrabber, specifying the name of the frame grabber and some additional
information, e.g., regarding the connected camera. Then, images can be grabbed by calling the operator
grab_image (or grab_image_async).