How to connect to different configurations of frame grabbers and cameras

Publisher:科技狂人Latest update time:2023-04-23 Source: 机器人及PLC自动化应用Author: Lemontree Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Connecting to the frame grabber

open_framegrabber (AcqName, 1, 1, 0, 0, 0, 0, 'default', -1, 'default', -1, 'false', CameraType, myBoard, -1, -1, AcqHandle)

When opening a connection to an image acquisition device with the operator open_framegrabber, the main parameter is the name of the corresponding HALCON acquisition interface. As a result, you get a so-called handle (AcqHandle) with which you can access the image acquisition device, for example, when calling the operator grab_image.

Figure 2.1: a) Acquired image; b) Processed image (automatic segmentation)

In the examples, most other parameters use default values ​​('default' or -1).

Step 2: Capture the image

grab_image(Image, AcqHandle)

After successfully connecting to your image acquisition device, you can grab an image by calling the operator grab_image with the corresponding handle AcqHandle.

Step 3: Loop through the images

while (Button != 1)

grab_image(Image, AcqHandle)

dev_set_window (WindowHandle)

dev_display (Image)

* -》 process image (segment with an automatically determined threshold)

auto_threshold (Image, Regions, 4)

connecon (Regions, ConnecdRegions)

dev_set_window (WindowHandleProcess)

dev_display (ConnectedRegions)

* -》 check for a click into the window (error handling switched off, otherwise the cuor must always be in the window)

dev_set_check ('~give_error')

get_mposition (WindowHandleButton, Row, Column, Button)

dev_set_check ('give_error')

endwhile

In the example, the grabbed image is then automatically segmented using the operator auto_threshold (see Figure 2.1). This is done in a loop that can be exited by clicking in the window with the left mouse button.

3. Connect to your image acquisition device

In this section we will show how to connect to frame grabbers and cameras in different configurations, from simple cases where one camera is connected to one frame grabber to more complex cases such as multiple synchronized cameras connected to one or more boards.

3.1 Open the connection with the specified configuration

With the operator open_framegrabber you can open a connection to an image acquisition device. Such a connection is described by four parameters (see Figure 3.1): First, you select an acquisition interface with the parameter Name. The parameter Device specifies the actual board or camera; depending on the acquisition interface, this parameter can contain a string describing the board or a simple number (in the form of a string!). Usually, cameras can be connected to the frame grabber at different ports, whose number can be selected with the parameter Port (or LineIn in rare cases). The parameter CameraType describes the connected camera: For cameras, this parameter usually specifies the used norm, for example, 'ntsc'. For cameras, this parameter usually specifies the camera model; more complex acquisition interfaces use this parameter to select a camera profile.

Therefore, open_framegrabber returns the handle of the open connection in the parameter AcqHandle. Note that if you use HALCON's COM or interfaces and call the operator via the corresponding class, such as HFramegrabber in C++, no handle is returned, because the instance of the class itself acts as your handle.

Using HDevelop's Image Acquisition Assistant you can easily connect to your image acquisition device and select the appropriate parameters.

3.2 Connecting multiple boards and cameras

Most HALCON acquisition interfaces allow the use of multiple frame grabbers and cameras. However, there is more than one way to connect cameras and boards and to access these configurations from within HALCON. Below, we describe different configurations; please check the online documentation of the HALCON interface for your image acquisition device (see %HALCONROOT%dochtmlmanuals, the HALCON folder in the Windows start menu, or http://www.halcon.com/image-acquisition) to find out which configurations it supports.

3.2.1 Single Camera

Figure 3.2a shows the simplest configuration: a single camera connected to a single board, accessible through a single handle. Some frame grabbers, especially digital ones, support only this configuration; you can still use multiple cameras with such frame grabbers by connecting each camera to a separate circuit board, as described in the following section. Note that this configuration is typical for digital cameras connected via 2.0, IEEE 1394, or GigE.

3.2.2 Multiple Boards

Figure 3.2b shows a configuration with multiple cameras, each connected to a separate board. In this case, you call the operator open_framegrabber once for each connection in the HDevelop example program solution_guideimage_acquisitionmultiple_boards.hdev.

Figure 3.2: a) Single board with single camera; b) Multiple boards, each with one camera; c) Multiple boards with one or more cameras; d) Multiple cameras on a single board and port switching; e) Multiple cameras on a single board for simultaneous capture; f) Simultaneous capture using multiple boards and cameras

open_framegrabber (AcqName, 1, 1, 0, 0, 0, 0, 'default', -1, 'default', -1, 'default', 'default', Board0, -1, -1, AcqHandle0)

open_framegrabber (AcqName, 1, 1, 0, 0, 0, 0, 'default', -1, 'default', -1, 'default', 'default', Board1, -1, -1, AcqHandle1)

