HALCON Class Reference

Contains functions for using data ic4::ImageBuffer objects in MVTec HALCON. More...

Static Public Member Functions

static HalconCpp::HImage 
wrap (const ic4::ImageBuffer &buffer, ic4::Error &err=ic4::Error::Default())

Wraps the passed image buffer in an HALCON HImage.

static bool 
canWrap (const ic4::ImageBuffer &buffer)

Checks whether wrap can work on the passed image buffer.

static HalconCpp::HImage 
copy (const ic4::ImageBuffer &buffer, ic4::Error &err=ic4::Error::Default())

Creates a copy of the image buffer and stores it in a HALCON HImage.

static std::shared_ptr< ic4::ImageBuffer
copy (const HalconCpp::HImage &src, std::shared_ptr< ic4::BufferPool > pool, ic4::Error &err=ic4::Error::Default())

Copies the contents of a HALCON HImage into a new ic4::ImageBuffer.

static std::shared_ptr< ic4::ImageBuffer
copy (const HalconCpp::HImage &src, ic4::Error &err=ic4::Error::Default())

Copies the contents of a HALCON HImage into a new ic4::ImageBuffer.

static bool 
copy (const HalconCpp::HImage &src, ic4::ImageBuffer &dest, ic4::Error &err=ic4::Error::Default())

Copies the contents of a HALCON HImage into an ic4::ImageBuffer.

Detailed Description

Contains functions for using data ic4::ImageBuffer objects in MVTec HALCON.

The HALCON interop support functions are declared in ic4interop/interop-HALCON.h.

Member Function Documentation

◆ canWrap()

static bool canWrap ( const ic4::ImageBuffer buffer)
inlinestatic

Checks whether wrap can work on the passed image buffer.

Parameters
[in]bufferAn image buffer
Returns
true, if the contents of the image buffer can be wrapped in a HALCON HImage, otherwise false.
Remarks
Wrapping image buffer data is only supported for Mono8 and Mono16 image buffers that do not have horizontal padding.

◆ copy() [1/4]

static std::shared_ptr< ic4::ImageBuffer > copy ( const HalconCpp::HImage &  src,
ic4::Error err = ic4::Error::Default() 
)
inlinestatic

Copies the contents of a HALCON HImage into a new ic4::ImageBuffer.

Parameters
[in]srcA HALCON HImage
[out]errReference to an error handler. See Error Handling for details.
Returns
A new image buffer. If the function fails, nullptr is returned.
Remarks
The resulting image buffer's pixel format depends on the type of src:
  • If src is a 1-channel image of type byte, the pixel format for the returned image buffer is ic4::PixelFormat::Mono8.
  • If src is a 1-channel image of type uint2, the pixel format for the returned image buffer is ic4::PixelFormat::Mono16.
  • If src is a 3-channel image of type byte, the pixel format for the returned image buffer is ic4::PixelFormat::BGRa8.
  • If src is a 3-channel image of type uint2, the pixel format for the returned image buffer is ic4::PixelFormat::BGRa16.
  • Other image types are not supported.

◆ copy() [2/4]

static bool copy ( const HalconCpp::HImage &  src,
ic4::ImageBuffer dest,
ic4::Error err = ic4::Error::Default() 
)
inlinestatic

Copies the contents of a HALCON HImage into an ic4::ImageBuffer.

Parameters
[in]srcA HALCON HImage
[out]destA destination buffer to receive the image data
[out]errReference to an error handler. See Error Handling for details.
Returns
true on success, otherwise false.
Remarks
The image type of dest needs to match the dimensions and type of src.

◆ copy() [3/4]

static std::shared_ptr< ic4::ImageBuffer > copy ( const HalconCpp::HImage &  src,
std::shared_ptr< ic4::BufferPool pool,
ic4::Error err = ic4::Error::Default() 
)
inlinestatic

Copies the contents of a HALCON HImage into a new ic4::ImageBuffer.

Parameters
[in]srcA HALCON HImage
[in]poolA buffer pool to query the new image buffer from
[out]errReference to an error handler. See Error Handling for details.
Returns
A new image buffer. If the function fails, nullptr is returned.
Remarks
The resulting image buffer's pixel format depends on the type of src:
  • If src is a 1-channel image of type byte, the pixel format for the returned image buffer is ic4::PixelFormat::Mono8.
  • If src is a 1-channel image of type uint2, the pixel format for the returned image buffer is ic4::PixelFormat::Mono16.
  • If src is a 3-channel image of type byte, the pixel format for the returned image buffer is ic4::PixelFormat::BGRa8.
  • If src is a 3-channel image of type uint2, the pixel format for the returned image buffer is ic4::PixelFormat::BGRa16.
  • Other image types are not supported.

◆ copy() [4/4]

static HalconCpp::HImage copy ( const ic4::ImageBuffer buffer,
ic4::Error err = ic4::Error::Default() 
)
inlinestatic

Creates a copy of the image buffer and stores it in a HALCON HImage.

Parameters
[in]bufferAn image buffer
[out]errReference to an error handler. See Error Handling for details.
Returns
A HALCON HImage containing a copy of the image data from the passed image buffer.

◆ wrap()

static HalconCpp::HImage wrap ( const ic4::ImageBuffer buffer,
ic4::Error err = ic4::Error::Default() 
)
inlinestatic

Wraps the passed image buffer in an HALCON HImage.

Parameters
[in]bufferAn image buffer
[out]errReference to an error handler. See Error Handling for details.
Returns
A HALCON HImage using the image buffer's memory as pixel storage
Remarks
Wrapping image buffer data is only supported for Mono8 and Mono16 image buffers that do not have horizontal padding.
The program has to make sure that the image buffer is not released/requeued while the returned HImage is in use.