Skip to content

pylon/Result.h#

Low Level API: Definition of classes that contain grabbed data.

Namespaces#

Name
Pylon
Contains definitions of pylon types.

Classes#

Name
class Pylon::GrabResult
Low Level API: A grab result that combines the used image buffer and status information.
class Pylon::EventResult
Low Level API: An event result.

Defines#

Name
RESULT_H__
SIZE_MAX
BIT_PER_PIXEL(pixelType)
Retrieve the number of bits per pixel for a given pixel type.

Macros Documentation#

define RESULT_H__#

#define RESULT_H__ 

define SIZE_MAX#

#define SIZE_MAX UINT_MAX

define BIT_PER_PIXEL#

#define BIT_PER_PIXEL(
    pixelType
)
( ( (pixelType) >> 16 ) & 0xff )

Retrieve the number of bits per pixel for a given pixel type.

Source code#

//-----------------------------------------------------------------------------
//  Basler pylon SDK
//  Copyright (c) 2006-2022 Basler AG
//  http://www.baslerweb.com
//  Author:  Hartmut Nebelung
//-----------------------------------------------------------------------------
#pragma once

#ifndef RESULT_H__
#define RESULT_H__


#include <limits.h>
#include <memory.h> // for memset
#include <Base/GCTypes.h>
#include <Base/GCException.h>

#include <pylon/Platform.h>
#include <pylon/StreamGrabber.h>
#include <pylon/PixelType.h>
#include <pylon/PayloadType.h>
#include <pylon/ResultImage.h>

#pragma pack(push, PYLON_PACKING)

// Microsoft Visual Studio defines SIZE_MAX (see limits.h)
// But VS 2003 does not define SIZE_MAX. In this case, we have to define SIZE_MAX
// Because of this, the following lines must be AFTER #include limits.h
#ifndef SIZE_MAX
#define SIZE_MAX UINT_MAX
#endif

namespace Pylon
{
    // Forward declaration
    class CPylonDataContainer;
    class CPylonDataComponent;
    class GrabResult;
    typedef CGrabResultImageT<const GrabResult&> CGrabResultImageRef;

    enum EGrabStatus
    {
        GrabStatus_Undefined = -1,
        _UndefinedGrabStatus = GrabStatus_Undefined, // Consider using GrabStatus_Undefined instead.

        GrabStatus_Idle,                
        Idle = GrabStatus_Idle,         

        GrabStatus_Queued,              
        Queued = GrabStatus_Queued,     

        GrabStatus_Grabbed,             
        Grabbed = GrabStatus_Grabbed,   

        GrabStatus_Canceled,            
        Canceled = GrabStatus_Canceled, 

        GrabStatus_Failed,              
        Failed = GrabStatus_Failed      
    };

#define BIT_PER_PIXEL( pixelType ) ( ( (pixelType) >> 16 ) & 0xff )


    class PYLONBASE_API GrabResult
    {
    public:
        //
        GrabResult()
            : m_pContext( NULL )
            , m_hBuffer( NULL )
            , m_pBuffer( NULL )
            , m_BufferSize( 0 )
            , m_Status( GrabStatus_Undefined )
            , m_PayloadType( PayloadType_Undefined )
            , m_PixelType( PixelType_Undefined )
            , m_TimeStamp( 0 )
            , m_SizeX( -1 )
            , m_SizeY( -1 )
            , m_OffsetX( -1 )
            , m_OffsetY( -1 )
            , m_PaddingX( -1 )
            , m_PaddingY( -1 )
            , m_PayloadSize( (uint64_t) -1 )
            , m_ErrorCode( 0 )
            , m_ErrorDescription( "" )
            , m_BlockID( GC_UINT64_MAX )
        {
        }


        //
        ~GrabResult()
        {
        }


        bool Succeeded() const
        {
            return m_Status == GrabStatus_Grabbed;
        }


        StreamBufferHandle Handle() const
        {
            return m_hBuffer;
        }


        void* Buffer() const
        {
            return const_cast<void*>(m_pBuffer);
        }


        EGrabStatus Status() const
        {
            return m_Status;
        }


        const void* Context() const
        {
            return m_pContext;
        }


        EPayloadType GetPayloadType() const
        {
            return m_PayloadType;
        }


        EPixelType GetPixelType() const
        {
            return m_PixelType;
        }


        uint64_t GetTimeStamp() const
        {
            return m_TimeStamp;
        }


        int32_t GetSizeX() const
        {
            return m_SizeX;
        }


        int32_t GetSizeY() const
        {
            return m_SizeY;
        }


        int32_t GetOffsetX() const
        {
            return m_OffsetX;
        }


        int32_t GetOffsetY() const
        {
            return m_OffsetY;
        }


        int32_t GetPaddingX() const
        {
            return m_PaddingX;
        }


        int32_t GetPaddingY() const
        {
            return m_PaddingY;
        }


        int64_t GetPayloadSize() const
        {
            return m_PayloadSize;
        }


        size_t GetPayloadSize_t() const
        {
#if SIZE_MAX >= 0xffffffffffffffffULL
            return static_cast<size_t>(GetPayloadSize());
#else
            if (m_PayloadSize > SIZE_MAX)
            {
                throw OUT_OF_RANGE_EXCEPTION( "PayloadSize too big" );
            }
            return static_cast<size_t>(m_PayloadSize & SIZE_MAX);
#endif
        }


        String_t GetErrorDescription() const
        {
            return m_ErrorDescription;
        }


        uint32_t GetErrorCode() const
        {
            return m_ErrorCode;
        }


        CGrabResultImageRef GetImage() const
        {
            return CGrabResultImageRef( *this, false );
        }


        uint64_t GetBlockID() const
        {
            return m_BlockID;
        }


        CPylonDataContainer GetDataContainer() const;


        size_t GetDataComponentCount() const;


        CPylonDataComponent GetDataComponent( size_t index );


        size_t GetBufferSize() const
        {
            return m_BufferSize;
        }

    protected:
        const void* m_pContext;
        StreamBufferHandle m_hBuffer;
        const void* m_pBuffer;
        size_t m_BufferSize;

        EGrabStatus m_Status;
        EPayloadType m_PayloadType;
        EPixelType m_PixelType;
        uint64_t m_TimeStamp;
        int32_t m_SizeX;
        int32_t m_SizeY;
        int32_t m_OffsetX;
        int32_t m_OffsetY;
        int32_t m_PaddingX;
        int32_t m_PaddingY;
        uint64_t m_PayloadSize;
        uint32_t m_ErrorCode;
        String_t m_ErrorDescription;
        uint64_t m_BlockID;
    };


    class EventResult
    {
    public:
        //
        EventResult()
            : m_ReturnCode( 0 )
            , m_Message()
        {
            // prevent uninitialized member warning
            memset( Buffer, 0, sizeof( Buffer ) );
        }


        //
        ~EventResult()
        {
        }


        //
        bool Succeeded() const
        {
            return 0 == m_ReturnCode;
        }


        //
        String_t ErrorDescription() const
        {
            return m_Message;
        }


        //
        unsigned long ErrorCode() const
        {
            return m_ReturnCode;
        }

    protected:
        unsigned long m_ReturnCode;
        String_t m_Message;

    public:
        unsigned char Buffer[576];
    };

    typedef CGrabResultImageT<GrabResult> CGrabResultImage;
}

#pragma pack(pop)

#endif // RESULT_H__

Updated on 5 July 2022 at 15:30:01