IDS peak ICV v1.0.0
Loading...
Searching...
No Matches
Working with Images

Creating an image

The IDS peak ICV library enables image creation across all supported programming languages. Each language binding provides APIs tailored to the respective language environment, but consistent with the core image model. Depending on the programming language binding, images can be created using various methods to suit different application scenarios and integration requirements.

The following core methods for creating an image are available in all supported programming languages:

Using the image processing pipeline

Creates an image by processing raw camera data through the Image Processing Pipeline, transforming it into a ready-to-use image. This is typically used when interacting with a camera via the IDS peak AFL library.

  • C++
    // Initialize pipeline with default settings
    //
    // Get a buffer from IDS peak genericAPI
    std::shared_ptr<peak::core::Buffer> buffer = dataStream->WaitForFinishedBuffer(5'000);
    //
    // Process the image view constructed from an acquisition buffer
    peak::icv::Image result = pipeline.Process(buffer->ToImageView());

Converting an existing IDS peak IPL image

Converts an existing IDS peak IPL image into a IDS peak ICV image.

  • C++
    peak::ipl::Image IPLImage{ peak::ipl::PixelFormatName::Mono8, 640, 480 };
    peak::icv::Image image{ IPLImage };

Reading from a file

Creates an image by loading it from a supported file format.

From pixel format and size

Creates a blank image by specifying the pixel format and the image dimensions (width × height).

Creating from a raw buffer

Constructs an image object from a raw byte buffer. The buffer must contain binary image data in a format supported by the IDS peak ICV library.

Setting an image region

Each IDS peak ICV image includes a Region, which by default covers the entire image – all pixels are considered. If needed, you can set a custom region to process only part of the image.

The region can be of any shape, depending on the use case.

Additionally, the current region of an image can be queried programmatically.

  • C++
    // Set region of any shape
    peak::icv::experimental::Region region{ std::vector<peak::common::Point>{ { 1, 2 }, { 3, 4 } } };
    image.SetRegion(region);
    // Query region
    auto imageRegion = image.GetRegion();
    // Reset region to full size
    image.ResetRegion();

Handling of pixel formats

Pixel formats define how pixel data is stored and interpreted. The IDS peak ICV library supports various pixel formats which are described in detail in Pixel and Pixel Format Specifications.

Converting an image to a different pixel format

To convert an image from one pixel format to another, use the appropriate conversion functions provided by the library. Check the documentation for each function to verify format compatibility and any conversion limitations.

Getting detailed information about pixel formats

You can obtain detailed information about a specific pixel format, such as name, bit depth, and the minimum and maximum possible values for each channel. Understanding these details is essential for correctly interpreting and manipulating pixel data.

You can retrieve this information using the following methods:

  • C++
    // Create an object for the Mono8 pixel format
    // Output pixel format information
    std::cout << info.GetName() << std::endl; // Output: Mono8
    std::cout << info.GetStorageBitsPerPixel() << std::endl; // Output: 8
    std::cout << info.GetMaximumValuePerChannel() << std::endl; // Output: 255

By using these methods, you can better understand how pixel data is structured and make informed decisions about image processing and format conversions.

Accessing raw data

If a transfer from IDS peak ICV to a third-party library is needed, you can get a pointer to raw data:

  • C++
    const uint8_t* data = image.GetData();