GxCamera/GxCamera.cpp
GX_STATUS GxCamera::openDevice(const char* CameraSN)
{
    //return GX_STATUS_SUCCESS;
    GX_STATUS status = GX_STATUS_SUCCESS;
    uint32_t ui32DeviceNum = 0;
    g_pDeviceSN = const_cast<char*>(CameraSN);

    //Get device enumerated number
    status = GXUpdateDeviceList(&ui32DeviceNum, 1000);
    GX_VERIFY_EXIT(status);

    //If no device found, app exit<char*>(const char*);
    if(ui32DeviceNum <= 0)
    {
        printf("<No device found>\n");
        GXCloseLib();
        exit(status);
    }

    //Init OpenParam , Open device in exclusive mode by SN
    GX_OPEN_PARAM stOpenParam;
    stOpenParam.accessMode = GX_ACCESS_EXCLUSIVE;
    stOpenParam.openMode = GX_OPEN_SN;
    stOpenParam.pszContent = g_pDeviceSN;

    //Open device
    status = GXOpenDevice(&stOpenParam, &g_hDevice);
    GX_VERIFY_EXIT(status);


    //Get Device Info
    printf("***********************************************\n");
    //Get libary version
    printf("<Libary Version : %s>\n", GXGetLibVersion());
    size_t nSize = 0;
    //Get string length of Vendor name
    status = GXGetStringLength(g_hDevice, GX_STRING_DEVICE_VENDOR_NAME, &nSize);
    GX_VERIFY_EXIT(status);
    //Alloc memory for Vendor name
    char *pszVendorName = new char[nSize];
    //Get Vendor name
    status = GXGetString(g_hDevice, GX_STRING_DEVICE_VENDOR_NAME, pszVendorName, &nSize);
    if (status != GX_STATUS_SUCCESS)
    {
        delete[] pszVendorName;
        pszVendorName = NULL;
        GX_VERIFY_EXIT(status);
    }

    printf("<Vendor Name : %s>\n", pszVendorName);
    //Release memory for Vendor name
    delete[] pszVendorName;
    pszVendorName = NULL;

    //Get string length of Model name
    status = GXGetStringLength(g_hDevice, GX_STRING_DEVICE_MODEL_NAME, &nSize);
    GX_VERIFY_EXIT(status);
    //Alloc memory for Model name
    char *pszModelName = new char[nSize];
    //Get Model name
    status = GXGetString(g_hDevice, GX_STRING_DEVICE_MODEL_NAME, pszModelName, &nSize);
    if (status != GX_STATUS_SUCCESS)
    {
        delete[] pszModelName;
        pszModelName = NULL;
        GX_VERIFY_EXIT(status);
    }

    printf("<Model Name : %s>\n", pszModelName);
    //Release memory for Model name
    delete[] pszModelName;
    pszModelName = NULL;

    //Get string length of Serial number
    status = GXGetStringLength(g_hDevice, GX_STRING_DEVICE_SERIAL_NUMBER, &nSize);
    GX_VERIFY_EXIT(status);
    //Alloc memory for Serial number
    char *pszSerialNumber = new char[nSize];
    //Get Serial Number
    status = GXGetString(g_hDevice, GX_STRING_DEVICE_SERIAL_NUMBER, pszSerialNumber, &nSize);
    if (status != GX_STATUS_SUCCESS)
    {
        delete[] pszSerialNumber;
        pszSerialNumber = NULL;
        GX_VERIFY_EXIT(status);
    }

    printf("<Serial Number : %s>\n", pszSerialNumber);
    //Release memory for Serial number
    delete[] pszSerialNumber;
    pszSerialNumber = NULL;

    //Get string length of Device version
    status = GXGetStringLength(g_hDevice, GX_STRING_DEVICE_VERSION, &nSize);
    GX_VERIFY_EXIT(status);
    char *pszDeviceVersion = new char[nSize];
    //Get Device Version
    status = GXGetString(g_hDevice, GX_STRING_DEVICE_VERSION, pszDeviceVersion, &nSize);
    if (status != GX_STATUS_SUCCESS)
    {
        delete[] pszDeviceVersion;
        pszDeviceVersion = NULL;
        GX_VERIFY_EXIT(status);
    }
    printf("<Device Version : %s>\n", pszDeviceVersion);

    //Get Device Maxium width * height
    int64_t width, height;
    GXGetInt(g_hDevice, GX_INT_WIDTH_MAX, &width);
    GXGetInt(g_hDevice, GX_INT_HEIGHT_MAX, &height);
    printf("<Camera maxImage : %d * %d>\n", width, height);

    //Release memory for Device version
    delete[] pszDeviceVersion;
    pszDeviceVersion = NULL;
    printf("***********************************************\n");

    //Get the type of Bayer conversion. whether is a color camera.

    status = GXIsImplemented(g_hDevice, GX_ENUM_PIXEL_COLOR_FILTER, &g_bColorFilter);
    GX_VERIFY_EXIT(status);

    //This app only support color cameras
    if (!g_bColorFilter)
    {
        printf("<This app only support color cameras! App Exit!>\n");
        GXCloseDevice(g_hDevice);
        g_hDevice = NULL;
        GXCloseLib();
        exit(0);
    }
    else
    {
        status = GXGetEnum(g_hDevice, GX_ENUM_PIXEL_COLOR_FILTER, &g_i64ColorFilter);
        GX_VERIFY_EXIT(status);
    }
    return GX_STATUS_SUCCESS;
}
/// Open device and display device information
Open device and display device information
Open device and display device information
GX_STATUS GxCamera::openDevice(const char* CameraSN)
{
    GX_STATUS status = GX_STATUS_SUCCESS;
    uint32_t ui32DeviceNum = 0;
    g_pDeviceSN = const_cast<char*>(CameraSN);
    status = GXUpdateDeviceList(&ui32DeviceNum, 1000);
    GX_VERIFY_EXIT(status);
    if(ui32DeviceNum <= 0)
    {
        printf("<No device found>\n");
        GXCloseLib();
        exit(status);
    }
    GX_OPEN_PARAM stOpenParam;
    stOpenParam.accessMode = GX_ACCESS_EXCLUSIVE;
    stOpenParam.openMode = GX_OPEN_SN;
    stOpenParam.pszContent = g_pDeviceSN;
    status = GXOpenDevice(&stOpenParam, &g_hDevice);
    GX_VERIFY_EXIT(status);
    printf("***********************************************\n");
    printf("<Libary Version : %s>\n", GXGetLibVersion());
    size_t nSize = 0;
    status = GXGetStringLength(g_hDevice, GX_STRING_DEVICE_VENDOR_NAME, &nSize);
    GX_VERIFY_EXIT(status);
    char *pszVendorName = new char[nSize];
    status = GXGetString(g_hDevice, GX_STRING_DEVICE_VENDOR_NAME, pszVendorName, &nSize);
    if (status != GX_STATUS_SUCCESS)
    {
        delete[] pszVendorName;
        pszVendorName = NULL;
        GX_VERIFY_EXIT(status);
    }
    printf("<Vendor Name : %s>\n", pszVendorName);
    delete[] pszVendorName;
    pszVendorName = NULL;
    status = GXGetStringLength(g_hDevice, GX_STRING_DEVICE_MODEL_NAME, &nSize);
    GX_VERIFY_EXIT(status);
    char *pszModelName = new char[nSize];
    status = GXGetString(g_hDevice, GX_STRING_DEVICE_MODEL_NAME, pszModelName, &nSize);
    if (status != GX_STATUS_SUCCESS)
    {
        delete[] pszModelName;
        pszModelName = NULL;
        GX_VERIFY_EXIT(status);
    }
    printf("<Model Name : %s>\n", pszModelName);
    delete[] pszModelName;
    pszModelName = NULL;
    status = GXGetStringLength(g_hDevice, GX_STRING_DEVICE_SERIAL_NUMBER, &nSize);
    GX_VERIFY_EXIT(status);
    char *pszSerialNumber = new char[nSize];
    status = GXGetString(g_hDevice, GX_STRING_DEVICE_SERIAL_NUMBER, pszSerialNumber, &nSize);
    if (status != GX_STATUS_SUCCESS)
    {
        delete[] pszSerialNumber;
        pszSerialNumber = NULL;
        GX_VERIFY_EXIT(status);
    }
    printf("<Serial Number : %s>\n", pszSerialNumber);
    delete[] pszSerialNumber;
    pszSerialNumber = NULL;
    status = GXGetStringLength(g_hDevice, GX_STRING_DEVICE_VERSION, &nSize);
    GX_VERIFY_EXIT(status);
    char *pszDeviceVersion = new char[nSize];
    status = GXGetString(g_hDevice, GX_STRING_DEVICE_VERSION, pszDeviceVersion, &nSize);
    if (status != GX_STATUS_SUCCESS)
    {
        delete[] pszDeviceVersion;
        pszDeviceVersion = NULL;
        GX_VERIFY_EXIT(status);
    }
    printf("<Device Version : %s>\n", pszDeviceVersion);
    int64_t width, height;
    GXGetInt(g_hDevice, GX_INT_WIDTH_MAX, &width);
    GXGetInt(g_hDevice, GX_INT_HEIGHT_MAX, &height);
    printf("<Camera maxImage : %d * %d>\n", width, height);
    delete[] pszDeviceVersion;
    pszDeviceVersion = NULL;
    printf("***********************************************\n");
    status = GXIsImplemented(g_hDevice, GX_ENUM_PIXEL_COLOR_FILTER, &g_bColorFilter);
    GX_VERIFY_EXIT(status);
    if (!g_bColorFilter)
    {
        printf("<This app only support color cameras! App Exit!>\n");
        GXCloseDevice(g_hDevice);
        g_hDevice = NULL;
        GXCloseLib();
        exit(0);
    }
    else
    {
        status = GXGetEnum(g_hDevice, GX_ENUM_PIXEL_COLOR_FILTER, &g_i64ColorFilter);
        GX_VERIFY_EXIT(status);
    }
    return GX_STATUS_SUCCESS;
}
GX_STATUS GxCamera :: openDevice ( const char * CameraSN ) { GX_STATUS status = GX_STATUS_SUCCESS ; uint32_t ui32DeviceNum = 0 ; g_pDeviceSN = const_cast < char * > ( CameraSN ) ; status = GXUpdateDeviceList ( & ui32DeviceNum , 1000 ) ; GX_VERIFY_EXIT ( status ) ; if ( ui32DeviceNum <= 0 ) { printf ( " \n " ) ; GXCloseLib ( ) ; exit ( status ) ; } GX_OPEN_PARAM stOpenParam ; stOpenParam . accessMode = GX_ACCESS_EXCLUSIVE ; stOpenParam . openMode = GX_OPEN_SN ; stOpenParam . pszContent = g_pDeviceSN ; status = GXOpenDevice ( & stOpenParam , & g_hDevice ) ; GX_VERIFY_EXIT ( status ) ; printf ( " \n " ) ; printf ( " \n " , GXGetLibVersion ( ) ) ; size_t nSize = 0 ; status = GXGetStringLength ( g_hDevice , GX_STRING_DEVICE_VENDOR_NAME , & nSize ) ; GX_VERIFY_EXIT ( status ) ; char * pszVendorName = new char [ nSize ] ; status = GXGetString ( g_hDevice , GX_STRING_DEVICE_VENDOR_NAME , pszVendorName , & nSize ) ; if ( status != GX_STATUS_SUCCESS ) { delete [ ] pszVendorName ; pszVendorName = NULL ; GX_VERIFY_EXIT ( status ) ; } printf ( " \n " , pszVendorName ) ; delete [ ] pszVendorName ; pszVendorName = NULL ; status = GXGetStringLength ( g_hDevice , GX_STRING_DEVICE_MODEL_NAME , & nSize ) ; GX_VERIFY_EXIT ( status ) ; char * pszModelName = new char [ nSize ] ; status = GXGetString ( g_hDevice , GX_STRING_DEVICE_MODEL_NAME , pszModelName , & nSize ) ; if ( status != GX_STATUS_SUCCESS ) { delete [ ] pszModelName ; pszModelName = NULL ; GX_VERIFY_EXIT ( status ) ; } printf ( " \n " , pszModelName ) ; delete [ ] pszModelName ; pszModelName = NULL ; status = GXGetStringLength ( g_hDevice , GX_STRING_DEVICE_SERIAL_NUMBER , & nSize ) ; GX_VERIFY_EXIT ( status ) ; char * pszSerialNumber = new char [ nSize ] ; status = GXGetString ( g_hDevice , GX_STRING_DEVICE_SERIAL_NUMBER , pszSerialNumber , & nSize ) ; if ( status != GX_STATUS_SUCCESS ) { delete [ ] pszSerialNumber ; pszSerialNumber = NULL ; GX_VERIFY_EXIT ( status ) ; } printf ( " \n " , pszSerialNumber ) ; delete [ ] pszSerialNumber ; pszSerialNumber = NULL ; status = GXGetStringLength ( g_hDevice , GX_STRING_DEVICE_VERSION , & nSize ) ; GX_VERIFY_EXIT ( status ) ; char * pszDeviceVersion = new char [ nSize ] ; status = GXGetString ( g_hDevice , GX_STRING_DEVICE_VERSION , pszDeviceVersion , & nSize ) ; if ( status != GX_STATUS_SUCCESS ) { delete [ ] pszDeviceVersion ; pszDeviceVersion = NULL ; GX_VERIFY_EXIT ( status ) ; } printf ( " \n " , pszDeviceVersion ) ; int64_t width , height ; GXGetInt ( g_hDevice , GX_INT_WIDTH_MAX , & width ) ; GXGetInt ( g_hDevice , GX_INT_HEIGHT_MAX , & height ) ; printf ( " \n " , width , height ) ; delete [ ] pszDeviceVersion ; pszDeviceVersion = NULL ; printf ( " \n " ) ; status = GXIsImplemented ( g_hDevice , GX_ENUM_PIXEL_COLOR_FILTER , & g_bColorFilter ) ; GX_VERIFY_EXIT ( status ) ; if ( ! g_bColorFilter ) { printf ( " \n " ) ; GXCloseDevice ( g_hDevice ) ; g_hDevice = NULL ; GXCloseLib ( ) ; exit ( 0 ) ; } else { status = GXGetEnum ( g_hDevice , GX_ENUM_PIXEL_COLOR_FILTER , & g_i64ColorFilter ) ; GX_VERIFY_EXIT ( status ) ; } return GX_STATUS_SUCCESS ; }
Open device and display device information
Open device and display device information
//return GX_STATUS_SUCCESS; //Get device enumerated number //If no device found, app exit<char*>(const char*); //Init OpenParam , Open device in exclusive mode by SN //Open device //Get Device Info //Get libary version //Get string length of Vendor name //Alloc memory for Vendor name //Get Vendor name //Release memory for Vendor name //Get string length of Model name //Alloc memory for Model name //Get Model name //Release memory for Model name //Get string length of Serial number //Alloc memory for Serial number //Get Serial Number //Release memory for Serial number //Get string length of Device version //Get Device Version //Get Device Maxium width * height //Release memory for Device version //Get the type of Bayer conversion. whether is a color camera. //This app only support color cameras