In this example, the two calls differ only in the value of the parameter Device ("0" and "1"); of course, you can use different values ​​for the other parameters and even connect to different image acquisition interfaces.

To grab images from two cameras, you only need to call the operator grab_image once with the two handles returned by two calls to open_framegrabber:

grab_image (Image0, AcqHandle0)

grab_image (Image1, AcqHandle1)

3.2.3 Multiple handles per board

Many frame grabbers offer multiple input ports, thus allowing multiple cameras to be connected to the board. Depending on the HALCON acquisition interface, this configuration can be accessed in different ways as described in this and the following sections.

The standard HALCON way of connecting cameras is shown in Figure 3.2c: Each connection has its own handle, i.e. open_framegrabber is called once for each camera with a different value for the parameter Port, as in the HDevelop example program solution_guideimage_acquisition multiple_ports.hdev:

open_framegrabber(AcqName, 1, 1, 0, 0, 0, 0, 'default', -1, 'default', -1,

'default', 'default', Board0, Port0, -1, AcqHandle0)

open_framegrabber(AcqName, 1, 1, 0, 0, 0, 0, 'default', -1, 'default', -1,

'default', 'default', Board1, Port1, -1, AcqHandle1)

grab_image (Image0, AcqHandle0) grab_image (Image1, AcqHandle1)

As shown in Figure 3.2c, you can also use multiple boards to connect multiple cameras.

3.2.4 Port Switching

Some image acquisition interfaces do not access the camera via multiple handles, but rather by dynamically switching the input ports (see Figure 3.2d). Therefore, open_framegrabber is called only once, as in the HDevelop example program solution_guideimage_acquisitionport_switching.hdev:

open_framegrabber (AcqName, 1, 1, 0, 0, 0, 0, 'default', -1, 'default', -1, 'default', 'default', 'default', 0, -1, AcqHandle)

Between grabbing images you switch the port using the operator set_fegrabber_param

set_framegrabber_param (AcqHandle, 'port', Port0)

dev_set_window (WindowHandle0)

grab_image (Image0, AcqHandle)

set_framegrabber_param (AcqHandle, 'port', Port1)

dev_set_window (WindowHandle1)

grab_image(Image1, AcqHandle)

Note that port switching only works for compatible (similar) cameras, since open_framegrabber is only called once, i.e. the same set of parameter values ​​is used for all cameras. In contrast, when using multiple handles as described above, you can specify different parameter values ​​for individual cameras (with some board-specific restrictions).

3.2.5 Simultaneous capture (only for specific interfaces)

In the above configuration, images are grabbed from a single camera by calling the operator grab_image multiple times. In contrast, some acquisition interfaces allow grabbing images from multiple cameras with a single call to grab_image, which then returns a multi-channel image (see Figure 3.2e; Appendix A.1 on page 51 contains more information on multi-channel images). This mode is called simultaneous grabbing (or parallel grabbing); like port switching, it only works with compatible (similar) cameras. For example, you can use this mode to grab synchronized images from a stereo camera system. Note that simultaneous grabbing is only available with very few image acquisition interfaces.

In this mode, open_framegrabber is called only once, as can be seen in the HDevelop example program solution_guideimage_acquisitionsimultaneous_grabbing.hdev:

open_framegrabber (AcqName, 1, 1, 0, 0, 0, 0, 'default', -1, 'default', -1, 'default', 'default', 'default', 0, -1, AcqHandle)

You can check the number of returned images (channels) using the operator count_channels

grab_image (SimulImages, AcqHandle)

count_channels (SimulImages, num_channels)

And extract individual images based on the number of images, for example using decomposition 2, decomposition 3, etc.:

if (num_channels == 2)

decompose2 (SimulImages, Image0, Image1)

Alternatively, you can convert the multi-channel image to an array of images using image_to_channels and then select a single image via select_obj.

3.3 Requesting information about the image acquisition interface

As mentioned before, the individual HALCON acquisition interfaces are described in detail on HTML pages which can be found in the directory %HALCONROOT%\doc\html\manuals or in the HALCON folder in the Windows start menu (if you installed the documentation). Another way to access information about the image acquisition interfaces is to use the operator info_framegrabber.

In the HDevelop sample program solution_guideimage_acquisitioninfo_framegrabber.hdev (preconfigured for the HALCON 1394IIDC interface, adjust the interface name according to your own image acquisition device), call this operator multiple times to query the interface version number, available devices, port number, camera type, and the default values ​​of all parameters of open_framegrabber; the results, that is, the values ​​displayed in the HDevelop variable window, are shown in Figure 3.3.

[1] [2]
Reference address:How to connect to different configurations of frame grabbers and cameras

Previous article:Halcon Knowledge: Rectangle Measurement
Next article:KUKA robot electric servo welding clamp configuration and force establishment process V4.21

Latest robot Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号