3.1   Reading Images From Files

Especially in the prototyping phase you often have a set of sample image files to work from. HDevelop (or rather the underlying HALCON library) supports a wealth of image formats that can be loaded directly (see read_image in the Reference Manual).

Drag-and-Drop

The easiest way to read an image is to simply drag it from a file browser to the HDevelop window and drop it there. When the file is dropped, HDevelop opens the dialog Read Image (see figure 3.1).

Figure 3.1: After dragging an image file onto the HDevelop window.

This dialog displays the full path of the image and automatically proposes a variable name derived from the file name. This name can be edited, or another iconic variable name from the current program may be selected from the drop-down list.

Furthermore, a preview of the image and basic image properties are displayed in the dialog (width, height, color type, and number of channels). If you picked the wrong image, you can select another one from the same directory by pressing the button next to the file name. This will open a file browser native to the operating system, i.e., on Windows you may be able to switch to thumbnail view in this dialog. When another image is selected, the dialog is updated accordingly.

When you click the button OK, the instruction read_image is added to the current program. With the setting of Insert Position you determine where the instruction will be put: At the IC or the PC. If you changed your mind about reading the selected image at all, click Cancel.

Drag-and-Drop of Multiple Images

You can also drag multiple images or directories containing multiple images to HDevelop. HDevelop will then open an image acquisition assistant with the images preselected. See section “Image Acquisition Assistant” for further information.

Images from Selected Directories

Apart from dragging and dropping images, there is an equivalent method from within HDevelop: Select File ▹ Read Image... to get the dialog described above. Browse to and select the desired image from this dialog, and click OK to add the selected image to your program.