前 言

Preface

Thank you for purchasing our product. If there is any question or request, please feel free to contact us. This manual may contain several technically incorrect places or printing errors, and the content is subject to change without notice. The updates will be added into the new version of this manual, and we will readily improve or update the product or procedure described in the manual.


Machine Vision Camera SDK Programming Manual

Overview

Machine vision camera SDK is compatible with standard protocols such as GigEVision, 1394, USB and CameraLink (GigEVision and U3Vision are currently supported). This SDK can be used for connection and control of machine vision cameras, including getting real-time image data and parameter configuration. Two sets of interfaces are provided, supporting C and C++.

C++ type interfaces include 3 categories, as shown below:

1) Transport layer factory (TIFactory): get single factory example through this category, and then enumerate online devices, create and destroy devices.

2) Device control (IMvDevices): control specified devices through this category, including start/stop devices, and get images.

3) GenApi: camera interface of GenICam, get and configure camera parameters through this module. The document only introduces basic GenApi interfaces, for more function interfaces of GenApi module, see GenICam documents.

To simplify the SDK calling procedure and upper layer software development, C interfaces are provided, including:

1) General function interfaces, including creating handle, connecting device, image acquisition and display and parameter configuration.

2) XML interfaces, in which GenICam is packaged, realizing resolving XML, getting and configuring all camera parameter nodes.

3) Special interfaces for GigEVision camera, including forced IP, setting network driving mode.

The Windows and Linux versions for SDK should be loaded and used in appropriate environment, while most interfaces are same, the differences will be noted in the interface description.


SDK Supported Systems

32-bit Windows:
  • Windows 10, Windows 8, Windows 7, Windows XP
  • Support drivers

    • 64-bit Windows:
  • Windows 10, Windows 8, Windows 7
  • Support drivers

    • 32/64-bit Linux:
  • Ubuntu 12.04 and above, Redhat, Centos, Fedora, kernel version 2.6 and above, gcc/g++ version 4.4.7 and above
  • For U3Vision camera, kernel version 3.0 and above is recommended
  • 64-bit Ubuntu 12.04 and above, Redhat 6 and above, CentOS 6 and above, support drivers


更新记录

Machine Vision Camera SDK Programming Manual

Update history

Version | Content
V2.1.0.1 Windows Version | 1. Added interface of creating handle without log: MV_CC_CreateHandleWithoutLog.
2. Added interface of camera heartbeat timeout configuration: MV_CC_GetHeartBeatTimeout, MV_CC_SetHeartBeatTimeout.
3. Added interface of GVCP command configuration timeout: MV_GIGE_SetGvcpTimeout.
4. Added picture data format conversion interface: MV_CC_SaveImage, MV_CC_SaveImageEx (supporting configuration of JPEG encoding quality).
5. Added camera horizontal scanning frequency interface: MV_CC_GetAcquisitionLineRate, MV_CC_SetAcquisitionLineRate.
6. Added interface of camera burst mode frame count configuration: MV_CC_GetBurstFrameCount, MV_CC_SetBurstFrameCount.
7. Added extension interface of getting image data:
1) C interface: MV_CC_GetOneFrameEx, MV_CC_RegisterImageCallBackEx.
2) C++ interface: MvCamCtrl::CMvGigEDevice::GetOneFrameEx, MvCamCtrl::CMvGigEDevice::RegisterImageCallBackEx
8. Added interface of configuring resending packet properties: MV_GIGE_SetResend.
9. Added interface of registering event callback:
1) C Interface: MV_CC_RegisterEventCallBack.
2) C++ Interface: MvCamCtrl::CMvGigEDevice::RegisterEventCallBack.
10. Added general configuration interface:
1) int type: MV_CC_GetIntValue, MV_CC_SetIntValue.
2) string type: MV_CC_GetStringValue, MV_CC_SetStringValue.
3) bool type: MV_CC_GetBoolValue, MV_CC_SetBoolValue.
4) float type: MV_CC_GetFloatValue, MV_CC_SetFloatValue.
5) Enum type: MV_CC_GetEnumValue, MV_CC_GetEnumValue.
6) Command type: MV_CC_SetCommandValue.
11.Complex SpecialInfo of MV_CC_DEVICE_INFO(device information) added structure parameter stUsb3VInfo (USB device information).
V2.0.0.4 Linux version | 1. Added C++ Interface of getting version information: MvCamCtrl::CTlFactory::GetSDKVersion.
V2.0.0.3 Windows version | 1. Added interface of registering image data callback: MV_CC_RegisterImageCallBack.
2. Added device user ID configuration interface: MV_CC_GetDeviceUserID, MV_CC_SetDeviceUserID.
3. Added interface of setting number of cache nodes of internal images: MV_CC_SetImageNodeNum.
4. Added white balance parameter configuration interface: MV_CC_GetBalanceWhiteAuto, MV_CC_SetBalanceWhiteAuto, MV_CC_GetBalanceRatioRed, MV_CC_SetBalanceRatioRed, MV_CC_GetBalanceRatioGreen, MV_CC_SetBalanceRatioGreen, MV_CC_GetBalanceRatioBlue, MV_CC_SetBalanceRatioBlue.
5. Added Gamma parameter configuration interface: MV_CC_GetGammaSelector, MV_CC_SetGammaSelector, MV_CC_GetGamma, MV_CC_SetGamma.
6. Added color parameter configuration interface: MV_CC_GetSharpness, MV_CC_SetSharpness, MV_CC_GetHue, MV_CC_SetHue, MV_CC_GetSaturation, MV_CC_SetSaturation.
7. Added trigger parameter configuration interface: MV_CC_GetTriggerSource, MV_CC_SetTriggerSource, MV_CC_GetTriggerDelay, MV_CC_SetTriggerDelay.
8. Added software trigger control interface: MV_CC_TriggerSoftwareExecute.
9. Added GigEVision device C++ interface:
MvCamCtrl::CMvGigEDevice::RegisterImageCallBack,
MvCamCtrl::CMvGigEDevice::GetAllMatchInfo,
MvCamCtrl::CMvGigEDevice::IsDriverWorking,
MvCamCtrl::CMvGigEDevice::SetThrowAbnormalImage,
MvCamCtrl::CMvGigEDevice::SetImageNodeNum.
10. Added U3Vision device C++ interface:
MvCamCtrl::CMvUsb3VDevice::RegisterImageCallBack,
MvCamCtrl::CMvUsb3VDevice::GetAllMatchInfo,
MvCamCtrl::CMvUsb3VDevice::SetImageNodeNum.
11. Edit interface return value description, including macro definition, value and description.
V2.0.0.1 Windows version | 1. Added C interface implementation, including getting SDK version information, device connection, image acquisition and display, parameter configuration, upgrade, register R/W, XML resolving.
2. Added support for U3V devices.
3. Added C++ Interface:
MvCamCtrl::CMvGigEDevice::RegisterExceptionCallBack,
MvCamCtrl::CMvGigEDevice::SetAcquisitionMode,
MvCamCtrl::CMvGigEDevice::LocalUpgrade,
MvCamCtrl::CMvGigEDevice::GetUpgradeProcess,
MvCamCtrl::CMvGigEDevice::GetOptimalPacketSize,
MvCamCtrl::CMvGigEDevice::Display,
MvCamCtrl::CMvGigEDevice::SetNetTransMode,
MvCamCtrl::CMvGigEDevice::ReadMemory,
MvCamCtrl::CMvGigEDevice::WriteMemory.
4. MV_CC_GetSDKVision interface name changed to MV_CC_GetSDKVersion(get SDK version).
5. Added error codes: 0x800000A1-0x800000A5, 0x800000ff, 0x80000210-0x80000213, 0x80000301-0x80000304.
V1.0.0.1 Windows version | 1. C++ interface implementation, including types of transport layer factory, device control and basic GenApi interface.


Device Connection Interface Procedure

Before Operating the device to realize the functions of image acquisition, parameter configuration and so on, you need to connect the device (open the device), see the above picture for the detailed procedure.

Example Code

#include "MvCameraControl.h"
void main()
{
    int nRet = -1;
    void*  m_handle = NULL;

    //Enumerate all the corresponding devices of the specified transport protocols within the subnet.
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the searched first online device, create a device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect the device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }

    //...Other processing method

    //Close the device, release the resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy the handle, release the resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}


Image Acquisition and Display Interface Procedure

After connecting the device, you can set the acquisition mode, triggering mode, image parameters and so on. And then start the acquisition, get image data or display the acquired image.

  • Set acquisition mode, interfaces：MV_CC_GetAcquisitionMode, MV_CC_SetAcquisitionMode, you can set single frame mode, multiple frames mode and continuous acquisition mode.
  • Set triggering parameters:
    1) Get and set camera triggering mode via MV_CC_GetTriggerMode, MV_CC_SetTriggerMode
    2) If the triggering mode is enabled, you need to set the triggering resource (MV_CC_GetTriggerSource、MV_CC_SetTriggerSource), the camera triggering resource includes hardware trigger and software trigger.
    3) Get and set the triggering delay time of corresponding cameras via MV_CC_GetTriggerDelay, MV_CCSetTriggerDelay.
    4) After setting software trigger as camera triggering source, you need to call MV_CC_TriggerSoftwareExecute to trigger the capture; but for hardware trigger mode, you can trigger the capture via device local hardware input.
  • Set image parameters, including image width/height, pixel format, frame rate, AIO offset, gain, exposure mode, exposure value, brightness, sharpness, saturation, grayscale, white balance, Gamma value and so on, see the related interfaces below: MV_CC_GetImageInfo, MV_CC_GetWidth, MV_CC_SetWidth, MV_CC_GetHeight, MV_CC_SetHeight, MV_CC_GetFrameRate, MV_CC_SetFrameRate, MV_CC_GetPixelFormat, MV_CC_SetPixelFormat. See more interfaces in the "Image Parameter Configuration" node of "C Interface Definition".
  • Acquire image data:
    1) There are two image data acquisition modes, and these two modes cannot be reused:
    Mode1：Call MV_CC_RegisterImageCallBack to set image data callback function, and then call MV_CC_StartGrabbing to start acquiring, the acquired image data can be gotten from the callback function.
    Mode2：Call MV_CC_StartGrabbing to start acquiring, and then circularly call MV_CC_GetOneFramein the application layer to get the frame data of the specified pixel format. When getting the frame data, the application program should control the frequency of calling this interface according to the frame rate.
    2) Before starting the acquisition, you can call MV_CC_SetImageNodeNum to set the cache node number of the SDK internal image. When the acquired SDK internal image number exceeds this node number, the earliest image data will be discarded automatically.
  • Display image: Start the acquisition via the interface MV_CC_StartGrabbing, and then call MV_CC_Display to display with the in-coming window handle.
  • When you need to stop acquisition or stop displaying the image, call MV_CC_StopGrabbing to release the resource.

Example Code

#include "MvCameraControl.h"

#define MAX_BUF_SIZE    (1920*1080*3)

void __stdcall ImageCallBack(unsigned char * pData, MV_FRAME_OUT_INFO* pFrameInfo, void* pUser)
{
    if (pFrameInfo)
    {
        // Add the current system time when outputting
        char   szInfo[128] = {0};
        SYSTEMTIME sys;
        GetLocalTime( &sys );
        sprintf_s(szInfo, 128, "[%d-%02d-%02d %02d:%02d:%02d:%04d] : GetOneFrame succeed, width[%d], height[%d]", sys.wYear, sys.wMonth,
            sys.wDay, sys.wHour, sys.wMinute, sys.wSecond, sys.wMilliseconds, pFrameInfo->nWidth, pFrameInfo->nHeight);

        printf("%s\n", szInfo);
    }
}

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all the corresponding devices of the specified transport protocols in the subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the searched first online device, create a device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Register the data callback function, get the acquired image data in the callback function
    nRet = MV_CC_RegisterImageCallBack(handle, ImageCallBack, NULL);
    if (MV_OK != nRet)
    {
        printf("error: RegisterImageCallBack fail [%x]\n", nRet);
        return;
    }

    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    //Connect the device
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }

    //Set device acquisition mode
    unsigned int enMode = 2; //Continuous acquisition mode
    nRet = MV_CC_SetAcquisitionMode(m_handle, enMode);
    if (MV_OK != nRet)
    {
        printf("error: SetAcquisitionMode fail [%x]\n", nRet);
        return;
    }

    //Get the height information of camera image
    MVCC_INTVALUE struIntValue = {0};
    nRet = MV_CC_GetHeight(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetHeight fail [%x]\n", nRet);
        return;
    }

    //Get the width information of camera image
    MVCC_INTVALUE struIntValue = {0};
    nRet = MV_CC_GetWidth(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetWidth fail [%x]\n", nRet);
        return;
    }

    //...Other processing method

    //Start acquiring image
    nRet = MV_CC_StartGrabbing(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing fail [%x]\n", nRet);
        return;
    }

    //Capture a frame picture
    unsigned char*  g_pFrameBuf = NULL;
    g_pFrameBuf = (unsigned char*)malloc(MAX_BUF_SIZE);

    MV_FRAME_OUT_INFO stInfo;
    memset(&stInfo, 0, sizeof(MV_FRAME_OUT_INFO));

    nRet = MV_CC_GetOneFrame(m_handle,g_pFrameBuf, MAX_BUF_SIZE, &stInfo);
    if (MV_OK != nRet)
    {
        printf("error: GetOneFrame fail [%x]\n", nRet);
        return;
    }

    //...Other processing method

    //Stop acquiring image
    nRet = MV_CC_StopGrabbing(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: StopGrabbing fail [%x]\n", nRet);
        return;
    }

    //Close the device, release the resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy the handle, release the resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;


XML Interface Procedure

Adopt the GenApi module to set the camera parameters with GigEVision transport protocol, get and set the device parameters via XML text mode. The SDK can parse XML and get all the camera parameter nodes, and it also contains the APIs for setting node property.

Example Code

#include "MvCameraControl.h"

//Property update callback function
void __stdcall MyCbFunc(MV_XML_InterfaceType enType, void* pstFeature, MV_XML_NODES_LIST* pstNodesList, void* pUser)
{
    for (int i = 0; i < pstNodesList->nNodeNum; i++)
    {
        MV_XML_InterfaceType enType = pstNodesList->stNodes[i].enType;
        printf("UpdateCallBack: Interface type [%d]\n", enType);
    }
}

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all the corresponding devices of the specified transport protocols in the subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the searched first online device, create a device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Callback function of registered node property update
    nRet = MV_XML_RegisterUpdateCallBack(m_handle, MyCbFunc, NULL);
    if (MV_OK != nRet)
    {
        printf("error: RegisterUpdateCallBack fail [%x]\n", nRet);
        return;
    }

    //Connect the device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...Other processing method

    //Get XML root node
    MV_XML_NODE_FEATURE stRootNode;
    memset(&stRootNode, 0, sizeof(MV_XML_NODE_FEATURE));
    nRet = MV_XML_GetRootNode(handle, &stRootNode);
    if (MV_OK != nRet)
    {
        printf("error: GetRootNode fail [%x]\n", nRet);
        return;
    }

    //Get detailed information of node
    MV_XML_NODE_FEATURE stNode;
    memset(&stNode, 0, sizeof(MV_XML_NODE_FEATURE));
    stNode.enType = IFT_IInteger;
    strcpy(stNode.strName, "Width");

    MV_XML_FEATURE_Integer stFeatureInteger;
    memset(&stFeatureInteger, 0, sizeof(MV_XML_FEATURE_Integer));

    nRet = MV_XML_GetNodeFeature(m_handle, &stNode, &stFeatureInteger);
    if (MV_OK != nRet)
    {
        printf("error: GetNodeFeature fail [%x]\n", nRet);
        return;
    }

    //Set node attribute value
    enType = IFT_IInteger;
    stFeatureInteger.enVisivility = 0; //Always visible
    nRet = MV_XML_UpdateNodeFeature(m_handle, enType, &stFeatureInteger);
    if (MV_OK != nRet)
    {
        printf("error: UpdateNodeFeature fail [%x]\n", nRet);
        return;
    }

    //...Other processing method

    //Close the device, release the resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy the handle, release the resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;


Transport Layer Factory Interface Procedure

Before connecting the device and operating the device to realize the functions of streaming and parameter configuration, you need to get factory singleton by using transport layer factory and create device instance. The above picture shows the detailed procedure.

Example Code

#include "TlFactory.h"
#include "CameraParams.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get factory singleton
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Call the interface in this instance
    unsigned int nSupportedTls = tlFactory.EnumerateTls();
    if (MV_GIGE_DEVICE == (nSupportedTls & MV_GIGE_DEVICE))
    {
        //Support GigE Vision transport protocol, the following operation is to operate the devices supported by this protocol.
        // Enumerate all the GigE devices within the subnet, return the device information list
        MV_CC_DEVICE_INFO_LIST stDevList;
        memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

        nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
        if (MV_OK != nRet)
        {
            printf("error: EnumDevices [%x]\n", nRet);
            return;
        }

        int i = 0;
        if (stDevList.nDeviceNum == 0)
        {
            printf("no camera found\n");
            Sleep(100000000);
        }
        else
        {
            for (int n = 0; n < stDevList.nDeviceNum; n++)
            {
                printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
            }
            printf("select one：");
            scanf("%d", &i);
            if (i < 0 || i >= stDevList.nDeviceNum)
            {
                printf("error : input\n");
                Sleep(10000000);
            }
        }

        // Select the searched first online device, and determine whether the device is accessible
        if(!tlFactory.IsDeviceAccessible(*(stDevList.pDeviceInfo[i])))
        {
            printf("error: IsDeviceAccessible\n");
            break;
        }

        // Select the first searched online device, and create device instance
        int i=0;
        IMvDevice* MyDevice = tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i]));

        if (NULL == MyDevice)
        {
            printf("error: CreateDevice\n");
            break;
        }

        //...Other device operations

        // Destory the device from the factory
        nRet = tlFactory.DestroyDevice(MyDevice);
        if (MV_OK != nRet)
        {
            printf("error: DestroyDevice fail [%x]\n", nRet);


Device Control Interface Procedure

After getting factory singleton by using the transport layer factory, you can connect the device via device control interface to get the device information and acquire the image data. This procedure and example code only take the GigEVision device as an example, and the adopted interface is CMvGigEDevice. For U3Vision device, the realization method is the same, and the adopted device control interface is CMvUsb3VDevice.

  • Acquire image data: Start the acquisition via the interface MvCamCtrl::CMvGigEDevice::StartGrabbing, and then circularly call MvCamCtrl::CMvGigEDevice::GetOneFrame to get the frame data of specified pixel format (support PixelType_Mono8 type). When getting the frame data, the upper-level application program should control the frequency of calling this API according to the frame rate. When the acquisition is stopped, call MvCamCtrl::CMvGigEDevice::StopGrabbing.

Example Code

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

#define MAX_BUF_SIZE    (1920*1080*3)

void main()
{
    int nRet = -1;

    // Get factory singleton
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices in the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the searched first online device, create a device instance
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open the device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    // Start image acquisition
    nRet = MyDevice->StartGrabbing();
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing [%x]\n", nRet);
        break;
    }

    unsigned int    nTestFrameSize = 0;
    unsigned char*  g_pFrameBuf = NULL;
    g_pFrameBuf = (unsigned char*)malloc(MAX_BUF_SIZE);

    MV_FRAME_OUT_INFO stInfo;
    memset(&stInfo, 0, sizeof(MV_FRAME_OUT_INFO));

    MV_NETTRANS_INFO stNetTransInfo = {0};

    // The upper-level application program needs to control the frequency of calling this interface according to the frame rate.
    // This code is only for reference, so creating another thread for image frame acquisition and handling is recommended in practical application.
    while(1)
    {
        if (nTestFrameSize > 99)
        {
            break;
        }
        nRet = MyDevice->GetOneFrame(g_pFrameBuf, MAX_BUF_SIZE, &stInfo);
        if (MV_OK != nRet)
        {
            Sleep(10);
        }
        else
        {
            //...Process the image data

            // Get network transport information
            if ((nTestFrameSize % 10) == 0)
            {
                nRet = MyDevice->GetNetTransInfo(&stNetTransInfo);
                printf("GetDataSize [%I64d], nRet[%x]\n", stNetTransInfo.nReviceDataSize, nRet);
            }

            nTestFrameSize++;
        }
    }

    // Stop image acquisition
    nRet = MyDevice->StopGrabbing();
    if (MV_OK != nRet)
    {
         printf("error: StopGrabbing fail [%x]\n", nRet);
    }

    // Close the device
    nRet = MyDevice->Close();
    if (MV_OK != nRet)
    {
        printf("error: Close fail [%x]\n", nRet);
    }

    // Destroy the device from the factory
    nRet = tlFactory.DestroyDevice(MyDevice);
    if (MV_OK != nRet)
    {
        printf("error: DestroyDevice fail [%x]\n", nRet);


Parameter Configuration Interface Procedure

Adopt GenApi module to realize the parameter configuration of machine vision camera (contain GigE, U3V, etc.), get and set the device parameters via XML text format. This document only introduces the basic interfaces, please refer to the GenICam standard document for more interfaces of GenApi module. This procedure and example code only take the GigEVision device as an example, and the adopted interface is CMvGigEDevice. For U3Vision device, the realization method is the same, and the adopted device control interface is CMvUsb3VDevice.

  • Get the transport layer proxy via MvCamCtrl::CMvGigEDevice::GetTlProxy.
  • Export the XML file from the device via MvCamCtrl::CMvGigEDevice::GetGenICamXML of device control, get the transport layer proxy via MvCamCtrl::CMvGigEDevice::GetTlProxy.
  • Use the GenApi::CNodeMapRef::_LoadXMLFromFile of GenApi module to load the XML file, and then use the GenApi::CNodeMapRef::_Connect of GenApi module to connect the device, and then read the node from the XML file via GenApi::CNodeMapRef::_GetNode, get and set the node name via GenApi::CNodeMapRef::GetValue and GenApi::CNodeMapRef::SetValue.

Example Code

#include
#include "TlFactory.h"
#include "MvErrorDefine.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
#include "NodeMapRef.h"
#include "IPort.h"
#include "GenApi.h"

using namespace MvCamCtrl;
using namespace GenApi;

#define MAX_XML_SIZE    (1024 * 1024 * 1)
CNodeMapRef* g_pNodeMapRef = NULL;

int InitGenICam(CMvGigEDevice * pMvGigEDevice)
{
    if (NULL == pMvGigEDevice)
    {
        return -1;
    }

    int             nRet            = MV_OK;          //Return value
    unsigned int    nXMLFileSize    = MAX_XML_SIZE;   //XML file size
    unsigned char*  pXMLFileBuf     = NULL;           //XML cache address
    unsigned int    nDataLen        = 0;              //The actual data length of XML file, return value

    // 1.malloc xml buffer
    if (NULL == pXMLFileBuf)
    {
        pXMLFileBuf = (unsigned char*)malloc(MAX_XML_SIZE);
        if (NULL == pXMLFileBuf)
        {
            printf("malloc fail\n");
            return -1;
        }
    }

    // 2.Get XML file from the device
    nRet = pMvGigEDevice->GetGenICamXML(pXMLFileBuf , nXMLFileSize , &nDataLen);
    if (MV_OK != nRet)
    {
        printf("GetGenICamXML fail, error code[%x]\n", nRet);
        return -1;
    }

    // 3.Save XML data as a file
    FILE* pXmlFile = fopen("testdevice.xml" , "wb+");
    if (NULL == pXmlFile)
    {
        return 0;
    }
    fwrite(pXMLFileBuf , 1 , nDataLen , pXmlFile);
    fclose(pXmlFile);
    pXmlFile = NULL;

    if (pXMLFileBuf)
    {
        free(pXMLFileBuf);
        pXMLFileBuf = NULL;
    }

    // 4. Get transport layer proxy used by GenICam
    TlProxy pTlProxy = pMvGigEDevice->GetTlProxy();
    if (NULL == pTlProxy)
    {
        printf("%s\n" , "Failed to Get transport layer!");
        return 0;
    }

    // use try...catch, in case of GenICam throw a exception
    try
    {
        // 5. create a CNodeMapRef instance
        if (NULL == g_pNodeMapRef)
        {
            g_pNodeMapRef = new CNodeMapRef;
            if (NULL == g_pNodeMapRef)
            {
                printf("%s\n" , "The Pointer of pNodeMapRef is NULL!");
                throw 1;
            }
        }

        // 6. Load device XML file
        g_pNodeMapRef->_LoadXMLFromFile("testdevice.xml");

        // 7.Import transport layer proxy, connect device
        g_pNodeMapRef->_Connect((IPort*)pTlProxy , "Device");
    }
    catch(...)
    {
        printf("init GenICam fail\n");
        return -1;
    }

    return 0;
}

/***************************************************************
* Parameter Configuration of Int Type
***************************************************************/
int SetIntParam()
{
    try
    {
        CIntegerPtr ptrIntNode = g_pNodeMapRef->_GetNode("Width");
        if (NULL == ptrIntNode)
        {
            printf("%s\n" , "Failed to GetNode Width");
            throw 1;
        }
        unsigned int nWidthMax  = (unsigned int)ptrIntNode->GetMax();
        unsigned int nWidthMin  = (unsigned int)ptrIntNode->GetMin();
        unsigned int nWidthInc  = (unsigned int)ptrIntNode->GetInc();

        unsigned int nWidth = 0;
        printf("input value between %d and %d, and the increment must be multiple of %d):\n", nWidthMax, nWidthMin, nWidthInc);
        scanf("%d", &nWidth);

        if (nWidth < nWidthMin || nWidth > nWidthMax)
        {
            printf("input value is out of range\n");
            return -1;
        }

        // make sure the value is valid
        nWidth = ((nWidth - nWidthMin) / nWidthInc) * nWidthInc + nWidthMin;
        ptrIntNode->SetValue(nWidth);
        printf("set value [%d] succeed!\n", nWidth);
    }
    catch (...)
    {
        printf("SetIntParam fail\n");
        return -1;
    }

    return 0;
}

/***************************************************************
* Parameter Configuration of Float Type
***************************************************************/
int SetFloatParam()
{
    try
    {
        CFloatPtr ptrFloatNode = g_pNodeMapRef->_GetNode("AcquisitionFrameRate");
        if (NULL == ptrFloatNode)
        {
            printf("%s\n" , "Failed to GetNode Width");
            throw 1;
        }

        float fFrameRate = 0.0;
        printf("input frame rate \n");
        scanf("%f", &fFrameRate);

        ptrFloatNode->SetValue(fFrameRate);
        printf("set value [%f] succeed!\n", fFrameRate);
    }
    catch (...)
    {
        printf("SetFloatParam fail\n");
        return -1;
    }

    return 0;
}

/***************************************************************
* Parameter Configuration of Enumeration Type
***************************************************************/
int SetEnumParam()
{
    try
    {
        CEnumerationPtr pstEnumNode = g_pNodeMapRef->_GetNode("PixelFormat");
        if (NULL == pstEnumNode)
        {
            printf("%s\n" , "Failed to GetNode PixelFormat");
            throw 1;
        }

        pstEnumNode->SetIntValue(PixelType_Gvsp_Mono8);
        printf("set value [%x] succeed!\n", PixelType_Gvsp_Mono8);
    }
    catch (...)
    {
        printf("SetEnumParam fail\n");
        return -1;
    }

    return 0;
}

/***************************************************************
* Parameter Configuration of String Type
***************************************************************/
int SetStringParam()
{
    try
    {
        CStringPtr pstStringNode = g_pNodeMapRef->_GetNode("DeviceUserID");
        if (NULL == pstStringNode)
        {
            printf("%s\n" , "Failed to GetNode DeviceUserID");
            throw 1;
        }

        pstStringNode->SetValue("MyCamera_001");
        printf("set value [%s] succeed!\n", "MyCamera_001");
    }
    catch (...)
    {
        printf("SetStringParam fail\n");
        return -1;
    }

    return 0;
}

/***************************************************************
* Parameter Configuration of Bool Type
***************************************************************/
int SetBoolParam()
{
    try
    {
        CBooleanPtr pstBooleanNode = g_pNodeMapRef->_GetNode("AcquisitionFrameRateEnable");
        if (NULL == pstBooleanNode)
        {
            printf("%s\n" , "Failed to GetNode AcquisitionFrameRateEnable");
            throw 1;
        }

        pstBooleanNode->SetValue(true);
        printf("set value [true] succeed!\n");
    }
    catch (...)
    {
        printf("SetBoolParam fail\n");
        return -1;
    }

    return 0;
}

/***************************************************************
* Parameter Configuration of Command Type
***************************************************************/
int SetCommandParam()
{
    try
    {
        CCommandPtr pstCommandNode = g_pNodeMapRef->_GetNode("DeviceReset");
        if (NULL == pstCommandNode)
        {
            printf("%s\n" , "Failed to GetNode DeviceReset");
            throw 1;
        }

        pstCommandNode->Execute();
        printf("set cmd DeviceReset succeed, the device will Restart, please wait a moment...\n");
    }
    catch (...)
    {
        printf("SetCommandParam fail\n");
        return -1;
    }

    return 0;
}

int main()
{
    int nRet = -1;
    MV_CC_DEVICE_INFO_LIST stDevList ;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    // 1.Get factory singleton
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // 2.Enumerate all the GigE devices within subnet, return the device information list
    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        return -1;
    }

    if (stDevList.nDeviceNum > 0)
    {
        printf("find [%d] gige device\n", stDevList.nDeviceNum);
    }
    else
    {
        printf("find no gige device\n");
        return -1;
    }

    // 3.Select the searched online device and create device instance
    CMvGigEDevice *pMvGigEDevice = (CMvGigEDevice *)tlFactory.CreateDevice(*(stDevList.pDeviceInfo[0]));
    if (NULL == pMvGigEDevice)
    {
        return -1;
    }

    // 4.Determine whether the device is accessible
    if (!tlFactory.IsDeviceAccessible(*(stDevList.pDeviceInfo[0])))
    {
        return -1;
    }

    // 5.Open the device
    nRet = pMvGigEDevice->Open();
    if (MV_OK != nRet)
    {
        printf("open fail, error code[%x]\n", nRet);
        return -1;
    }

    // 6.Get/save/import XML file
    nRet = InitGenICam(pMvGigEDevice);
    if (0 != nRet)
    {
        return -1;
    }

    // 6.1 Parameter Configuration of Int Type
    SetIntParam();

    // 6.2 Parameter Configuration of Float Type
    SetFloatParam();

    // 6.3 Parameter Configuration of Enumeration Type
    SetEnumParam();

    // 6.4 Parameter Configuration of String Type
    SetStringParam();

    // 6.5 Parameter Configuration of Bool Type
    SetBoolParam();

    // 6.6 Parameter Configuration of Command Type
    SetCommandParam();

    if (g_pNodeMapRef)
    {
        g_pNodeMapRef->_Destroy();

        delete g_pNodeMapRef;
        g_pNodeMapRef = NULL;
    }

    nRet = pMvGigEDevice->Close();
    if (MV_OK != nRet)
    {
        printf("Close device fail [%x]\n", nRet);
    }

    nRet = tlFactory.DestroyDevice(pMvGigEDevice);
    if (MV_OK != nRet)
    {
        printf("DestroyDevice fail [%x]\n", nRet);
    }

    system("pause");
    return 0;


MV_CC_GetSDKVersion

Get SDK version No.

unsigned int MV_CC_GetSDKVersion(
);

Return Values

Return SDK version No.:
|Main |Sub |Revision |Test
|8bits |8bits |8bits |8bits

Remarks

For example, if the return value is 0x01000001, the SDK version is V1.0.0.1.


Description of Interface Return Values

Return Type | Value | Description
MV_OK | 0 | Successed, no error.
Definition of General Error Codes: Range from 0x80000000 to 0x800000FF |  |
MV_E_HANDLE | 0x80000000 | Error or invalid handle.
MV_E_SUPPORT | 0x80000001 | Not supported function.
MV_E_BUFOVER | 0x80000002 | Cache is full.
MV_E_CALLORDER | 0x80000003 | Function calling order error.
MV_E_PARAMETER | 0x80000004 | Incorrect parameter.
MV_E_RESOURCE | 0x80000006 | Applying resource failed.
MV_E_NODATA | 0x80000007 | No data.
MV_E_PRECONDITION | 0x80000008 | Precondition error, or running environment changed.
MV_E_VERSION | 0x80000009 | Version mismatches.
MV_E_NOENOUGH_BUF | 0x8000000A | Insufficient memory.
MV_E_UNKNOW | 0x800000FF | Unknown error.
GenICam Series Error Codes: Range from 0x80000100 to 0x800001FF |  |
MV_E_GC_GENERIC | 0x80000100 | General error.
MV_E_GC_ARGUMENT | 0x80000101 | Illegal parameters.
MV_E_GC_RANGE | 0x80000102 | The value is out of range
MV_E_GC_PROPERTY | 0x80000103 | Property
MV_E_GC_RUNTIME | 0x80000104 | Running environment error.
MV_E_GC_LOGICAL | 0x80000105 | Logical error
MV_E_GC_ACCESS | 0x80000106 | Node accessing condition error.
MV_E_GC_TIMEOUT | 0x80000107 | Timeout.
MV_E_GC_DYNAMICCAST | 0x80000108 | Transformation exception.
MV_E_GC_UNKNOW | 0x800001FF | GenICam unknown error.
GigE_STATUS Error Codes: Range from 0x80000200 to 0x800002FF |  |
MV_E_NOT_IMPLEMENTED | 0x80000200 | The command is not supported by device.
MV_E_INVALID_ADDRESS | 0x80000201 | The target address being accessed does not exist.
MV_E_WRITE_PROTECT | 0x80000202 | The target address is not writable.
MV_E_ACCESS_DENIED | 0x80000203 | No permission.
MV_E_BUSY | 0x80000204 | Device is busy, or network disconnected.
MV_E_PACKET | 0x80000205 | Network data packet error.
MV_E_NETER | 0x80000206 | Network error.
USB_STATUS Error Codes: Range from 0x80000300 to 0x800003FF |  |
MV_E_USB_READ | 0x80000300 | Reading USB error.
MV_E_USB_WRITE | 0x80000301 | Writing USB error.
MV_E_USB_DEVICE | 0x80000302 | Device exception.
MV_E_USB_GENICAM | 0x80000303 | GenICam error.
MV_E_USB_BANDWIDTH | 0x80000304 | Insufficient bandwidth.
MV_E_USB_UNKNOW | 0x800003FF | USB unknown error.
Upgrade Error Codes: Range from 0x80000400 to 0x800004FF |  |
MV_E_UPG_FILE_MISMATCH | 0x80000400 | Firmware mismatches.
MV_E_UPG_LANGUSGE_MISMATCH | 0x80000401 | Firmware language mismatches.
MV_E_UPG_CONFLICT | 0x80000402 | Upgrading conflicted (repeated upgrading requests during device upgrade).
MV_E_UPG_INNER_ERR | 0x80000403 | Camera internal error during upgrade.
MV_E_UPG_UNKNOW | 0x800004FF | Unknown error during upgrade.


MV_CC_EnumerateTls

Enumerate supported device type (transport layer type)

int MV_CC_EnumerateTls(
);

Return Values

Return supported device type, indicated by bit, supporting multiple selection, available protocol types are shown below:

Macro Definition | Value | Description
MV_UNKNOW_DEVICE | 0x00000000 | Unknow device type
MV_GIGE_DEVICE | 0x00000001 | GigE device
MV_1394_DEVICE | 0x00000002 | 1394-a/b device
MV_USB_DEVICE | 0x00000004 | USB3.0 device
MV_CAMERALINK_DEVICE | 0x00000008 | CameraLink device
Example: nTLayerType == MV_GIGE_DEVICE | MV_USB_DEVICE, means supporting GigE and USB 3.0 device

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    unsigned int nTransLayers = MV_CC_EnumerateTls();
    if (nTransLayers & MV_GIGE_DEVICE)
    {
        OutputString(_T("MV_GIGE_DEVICE"));


MV_CC_EnumDevices

Enumerate all devices corresponding to specified transport protocol within subnet

int MV_CC_EnumDevices(
  unsigned int              nTLayerType,
  MV_CC_DEVICE_INFO_LIST    *pstDevList,
);

Parameters

nTLayerType
[in] Transport layer protocol type, indicated by bit, supporting multiple selection, available protocol types are shown below:
Macro Definition | Value | Description
MV_UNKNOW_DEVICE | 0x00000000 | Unknown device type
MV_GIGE_DEVICE | 0x00000001 | GigE device
MV_1394_DEVICE | 0x00000002 | 1394-a/b device
MV_USB_DEVICE | 0x00000004 | USB3.0 device
MV_CAMERALINK_DEVICE | 0x00000008 | CameraLink device
Example: nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE, means searching GigE and USB 3.0 device
pstDevList
[out] Information list of found devices

Return Values

Return MV_OK(0) on success; return error code on failure.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;

    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);


MV_CC_CreateHandle

Create handle

int MV_CC_CreateHandle(
  void                       **handle,
  const MV_CC_DEVICE_INFO    *pstDevInfo
);

Parameters

handle
[out] Device handle, output parameter
pstDevInfo
[in] Device information, including device version, MAC address, transport layer type and other device information

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Create required resources within library and initialize internal module according to input device information. Create handle and call SDK interface through this interface, and SDK log file will be created by default and will be saved in MvSdkLog folder under current executable program path. Creating handle through MV_CC_CreateHandleWithoutLog will not generate log files.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void*  m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_CreateHandleWithoutLog MV_CC_EnumDevices MV_CC_DestroyHandle


MV_CC_CreateHandleWithoutLog

Create handle without log

int MV_CC_CreateHandleWithoutLog(
  void                       **handle,
  const MV_CC_DEVICE_INFO    *pstDevInfo
);

Parameters

handle
[out] Device handle, output parameter
pstDevInfo
[in] Device information, including device version, MAC address, transport layer type and other device information

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Create required resources within library and initialize internal module according to input device information. Create handle and call SDK interface through this interface, and SDK log file will not be created. To create logs, create handle through MV_CC_CreateHandle, and log files will be automatically generated and saved to MvSdkLog folder under current executable program path.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void*  m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandleWithoutLog(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandleWithoutLog fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_EnumDevices MV_CC_DestroyHandle


MV_CC_DestroyHandle

Destroy device example and related resources

int MV_CC_DestroyHandle
  void    *handle
);

Parameters

handle
[in] Device handle, return value MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.

Return Values

Return MV_OK(0) on success; return error code on failure.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void*  m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    else
    {
        //...other processing
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_CreateHandle


MV_CC_RegisterExceptionCallBack

Register exception message callback

int MV_CC_RegisterExceptionCallBack(
  void           *handle,
  cbException    fExceptionCallBack,
  void           *pUser
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
fExceptionCallBack
[in] Callback function to receive exception messages
pUser
[in] User data

Callback Function

void(__stdcall* cbException)(
  unsigned int    nMsgType,
  void            *pUser
);

Callback Function Parameters

nMsgType
[out] Exception message type
pUser
[out] User data

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Call this interface after the device is opened by MV_CC_OpenDevice. When device is exceptionally disconnected, the exception message can be obtained from callback function. For Disconnected GigE device, first call MV_CC_CloseDevice to shut device, and then call MV_CC_OpenDevice to reopen the device.

For exception message type macro definition see below:

Macro Definition | Value | Description
MV_GIGE_EXCEPTION_DEV_DISCONNECT | 0x00008001 | 设备断开连接

Example

Example code is for reference only.

#include "MvCameraControl.h"

//Exception callback function
void __stdcall ExceptionCB(unsigned int nMsgType, void* pUser)
{
    printf("Exception message is: 0x%x", nMsgType);
}

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }

    //...other processing

    nRet = MV_CC_RegisterExceptionCallBack(m_handle, ExceptionCB, NULL);

    if (MV_OK != nRet)
    {
        printf("error: RegisterExceptionCallBack fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_OpenDevice


MV_CC_RegisterEventCallBack

Register Event callback

int MV_CC_RegisterEventCallBack(
  void       *handle,
  cbEvent    fEventCallBack,
  void       *pUser
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
fEventCallBack
[in] Receive Event callback function
pUser
[in] User data

Callback Function

void(__stdcall* cbEvent)(
  unsigned int    nExternalEventId,
  void            *pUser
);

Callback Function Parameters

nExternalEventId
[out] External output EventId, for detailed enumeration type value see: MV_GIGE_EVENT
pUser
[out] User data

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Set event callback through this interface. Get acquisition and exposure information in the callback function.

Example

Example code is for reference only.

#include "MvCameraControl.h"

//Exception callback function
void __stdcall EventCallBack(unsigned int nExternalEventId, void* pUser)
{
    switch(nUserDefinedId)
    {
    case MV_EVENT_ExposureEnd:
        printf("ExposureEnd!\n");
        break;
    case MV_EVENT_FrameStartOvertrigger:
        printf("FrameStartOvertrigger!\n");
        break;
    case MV_EVENT_AcquisitionStartOvertrigger:
        printf("AcquisitionStartOvertrigger!\n");
        break;
    case MV_EVENT_FrameStart:
        printf("FrameStart!\n");
        break;
    case MV_EVENT_AcquisitionStart:
        printf("AcquisitionStart!\n");
        break;
    case MV_EVENT_EventOverrun:
        printf("EventOverrun!\n");
        break;
    default:
        printf("no such eventId[%d]\n", nUserDefinedId);
    }
}

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Register Event callback function
    nRet = MV_CC_RegisterEventCallBack(handle, EventCallBack, NULL);
    if (MV_OK != nRet)
    {
        printf("error: RegisterEventCallBack fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_CreateHandle


MV_CC_IsDeviceAccessible

Whether the specified device can be accessed

bool MV_CC_IsDeviceAccessible(
  MV_CC_DEVICE_INFO    *pstDevInfo
  unsigned int         nAccessMode
);

Parameters

pstDevInfo
[in] Specified device information
nAccessMode
[in] Access type, for details see below:
Macro Definition | Value | Description
MV_ACCESS_Exclusive | 1 | Exclusive permission, for other apps, the CCP register is only allowed to be read
MV_ACCESS_ExclusiveWithSwitch | 2 | Preempt permission in mode 5, and then open with exclusive permission
MV_ACCESS_Control | 3 | Control permission, for other apps, all registers are allowed to be read
MV_ACCESS_ControlWithSwitch | 4 | Preempt permission in mode 5, and then open with control permission
MV_ACCESS_ControlSwitchEnable | 5 | Open with control permission that can be preempted
MV_ACCESS_ControlSwitchEnableWithKey | 6 | Preempt permission in mode 5, and then open with control permission that can be preempted
MV_ACCESS_Monitor | 7 | Open device with reading mode, suitable under control permission

Return Values

Return true to mean accessible; return false to mean no permission or the device is offline.

Remarks

  • Read device CCP register value and determine current access permission.
  • Return false if the device does not support the modes MV_ACCESS_ExclusiveWithSwitch, MV_ACCESS_ControlWithSwitch, MV_ACCESS_ControlSwitchEnableWithKey. Currently the device does not support the 3 preemption modes, neither do the devices from other mainstream manufacturers.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Determine whether specified device is accessible
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    nRet = MV_CC_IsDeviceAccessible(&m_stDevInfo, nAccessMode);
    if (MV_OK != nRet)
    {
        printf("error: IsDeviceAccessible fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_CreateHandle


MV_CC_OpenDevice

Open device (connect device)

int MV_CC_OpenDevice(
  void              *handle,
  unsigned int      nAccessMode = MV_ACCESS_Exclusive,
  unsigned short    nSwitchoverKey = 0
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nAccessMode
[in] Device access mode, exclusive mode be default, for details see below:
Macro Definition | Value | Description
MV_ACCESS_Exclusive | 1 | Exclusive permission, for other apps, the CCP register is only allowed to be read
MV_ACCESS_ExclusiveWithSwitch | 2 | Preempt permission in mode 5, and then open with exclusive permission
MV_ACCESS_Control | 3 | Control permission, for other apps, all registers are allowed to be read
MV_ACCESS_ControlWithSwitch | 4 | Preempt permission in mode 5, and then open with control permission
MV_ACCESS_ControlSwitchEnable | 5 | Open with control permission that can be preempted
MV_ACCESS_ControlSwitchEnableWithKey | 6 | Preempt permission in mode 5, and then open with control permission that can be preempted
MV_ACCESS_Monitor | 7 | Open device with reading mode, suitable under control permission
nSwitchoverKey
[in] Key for switch permissions, null by default, valid when access mode supports permission switching (2/4/6 mode).

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

  • Find specific device and connect according to set device parameters.
  • When calling the interface, the input of nAccessMode and nSwitchoverKey is optional, and the device access mode is exclusive. Currently the device does not support the following preemption modes: MV_ACCESS_ExclusiveWithSwitch, MV_ACCESS_ControlWithSwitch, MV_ACCESS_ControlSwitchEnableWithKey.
  • For U3V device, nAccessMode, nSwitchoverKey are invalid.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    //Connect device
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_CloseDevice


MV_CC_CloseDevice

Shut device

int MV_CC_CloseDevice(
  void    *handle
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After connecting to device through MV_CC_OpenDevice, use this interface to disconnect and release resources.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void*  m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_OpenDevice


MV_CC_GetDeviceInfo

Get device information

int MV_CC_GetDeviceInfo(
  void                 *handle,
  MV_CC_DEVICE_INFO    *pstDevInfo
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstDevInfo
[out] Device information

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

The interface is not supported by U3Vision device.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
     int nRet = -1;
    void*  m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }

    //Get device information
    MV_CC_DEVICE_INFO struDeviceInfo;
    memset(&deviceInfo, 0, sizeof(MV_CC_DEVICE_INFO));
    nRet = MV_CC_GetDeviceInfo(m_handle, &struDeviceInfo);
    if (MV_OK != nRet)
    {
        printf("error: GetDeviceInfo[%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_OpenDevice


MV_CC_GetOptimalPacketSize

Get optimized packet size

int MV_CC_GetOptimalPacketSize(
  void    *handle
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

To get optimized packet size, for GigEVision device is SCPS, for U3V device is the size of packet read from driver each time, and it is the size of a packet transported on the network. The interface should be called after MV_CC_OpenDevice and before MV_CC_StartGrabbing.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void*  m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }

    //Get optimized packet size
    int iPacketSize = MV_CC_GetOptimalPacketSize(m_handle);

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_OpenDevice MV_CC_StartGrabbing


MV_CC_GetDeviceUserID

Get device user ID information

int MV_CC_GetDeviceUserID(
  void                *handle,
  MVCC_STRINGVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Device user ID information

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get camera user ID information.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get camera user ID information
    MVCC_STRINGVALUE struIntValue = {0};

    nRet = MV_CC_GetDeviceUserID(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetDeviceUserID fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetDeviceUserID


MV_CC_SetDeviceUserID

Set device user ID information

int MV_CC_SetDeviceUserID(
  void          *handle,
  const char    *chValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
chValue
[in] Device user ID information

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to set camera user ID information.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }

    //Get camera user ID information
    MVCC_STRINGVALUE struIntValue = {0};
    nRet = MV_CC_GetDeviceUserID(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetDeviceUserID fail [%x]\n", nRet);
        return;
    }

    //Set camera user ID information
    strncpy(struIntValue.chCurValue,"ID12345",256);
    nRet = MV_CC_SetDeviceUserID(m_handle, struIntValue.chCurValue);
    if (MV_OK != nRet)
    {
        printf("error: SetDeviceUserID fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetDeviceUserID


MV_CC_GetHeartBeatTimeout

Get camera heartbeat timeout time

int MV_CC_GetHeartBeatTimeout(
  void             *handle,
  MVCC_INTVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Heartbeat time, unit: ms

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get camera heartbeat timeout time.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get camera heartbeat
    MVCC_INTVALUE struIntValue = {0};
    nRet = MV_CC_GetHeartBeatTimeout(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetHeartBeatTimeout fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetHeartBeatTimeout


MV_CC_SetHeartBeatTimeout

Set camera heartbeat time

int MV_CC_SetHeartBeatTimeout(
  void            *handle,
  unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nValue
[in] Heartbeat time, unit: ms

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to set camera heartbeat timeout time.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Set camera heartbeat
    unsigned int nValue = 3000; //ms
    nRet = MV_CC_SetHeartBeatTimeout(m_handle, nValue);
    if (MV_OK != nRet)
    {
        printf("error: SetHeartBeatTimeout fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetHeartBeatTimeout MV_GIGE_SetResend


MV_CC_GetAcquisitionMode

Get camera acquisition mode

int MV_CC_GetAcquisitionMode(
  void              *handle,
  MVCC_ENUMVALUE    *pstValue
);

Parameters

handle
[in] Handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Acquisition mode information, for enumeration type value see: MV_CAM_ACQUISITION_MODE

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get camera acquisition mode, including single frame, multiple frame or continuous mode.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get device acquisition mode
    MVCC_ENUMVALUE struEnumValue = {0};
    nRet = MV_CC_GetAcquisitionMode(m_handle, &struEnumValue);
    if (MV_OK != nRet)
    {
        printf("error: GetAcquisitionMode fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetAcquisitionMode


MV_CC_SetAcquisitionMode

Set camera acquisition mode

int MV_CC_SetAcquisitionMode(
  void                  *handle,
  const unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nValue
[in] Acquisition mode, for details see: MV_CAM_ACQUISITION_MODE

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

  • After the device is connected, call this interface to set acquisition mode, including single frame, multiple frame or continuous mode.
  • Multiple frame mode is currently not supported.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Set acquisition mode
    unsigned int nValue = 2; //Continuous acquisition mode
    nRet = MV_CC_SetAcquisitionMode(m_handle, nValue);
    if (MV_OK != nRet)
    {
        printf("error: SetAcquisitionMode fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetAcquisitionMode


MV_CC_SetImageNodeNum

Set number of SDK internal image buffer nodes

int MV_CC_SetImageNodeNum(
  void            *handle,
  unsigned int    nNum
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nNum
[in] Number of SDK internal image buffer nodes, range: 1 to 30

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Call this interface to set the number of SDK internal image buffer nodes. The interface should be called before calling MV_CC_StartGrabbing for capturing.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void __stdcall ImageCallBack(unsigned char * pData, MV_FRAME_OUT_INFO* pFrameInfo, void* pUser)
{
    if (pFrameInfo)
    {
        // Add system time at output
        char   szInfo[128] = {0};
        SYSTEMTIME sys;
        GetLocalTime( &sys );
        sprintf_s(szInfo, 128, "[%d-%02d-%02d %02d:%02d:%02d:%04d] : GetOneFrame succeed, width[%d], height[%d]", sys.wYear, sys.wMonth,
            sys.wDay, sys.wHour, sys.wMinute, sys.wSecond, sys.wMilliseconds, pFrameInfo->nWidth, pFrameInfo->nHeight);

        printf("%s\n", szInfo);
    }
}

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Set number of SDK internal image buffer nodes
    unsigned int nNum = 15;
    nRet = MV_CC_SetImageNodeNum(handle, nNum);
    if (MV_OK != nRet)
    {
        printf("error: SetImageNodeNum fail [%x]\n", nRet);
        return;
    }

    //Register data callback function, get acquired image data in the callback function
    nRet = MV_CC_RegisterImageCallBack(handle, ImageCallBack, NULL);
    if (MV_OK != nRet)
    {
        printf("error: RegisterImageCallBack fail [%x]\n", nRet);
        return;
    }

    //Start image acquiring
    nRet = MV_CC_StartGrabbing(m_handle);
    if (MV_OK != nRet)
    {
         printf("error: StartGrabbing fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Stop image acquiring
    nRet = MV_CC_StopGrabbing(m_handle);
    if (MV_OK != nRet)
    {
        OutputString(_T("Operation: Stop Grabbing......failed!"));
        return;
    }

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_OpenDevice


MV_CC_RegisterImageCallBack

Register image data callback function.

int MV_CC_RegisterImageCallBack(
  void        *handle,
  cbOutput    fOutputCallBack,
  void        *pUser
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
fOutputCallBack
[in] Image data callback function
pUser
[in] User data

Callback Function

void(__stdcall* cbOutput)(
  unsigned char        *pData,
  MV_FRAME_OUT_INFO    *pFrameInfo
  void                 *pUser
);

Callback Function Parameters

pData
[out] Address of buffer that saves image data
pFrameInfo
[out] Obtained frame information, including width, height and pixel format
pUser
[out] User data

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

  • After MV_CC_CreateHandle, call this interface to set image data callback function.
  • There are two available image data acquisition modes, and cannot be used together:
    1: Call MV_CC_RegisterImageCallBack to set image data callback function, and then callMV_CC_StartGrabbing to start acquiring. The acquired image data will return in the set callback function.
    2: Call MV_CC_StartGrabbing to start acquiring, and then call MV_CC_GetOneFrame repeatedly in application layer to get frame data of specified pixel format. When getting frame data, the frequency of calling this interface should be controlled by upper layer application according to frame rate.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void __stdcall ImageCallBack(unsigned char * pData, MV_FRAME_OUT_INFO* pFrameInfo, void* pUser)
{
    if (pFrameInfo)
    {
        // Add current system time at output
        char   szInfo[128] = {0};
        SYSTEMTIME sys;
        GetLocalTime( &sys );
        sprintf_s(szInfo, 128, "[%d-%02d-%02d %02d:%02d:%02d:%04d] : GetOneFrame succeed, width[%d], height[%d]", sys.wYear, sys.wMonth,
            sys.wDay, sys.wHour, sys.wMinute, sys.wSecond, sys.wMilliseconds, pFrameInfo->nWidth, pFrameInfo->nHeight);

        printf("%s\n", szInfo);
    }
}

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Register data callback function
    nRet = MV_CC_RegisterImageCallBack(handle, ImageCallBack, NULL);
    if (MV_OK != nRet)
    {
        printf("error: RegisterImageCallBack fail [%x]\n", nRet);
        return;
    }

    //Connect device
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Start acquiring image
    nRet = MV_CC_StartGrabbing(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Stop acquiring image
    nRet = MV_CC_StopGrabbing(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: StopGrabbing fail [%x]\n", nRet);
        return;
    }

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_RegisterImageCallBackEx MV_CC_StartGrabbing


MV_CC_RegisterImageCallBackEx

Register image data callback function, supporting getting chunk information

int MV_CC_RegisterImageCallBackEx(
  void        *handle,
  cbOutput    fOutputCallBack,
  void        *pUser
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
fOutputCallBack
[in] Image data callback function
pUser
[in] User data

Callback Function

void(__stdcall* cbOutput)(
  unsigned char           *pData,
  MV_FRAME_OUT_INFO_EX    *pFrameInfo
  void                    *pUser
);

Callback Function Parameters

pData
[out] Address of buffer that saves image data
pFrameInfo
[out] Obtained frame information, including width, height, pixel format and chunk information
pUser
[out] User data

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

  • After MV_CC_CreateHandle, call this interface to set image data callback function.
  • There are two available image data acquisition modes, and cannot be used together:
    1: Call MV_CC_RegisterImageCallBack to set image data callback function, and then callMV_CC_StartGrabbing to start acquiring. The acquired image data will return in the set callback function.
    2: Call MV_CC_StartGrabbing to start acquiring, and then call MV_CC_GetOneFrame repeatedly in application layer to get frame data of specified pixel format. When getting frame data, the frequency of calling this interface should be controlled by upper layer application according to frame rate.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void __stdcall ImageCallBack(unsigned char * pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser)
{
    if (pFrameInfo)
    {
        // Add current system time at output
        char   szInfo[128] = {0};
        SYSTEMTIME sys;
        GetLocalTime( &sys );
        sprintf_s(szInfo, 128, "[%d-%02d-%02d %02d:%02d:%02d:%04d] : GetOneFrame succeed, width[%d], height[%d]", sys.wYear, sys.wMonth,
            sys.wDay, sys.wHour, sys.wMinute, sys.wSecond, sys.wMilliseconds, pFrameInfo->nWidth, pFrameInfo->nHeight);

        printf("%s\n", szInfo);
    }
}

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Register data callback function
    nRet = MV_CC_RegisterImageCallBackEx(handle, ImageCallBack, NULL);
    if (MV_OK != nRet)
    {
        printf("error: RegisterImageCallBack fail [%x]\n", nRet);
        return;
    }

    //Connect device
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Start acquiring image
    nRet = MV_CC_StartGrabbing(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Stop acquiring image
    nRet = MV_CC_StopGrabbing(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: StopGrabbing fail [%x]\n", nRet);
        return;
    }

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_RegisterImageCallBack MV_CC_StartGrabbing


MV_CC_StartGrabbing

Start acquiring image

int MV_CC_StartGrabbing(
  void    *handle
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.

Return Values

Return MV_OK(0) on success; return error code on failure.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void __stdcall ImageCallBack(unsigned char * pData, MV_FRAME_OUT_INFO* pFrameInfo, void* pUser)
{
    if (pFrameInfo)
    {
        // Add system time at output
        char   szInfo[128] = {0};
        SYSTEMTIME sys;
        GetLocalTime( &sys );
        sprintf_s(szInfo, 128, "[%d-%02d-%02d %02d:%02d:%02d:%04d] : GetOneFrame succeed, width[%d], height[%d]", sys.wYear, sys.wMonth,
            sys.wDay, sys.wHour, sys.wMinute, sys.wSecond, sys.wMilliseconds, pFrameInfo->nWidth, pFrameInfo->nHeight);

        printf("%s\n", szInfo);
    }
}

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    else
    {
        unsigned int nAccessMode = MV_ACCESS_Exclusive;
        unsigned short nSwitchoverKey = 0;

        //Connect device
        nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
        if (MV_OK != nRet)
        {
            printf("error: OpenDevice fail [%x]\n", nRet);
            return;
        }
        //...other processing
    }

    //Register data callback function, get acquired image data in the callback function
    nRet = MV_CC_RegisterImageCallBack(handle, ImageCallBack, NULL);
    if (MV_OK != nRet)
    {
        printf("error: RegisterImageCallBack fail [%x]\n", nRet);
        return;
    }

    //Start acquiring image
    nRet = MV_CC_StartGrabbing(m_handle);
    if (MV_OK != nRet)
    {
         printf("error: StartGrabbing fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Stop acquiring image
    nRet = MV_CC_StopGrabbing(m_handle);
    if (MV_OK != nRet)
    {
        OutputString(_T("Operation: Stop Grabbing......failed!"));
        return;
    }

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_StopGrabbing


MV_CC_StopGrabbing

Stop acquiring images

int MV_CC_StopGrabbing(
  void    *handle
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.

Return Values

Return MV_OK(0) on success; return error code on failure.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    else
    {
        unsigned int nAccessMode = MV_ACCESS_Exclusive;
        unsigned short nSwitchoverKey = 0;

        //Connect device
        nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
        if (MV_OK != nRet)
        {
            printf("error: OpenDevice fail [%x]\n", nRet);
            return;
        }
        //...other processing
    }

    //Start acquiring image
    nRet = MV_CC_StartGrabbing(m_handle);
    if (MV_OK != nRet)
    {
         printf("error: StartGrabbing fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Stop acquiring image
    nRet = MV_CC_StopGrabbing(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: StopGrabbing fail [%x]\n", nRet);
        return;
    }

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_StartGrabbing


MV_CC_GetOneFrame

Get one frame data

int MV_CC_GetOneFrame(
  void                 *handle,
  unsigned char        *pData,
  unsigned int         nDataSize,
  MV_FRAME_OUT_INFO    *pFrameInfo
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pData
[in] Address of cache used to save image data
nDataSize
[in] Cache size
pFrameInfo
[out] Obtained frame information

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Before calling this interface to get image data frame, call MV_CC_StartGrabbing to start image acquisition. The interface actively gets frame data. The frequency of calling this interface should be controlled by upper layer application according to frame rate.

Example

Example code is for reference only.

#include "MvCameraControl.h"

#define MAX_BUF_SIZE    (1920*1080*3)

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Start acquiring image
    nRet = MV_CC_StartGrabbing(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing fail [%x]\n", nRet);
        return;
    }

    unsigned int    nTestFrameSize = 0;
    unsigned char*  g_pFrameBuf = NULL;
    g_pFrameBuf = (unsigned char*)malloc(MAX_BUF_SIZE);

    MV_FRAME_OUT_INFO stInfo;
    memset(&stInfo, 0, sizeof(MV_FRAME_OUT_INFO));

    //The frequency of calling this interface should be controlled by upper layer application according to frame rate.
    //The codes are for reference only. In practical application, it is recommended to create a new thread for image acquisition and processing.
    while(1)
    {
        if (nTestFrameSize > 99)
        {
            break;
        }
        nRet = MV_CC_GetOneFrame(m_handle,g_pFrameBuf, MAX_BUF_SIZE, &stInfo);
        if (MV_OK != nRet)
        {
            Sleep(10);
        }
        else
        {
            //...Image data processing
            nTestFrameSize++;
        }
    }

    //...other processing

    //Stop image acquiring
    nRet = MV_CC_StopGrabbing(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: StopGrabbing fail [%x]\n", nRet);
        return;
    }

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_StartGrabbing


MV_CC_GetOneFrameEx

Get one frame data, supporting getting chunk information

int MV_CC_GetOneFrameEx(
  void                    *handle,
  unsigned char           *pData,
  unsigned int            nDataSize,
  MV_FRAME_OUT_INFO_EX    *pFrameInfo
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pData
[in] Address of cache used to save image data
nDataSize
[in] Cache size
pFrameInfo
[out] Obtained frame information, including chunk information

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Before calling this interface to get image data frame, call MV_CC_StartGrabbing to start image acquisition. The interface actively gets frame data. The frequency of calling this interface should be controlled by upper layer application according to frame rate.

Example

Example code is for reference only.

#include "MvCameraControl.h"

#define MAX_BUF_SIZE    (1920*1080*3)

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Start image acquisition
    nRet = MV_CC_StartGrabbing(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing fail [%x]\n", nRet);
        return;
    }

    unsigned int    nTestFrameSize = 0;
    unsigned char*  g_pFrameBuf = NULL;
    g_pFrameBuf = (unsigned char*)malloc(MAX_BUF_SIZE);

    MV_FRAME_OUT_INFO_EX stInfo;
    memset(&stInfo, 0, sizeof(MV_FRAME_OUT_INFO_EX));

    //The frequency of calling this interface should be controlled by upper layer application according to frame rate.
    //The codes are for reference only. In practical application, it is recommended to create a new thread for image acquisition and processing.
    while(1)
    {
        if (nTestFrameSize > 99)
        {
            break;
        }
        nRet = MV_CC_GetOneFrameEx(m_handle,g_pFrameBuf, MAX_BUF_SIZE, &stInfo);
        if (MV_OK != nRet)
        {
            Sleep(10);
        }
        else
        {
            //...Image data processing
            nTestFrameSize++;
        }
    }

    //...other processing

    //Stop image acquiring
    nRet = MV_CC_StopGrabbing(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: StopGrabbing fail [%x]\n", nRet);
        return;
    }

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetOneFrame MV_CC_StartGrabbing


MV_CC_Display

Display acquired images

int MV_CC_Display(
  void    *handle,
  void    *hWnd
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
hWnd
[in] Window handle

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Call this interface after MV_CC_StartGrabbing to display acquired images.

Example

Example code is for reference only.

#include <stdio.h>
#include "Windows.h"
#include "MvCameraControl.h"

typedef HWND (WINAPI *PROCGETCONSOLEWINDOW)();
PROCGETCONSOLEWINDOW GetConsoleWindow;

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Start acquiring images
    nRet = MV_CC_StartGrabbing(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing fail [%x]\n", nRet);
        return;
    }

    //Get console window handle
    HMODULE hKernel32 = GetModuleHandle("kernel32");
    GetConsoleWindow = (PROCGETCONSOLEWINDOW)GetProcAddress(hKernel32,"GetConsoleWindow");
    HWND hWnd = GetConsoleWindow(); //window handle

    //Display images
    nRet = MV_CC_Display(m_handle,hWnd);
    if (MV_OK != nRet)
    {
        printf("error: Display fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Stop acquiring images
    nRet = MV_CC_StopGrabbing(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: StopGrabbing fail [%x]\n", nRet);
        return;
    }

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_StartGrabbing


MV_CC_SaveImage

Convert original image data into picture format and saves in specified memory

int MV_CC_SaveImage(
  MV_SAVE_IMAGE_PARAM    *pSaveParam
);

Parameters

pSaveParam
[in&out] Picture data input and output parameter

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

  • Through this interface, convert the original images acquired by device into JPEG or BMP format and save in specified memory, and you can save the converted data as picture file. No sequence is required for calling this interface, original image data can be directly converted. First call MV_CC_GetOneFrame or MV_CC_RegisterImageCallBack to set callback function, and get one frame of image data, and then convert into other formats through this interface.
  • This interface is supported by Windows version only.

Example

Example code is for reference only.

#include "MvCameraControl.h"

#define MAX_BUF_SIZE    (1920*1080*3)

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Starting acquiring image
    nRet = MV_CC_StartGrabbing(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing fail [%x]\n", nRet);
        return;
    }

    unsigned int    nTestFrameSize = 0;
    unsigned char*  g_pFrameBuf = NULL;
    g_pFrameBuf = (unsigned char*)malloc(MAX_BUF_SIZE);

    MV_FRAME_OUT_INFO stInfo;
    memset(&stInfo, 0, sizeof(MV_FRAME_OUT_INFO));

    //The frequency of calling this interface should be controlled by upper layer application according to frame rate.
    //The codes are for reference only. In practical application, it is recommended to create a new thread for image acquisition and processing.
    while(1)
    {
        if (nTestFrameSize > 99)
        {
            break;
        }
        nRet = MV_CC_GetOneFrame(m_handle,g_pFrameBuf, MAX_BUF_SIZE, &stInfo);
        if (MV_OK != nRet)
        {
            Sleep(10);
        }
        else
        {
            //Picture data input and output parameters
            MV_SAVE_IMAGE_PARAM stParam;

            //Source data
            stParam.pData         = g_pFrameBuf;              //Original image data
            stParam.nDataLen      = stFrameInfo.nFrameLen;    //Original image data length
            stParam.enPixelType   = stFrameInfo.enPixelType;  //Original image data pixel format
            stParam.nWidth        = stFrameInfo.nWidth;       //Image width
            stParam.nHeight       = stFrameInfo.nHeight;      //Image height

            //Target data
            stParam.enImageType   = MV_Image_Jpeg;            //Image type to be saved, converting to JPEG format
            stParam.nBufferSize   = MAX_BUF_SIZE;             //Storage node size
            unsigned char* pImage = (unsigned char*)malloc(MAX_BUF_SIZE);
            stParam.pImageBuffer  = pImage;                   //Output data buffer, saving converted picture data

            nRet = MV_CC_SaveImage(&stParam);
            if(MV_OK != nRet)
            {
                break;
            }

            //Save converted picture data as file
            FILE* fp = fopen("image", "wb");
            fwrite(pImage, 1, stParam.nImageLen, fp);
            fclose(fp);
            free(pImage);

            //...other image data processing
            nTestFrameSize++;
        }
    }
    free(g_pFrameBuf);

    //...other processing

    //Stop acquiring image
    nRet = MV_CC_StopGrabbing(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: StopGrabbing fail [%x]\n", nRet);
        return;
    }

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetOneFrame MV_CC_RegisterImageCallBack MV_CC_SaveImageEx


MV_CC_SaveImageEx

Convert original image data into picture format and saves in specified memory, supporting setting JPEG encoding quality

int MV_CC_SaveImageEx(
  MV_SAVE_IMAGE_PARAM_EX    *pSaveParam
);

Parameters

pSaveParam
[in&out] Picture data input and output parameter

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

  • Through this interface, convert the original images acquired by device into JPEG or BMP format and save in specified memory, and you can save the converted data as picture file. No sequence is required for calling this interface, original image data can be directly converted. First call MV_CC_GetOneFrame or MV_CC_RegisterImageCallBack to set callback function, and get one frame of image data, and then convert into other formats through this interface.
  • This interface is supported by Windows version only.

Example

Example code is for reference only.

#include "MvCameraControl.h"

#define MAX_BUF_SIZE    (1920*1080*3)

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Start acquiring image
    nRet = MV_CC_StartGrabbing(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing fail [%x]\n", nRet);
        return;
    }

    unsigned int    nTestFrameSize = 0;
    unsigned char*  g_pFrameBuf = NULL;
    g_pFrameBuf = (unsigned char*)malloc(MAX_BUF_SIZE);

    MV_FRAME_OUT_INFO stInfo;
    memset(&stInfo, 0, sizeof(MV_FRAME_OUT_INFO));

    //The frequency of calling this interface should be controlled by upper layer application according to frame rate.
    //The codes are for reference only. In practical application, it is recommended to create a new thread for image acquisition and processing.
    while(1)
    {
        if (nTestFrameSize > 99)
        {
            break;
        }
        nRet = MV_CC_GetOneFrame(m_handle,g_pFrameBuf, MAX_BUF_SIZE, &stInfo);
        if (MV_OK != nRet)
        {
            Sleep(10);
        }
        else
        {
            //Picture data input and output parameters
            MV_SAVE_IMAGE_PARAM_EX stParam;

            //Source data
            stParam.pData         = g_pFrameBuf;              //Original image data
            stParam.nDataLen      = stFrameInfo.nFrameLen;    //Original image data length
            stParam.enPixelType   = stFrameInfo.enPixelType;  //Original image data pixel format
            stParam.nWidth        = stFrameInfo.nWidth;       //Image width
            stParam.nHeight       = stFrameInfo.nHeight;      //Image height
            stParam.nJpgQuality   = 70;						  //JPEG picture encoding quality

            //Target data
            stParam.enImageType   = MV_Image_Jpeg;            //Image type to be saved, converting to JPEG format
            stParam.nBufferSize   = MAX_BUF_SIZE;             //Storage node size
            unsigned char* pImage = (unsigned char*)malloc(MAX_BUF_SIZE);
            stParam.pImageBuffer  = pImage;                   //Output data buffer, saving converted picture data

            nRet = MV_CC_SaveImageEx(&stParam);
            if(MV_OK != nRet)
            {
                break;
            }

            //Save converted picture data as file
            FILE* fp = fopen("image", "wb");
            fwrite(pImage, 1, stParam.nImageLen, fp);
            fclose(fp);
            free(pImage);

            //...other image data processing
            nTestFrameSize++;
        }
    }
    free(g_pFrameBuf);

    //...other processing

    //Stop acquiring image
    nRet = MV_CC_StopGrabbing(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: StopGrabbing fail [%x]\n", nRet);
        return;
    }

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetOneFrame MV_CC_RegisterImageCallBack MV_CC_SaveImage


MV_CC_GetTriggerMode

Get camera trigger mode

int MV_CC_GetTriggerMode(
  void              *handle,
  MVCC_ENUMVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Trigger mode, for detailed enumeration type value see: MV_CAM_TRIGGER_MODE

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get camera trigger mode. If trigger mode is enabled, configure trigger source for image acquisition. Get and set current trigger mode through MV_CC_GetTriggerSource and MV_CC_SetTriggerSource.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get current trigger mode
    MVCC_ENUMVALUE struEnumValue = {0};
    nRet = MV_CC_GetTriggerMode(m_handle, &struEnumValue);
    if (MV_OK != nRet)
    {
        printf("error: GetTriggerMode fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetTriggerMode


MV_CC_SetTriggerMode

Set camera trigger mode

int MV_CC_SetTriggerMode(
  void                  *handle,
  const unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nValue
[in] Trigger mode, for detailed enumeration type value see: MV_CAM_TRIGGER_MODE

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to set camera trigger mode. If trigger mode is enabled, configure trigger source for image acquisition. Get and set current trigger mode through MV_CC_GetTriggerSource and MV_CC_SetTriggerSource.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Set current trigger mode
    unsigned int enMode = MV_TRIGGER_MODE_ON; //Open
    nRet = MV_CC_SetTriggerMode(m_handle, enMode);
    if (MV_OK != nRet)
    {
        printf("error: SetTriggerMode fail [%x]\n", nRet);
        return;
    }

    //...other processing
}

See Also

MV_CC_GetTriggerMode


MV_CC_GetTriggerDelay

Get camera trigger delay time

int MV_CC_GetTriggerDelay(
  void               *handle,
  MVCC_FLOATVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Trigger delay

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get trigger delay.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get trigger delay
    MVCC_FLOATVALUE struFloatValue = {0};
    nRet = MV_CC_GetTriggerDelay(m_handle, &struFloatValue);
    if (MV_OK != nRet)
    {
        printf("error: GetTriggerDelay fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetTriggerDelay


MV_CC_SetTriggerDelay

Set camera trigger delay

int MV_CC_SetTriggerDelay(
  void           *handle,
  const float    fValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
fValue
[in] Trigger delay

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to set trigger delay, the decimal places of the delay time will be ignored.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get trigger delay
    MVCC_FLOATVALUE struFloatValue = {0};
    nRet = MV_CC_GetTriggerDelay(m_handle, &struFloatValue);
    if (MV_OK != nRet)
    {
        printf("error: GetTriggerDelay fail [%x]\n", nRet);
        return;
    }

    //Set trigger delay
    float fValue = struFloatValue.fMax;    //Set as max. value
    nRet = MV_CC_SetTriggerDelay(m_handle, fValue);
    if (MV_OK != nRet)
    {
        printf("error: SetTriggerDelay fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetTriggerDelay


MV_CC_GetTriggerSource

Get camera trigger source

int MV_CC_GetTriggerSource(
  void              *handle,
  MVCC_ENUMVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Trigger mode, for detailed enumeration type value see: MV_CAM_TRIGGER_SOURCE

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get camera trigger source.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get trigger source
    MVCC_ENUMVALUE struEnumValue = {0};
    nRet = MV_CC_GetTriggerSource(m_handle, &struEnumValue);
    if (MV_OK != nRet)
    {
        printf("error: GetTriggerSource fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetTriggerSource


MV_CC_SetTriggerSource

Set camera trigger source

int MV_CC_SetTriggerSource(
  void                  *handle,
  const unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nValue
[in] Trigger mode, for detailed enumeration type value see: MV_CAM_TRIGGER_SOURCE

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Return MV_OK(0) on success; return error code on failure.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Set trigger source
    unsigned int enMode = MV_TRIGGER_SOURCE_SOFTWARE; //Set trigger source as soft trigger
    nRet = MV_CC_SetTriggerSource(m_handle, enMode);
    if (MV_OK != nRet)
    {
        printf("error: SetTriggerSource fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetTriggerSource


MV_CC_TriggerSoftwareExecute

Software trigger

int MV_CC_TriggerSoftwareExecute(
  void    *handle
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to soft trigger the camera once, valid when the camera trigger source is soft trigger (MV_TRIGGER_SOURCE_SOFTWARE). Get and set current trigger source through MV_CC_GetTriggerSource and MV_CC_SetTriggerSource.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void __stdcall ImageCallBack(unsigned char * pData, MV_FRAME_OUT_INFO* pFrameInfo, void* pUser)
{
    if (pFrameInfo)
    {
        // Add current system time at output
        char   szInfo[128] = {0};
        SYSTEMTIME sys;
        GetLocalTime( &sys );
        sprintf_s(szInfo, 128, "[%d-%02d-%02d %02d:%02d:%02d:%04d] : GetOneFrame succeed, width[%d], height[%d]", sys.wYear, sys.wMonth,
            sys.wDay, sys.wHour, sys.wMinute, sys.wSecond, sys.wMilliseconds, pFrameInfo->nWidth, pFrameInfo->nHeight);

        printf("%s\n", szInfo);
    }
}

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    nRet = MV_CC_SetTriggerMode(handle, MV_TRIGGER_MODE_ON);  //Enable trigger mode
    if (MV_OK != nRet)
    {
        printf("error: SetTriggerMode fail [%x]\n", nRet);
        return;
    }

     nRet = MV_CC_SetTriggerSource(handle, MV_TRIGGER_SOURCE_SOFTWARE);  //Set trigger source to soft trigger

     if (MV_OK != nRet)
     {
        printf("error: SetTriggerSource fail [%x]\n", nRet);
        return;
     }

    //Register data callback function, get triggered capture data in the callback function
    nRet = MV_CC_RegisterImageCallBack(handle, ImageCallBack, NULL);
    if (MV_OK != nRet)
    {
        printf("error: RegisterImageCallBack fail [%x]\n", nRet);
        return;
    }

    //Start acquiring image
    nRet = MV_CC_StartGrabbing(m_handle);
    if (MV_OK != nRet)
    {
         printf("error: StartGrabbing fail [%x]\n", nRet);
        return;
    }

    //Soft trigger
    nRet = MV_CC_TriggerSoftwareExecute(handle);
    if (MV_OK != nRet)
    {
        printf("error: TriggerSoftwareExecute fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_StartGrabbing MV_CC_GetTriggerSource MV_CC_SetTriggerSource


MV_CC_GetBurstFrameCount

Get the number of frames by one trigger

int MV_CC_GetBurstFrameCount(
  void             *handle,
  MVCC_INTVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Number of frames by one trigger

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get number of frames by one trigger, including current value, max. and min. supported value and increment.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get number of frames by one trigger
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetBurstFrameCount(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetBurstFrameCount fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetBurstFrameCount


MV_CC_SetBurstFrameCount

Set the number of frames by one trigger

int MV_CC_SetBurstFrameCount(
  void            *handle,
  unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nValue
[in] Number of frames by one trigger

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Set the number of frames by one trigger through this interface.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Set number of frames by one trigger
    unsigned int nValue = 10;

    nRet = MV_CC_SetBurstFrameCount(m_handle, nValue);
    if (MV_OK != nRet)
    {
        printf("error: SetBurstFrameCount fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetBurstFrameCount


MV_CC_GetImageInfo

Get basic image information

int MV_CC_GetImageInfo(
  void                   *handle,
  MV_IMAGE_BASIC_INFO    *pstInfo
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstInfo
[out] Basic image information

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get basic image information, including width, height, frame rate and resolution.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    else
    {
        unsigned int nAccessMode = MV_ACCESS_Exclusive;
        unsigned short nSwitchoverKey = 0;

        //Connect device
        nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
        if (MV_OK != nRet)
        {
            printf("error: OpenDevice fail [%x]\n", nRet);
            return;
        }
        //...other processing
    }

    //Get basic image information
    MV_IMAGE_BASIC_INFO mstruBasicInfo = {0};
    nRet = MV_CC_GetImageInfo(m_handle, &mstruBasicInfo);
    if (MV_OK != nRet)
    {
        printf("error: GetImageInfo fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_OpenDevice


MV_CC_GetWidth

Get image width information

int MV_CC_GetWidth(
  void             *handle,
  MVCC_INTVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Image width information

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get image width information, including current value, max. and min. supported value and increment.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get image width information
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetWidth(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetWidth fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetWidth


MV_CC_SetWidth

Set image width

int MV_CC_SetWidth(
  void                  *handle,
  const unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nValue
[in] Image width

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to set image width.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get image width information
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetWidth(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetWidth fail [%x]\n", nRet);
        return;
    }

    //Set image width
    unsigned int nValue = struIntValue.nMax; //Set current width as obtained max. value

    nRet = MV_CC_SetWidth(m_handle, nValue);
    if (MV_OK != nRet)
    {
        printf("error: SetWidth fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetWidth


MV_CC_GetHeight

Get image height information

int MV_CC_GetHeight(
  void             *handle,
  MVCC_INTVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Image height information

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get camera height information, including current value, max. and min. supported value and increment.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get camera image height information
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetHeight(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetHeight fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetHeight


MV_CC_SetHeight

Set camera image height

int MV_CC_SetHeight(
  void                  *handle,
  const unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nValue
[in] Image height

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to set camera height.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get camera image height information
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetHeight(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetHeight fail [%x]\n", nRet);
        return;
    }

    //Set camera image height
    unsigned int nValue = struIntValue.nMax; //Set current height to the max. obtained value

    nRet = MV_CC_SetHeight(m_handle, nValue);
    if (MV_OK != nRet)
    {
        printf("error: SetHeight fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetHeight


MV_CC_GetPixelFormat

Get image pixel format

int MV_CC_GetPixelFormat(
  void              *handle,
  MVCC_ENUMVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Pixel format, for detailed enumeration type value see: MvGvspPixelType

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get current pixel format.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get image pixel format
    MVCC_ENUMVALUE struEnumValue = {0};
    nRet = MV_CC_GetPixelFormat(m_handle, &struEnumValue);
    if (MV_OK != nRet)
    {
        printf("error: GetPixelFormat fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetPixelFormat


MV_CC_SetPixelFormat

Set image pixel format

int MV_CC_SetPixelFormat(
  void                  *handle,
  const unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nValue
[in] Pixel format, for detailed enumeration type value see: MvGvspPixelType

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to set current pixel format.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Set image pixel format
    unsigned int enValue = PixelType_Gvsp_YUV422_Packed;
    nRet = MV_CC_SetPixelFormat(m_handle, enValue);
    if (MV_OK != nRet)
    {
        printf("error: SetPixelFormat fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetPixelFormat


MV_CC_GetFrameRate

Get camera acquisition frame rate information

int MV_CC_GetFrameRate(
  void               *handle,
  MVCC_FLOATVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Acquisition frame rate information

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get camera acquisition frame rate, currently only getting current acquisition frame rate is supported, the max. and min. values are invalid.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get camera acquisition frame rate information
    MVCC_FLOATVALUE struFloatValue = {0};

    nRet = MV_CC_GetFrameRate(m_handle, &struFloatValue);
    if (MV_OK != nRet)
    {
        printf("error: GetFrameRate fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetFrameRate


MV_CC_SetFrameRate

Set frame rate

int MV_CC_SetFrameRate(
  void           *handle,
  const float    fValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
fValue
[in] Acquisition frame rate

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to set camera acquisition frame rate

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get camera acquisition frame rate
    MVCC_FLOATVALUE struFloatValue = {0};

    nRet = MV_CC_GetFrameRate(m_handle, &struFloatValue);
    if (MV_OK != nRet)
    {
        printf("error: GetFrameRate fail [%x]\n", nRet);
        return;
    }

    //Set camera acquisition frame rate
    float fValue = 25; //Set frame rate

    nRet = MV_CC_SetFrameRate(m_handle, fValue);
    if (MV_OK != nRet)
    {
        printf("error: SetFrameRate fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetFrameRate


MV_CC_GetAcquisitionLineRate

Get camera horizontal scanning frequency

int MV_CC_GetAcquisitionLineRate(
  void             *handle,
  MVCC_INTVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Horizontal scanning frequency

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Through this interface, get camera horizontal scanning frequency, including current value, max. and min. supported value, increment and other special parameters.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get camera horizontal scanning frequency
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetAcquisitionLineRate(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetAcquisitionLineRate fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetAcquisitionLineRate


MV_CC_SetAcquisitionLineRate

Set camera horizontal scanning frequency

int MV_CC_SetAcquisitionLineRate(
  void            *handle,
  unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nValue
[in] Horizontal scanning frequency

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Set horizontal scanning frequency through this interface, special parameter for machine vision camera.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Set horizontal scanning frequency
    unsigned int nValue = 1000;

    nRet = MV_CC_SetAcquisitionLineRate(m_handle, nValue);
    if (MV_OK != nRet)
    {
        printf("error: SetAcquisitionLineRate fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetAcquisitionLineRate


MV_CC_GetAOIoffsetX

Get AOI offset X value information

int MV_CC_GetAOIoffsetX(
  void             *handle,
  MVCC_INTVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] AOI offset X value information

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Through this interface, get AOI offset X coordinate information, including current value, max. and min. supported value and increment.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get AOI offset X value
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetAOIoffsetX(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetAOIoffsetX fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetAOIoffsetX MV_CC_GetAOIoffsetY MV_CC_SetAOIoffsetY


MV_CC_SetAOIoffsetX

Set AOI offset X value

int MV_CC_SetAOIoffsetX(
  void                  *handle,
  const unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nValue
[in] AOI offset X value

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Set AOI offset X coordinate through this interface, and the setting is only available when the width is under max. value: current width + max. X axis offset = max. width.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get AOI offset X value
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetAOIoffsetX(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetAOIoffsetX fail [%x]\n", nRet);
        return;
    }

    //Set AOI offset X value
    unsigned int nValue = struIntValue.nMax;  //Set as max. value

    nRet = MV_CC_SetAOIoffsetX(m_handle, nValue);
    if (MV_OK != nRet)
    {
        printf("error: SetAOIoffsetX fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetAOIoffsetX MV_CC_GetAOIoffsetY MV_CC_SetAOIoffsetY


MV_CC_GetAOIoffsetY

Get AOI offset Y value information

int MV_CC_GetAOIoffsetY(
  void             *handle,
  MVCC_INTVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] AOI offset Y value information

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Through this interface, get AOI offset Y coordinate information, including current value, max. and min. supported value and increment.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get AOI offset Y value
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetAOIoffsetY(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetAOIoffsetY fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetAOIoffsetX MV_CC_SetAOIoffsetX MV_CC_SetAOIoffsetY


MV_CC_SetAOIoffsetY

Set AOI offset Y value

int MV_CC_SetAOIoffsetY(
  void                  *handle,
  const unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nValue
[in] AOI offset Y value

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Set AOI offset X coordinate through this interface, and the setting is only available when the width is under max. value: current height + max. Y axis offset = max. height.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get AOI offset Y value
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetAOIoffsetY(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetAOIoffsetY fail [%x]\n", nRet);
        return;
    }

    //Get AOI offset Y value
    unsigned int nValue = struIntValue.nMax;   //Set as max. value
    nRet = MV_CC_SetAOIoffsetY(m_handle, nValue);
    if (MV_OK != nRet)
    {
        printf("error: SetAOIoffsetY fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetAOIoffsetX MV_CC_SetAOIoffsetX MV_CC_GetAOIoffsetY


MV_CC_GetGainMode

Get camera gain mode

int MV_CC_GetGainMode(
  void              *handle,
  MVCC_ENUMVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Gain mode, for detailed enumeration types see: MV_CAM_GAIN_MODE

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

  • After the device is connected, call this interface to get camera gain mode.
  • If the gain mode is MV_GAIN_MODE_OFF, the camera will not automatically set gain value. Call MV_CC_SetGain to set gain.
    If the gain mode is MV_GAIN_MODE_ONCE, the camera will adjust gain value once according to the environment, and then set gain mode to MV_GAIN_MODE_OFF.
    If the gain mode is MV_GAIN_MODE_CONTINUOUS, the camera will adjust the gain value according to environment.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get device gain mode
    MVCC_ENUMVALUE struEnumValue = {0};
    nRet = MV_CC_GetGainMode(m_handle, &struEnumValue);
    if (MV_OK != nRet)
    {
        printf("error: GetGainMode fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetGainMode


MV_CC_SetGainMode

Set camera gain mode

int MV_CC_SetGainMode(
  void                  *handle,
  const unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nValue
[in] Gain mode, for detailed enumeration types see: MV_CAM_GAIN_MODE

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

  • After the device is connected, call this interface to set camera gain mode.
  • If the gain mode is MV_GAIN_MODE_OFF, the camera will not automatically set gain value. Call MV_CC_SetGain to set gain.
    If the gain mode is MV_GAIN_MODE_ONCE, the camera will adjust gain value once according to the environment, and then set gain mode to MV_GAIN_MODE_OFF.
    If the gain mode is MV_GAIN_MODE_CONTINUOUS, the camera will adjust the gain value according to environment.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Set device gain mode
    unsigned int nValue = MV_GAIN_MODE_CONTINUOUS; //Continuous mode
    nRet = MV_CC_SetGainMode(m_handle, nValue);
    if (MV_OK != nRet)
    {
        printf("error: SetGainMode fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetGainMode


MV_CC_GetGain

Get camera current gain value

int MV_CC_GetGain(
  void               *handle,
  MVCC_FLOATVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Gain information

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Through this interface, get camera current gain value, including current value, max. and min. supported value.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get device gain
    MVCC_FLOATVALUE struFloatValue = {0};

    nRet = MV_CC_GetGain(m_handle, &struFloatValue);
    if (MV_OK != nRet)
    {
        printf("error: GetGain fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetGain


MV_CC_SetGain

Set camera current gain value

int MV_CC_SetGain(
  void           *handle,
  const float    fValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pfValue
[in] Gain value

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Set camera gain value through this interface.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get device gain
    MVCC_FLOATVALUE struFloatValue = {0};

    nRet = MV_CC_GetGain(m_handle, &struFloatValue);
    if (MV_OK != nRet)
    {
        printf("error: GetGainValue fail [%x]\n", nRet);
        return;
    }

    //Set device gain
    float fValue = struFloatValue.fMax;    //Set as max. gain value
    nRet = MV_CC_SetGain(m_handle, fValue);
    if (MV_OK != nRet)
    {
        printf("error: SetGain fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetGain


MV_CC_GetExposureAutoMode

Get camera auto exposure mode

int MV_CC_GetExposureAutoMode(
  void              *handle,
  MVCC_ENUMVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Auto exposure mode, for detailed enumeration type see: MV_CAM_EXPOSURE_AUTO_MODE

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

  • After the device is connected, call this interface to get camera auto exposure mode.
  • If exposure mode is MV_EXPOSURE_AUTO_MODE_OFF, the camera will not automatically adjust exposure time. Call MV_CC_SetExposureTime to set exposure time.
    If exposure mode is MV_EXPOSURE_AUTO_MODE_ONCE, the camera will adjust exposure time once according to the environment, and then set exposure mode to MV_EXPOSURE_AUTO_MODE_OFF.
    If exposure mode is MV_EXPOSURE_AUTO_MODE_CONTINUOUS, the camera will adjust the exposure time according to environment.
  • The camera will automatically adjust the exposure time between the set upper and lower limit, related interfaces: MV_CC_GetAutoExposureTimeLower, MV_CC_SetAutoExposureTimeLower, MV_CC_GetAutoExposureTimeUpper, MV_CC_SetAutoExposureTimeUpper.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get auto exposure mode
    MVCC_ENUMVALUE struEnumValue = {0};
    nRet = MV_CC_GetExposureAutoMode(m_handle, &struEnumValue);
    if (MV_OK != nRet)
    {
        printf("error: GetExposureAutoMode fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetExposureAutoMode


MV_CC_SetExposureAutoMode

Set camera auto exposure mode

int MV_CC_SetExposureAutoMode(
  void                  *handle,
  const unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nValue
[in] Auto exposure mode, for detailed enumeration type see: MV_CAM_EXPOSURE_AUTO_MODE

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

  • After the device is connected, call this interface to set camera auto exposure mode.
  • If exposure mode is MV_EXPOSURE_AUTO_MODE_OFF, the camera will not automatically adjust exposure time. Call MV_CC_SetExposureTime to set exposure time.
    If exposure mode is MV_EXPOSURE_AUTO_MODE_ONCE, the camera will adjust exposure time once according to the environment, and then set exposure mode to MV_EXPOSURE_AUTO_MODE_OFF.
    If exposure mode is MV_EXPOSURE_AUTO_MODE_CONTINUOUS, the camera will adjust the exposure time according to environment.
  • The camera will automatically adjust the exposure time between the set upper and lower limit, related interfaces: MV_CC_GetAutoExposureTimeLower, MV_CC_SetAutoExposureTimeLower, MV_CC_GetAutoExposureTimeUpper, MV_CC_SetAutoExposureTimeUpper.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Set auto exposure mode
    unsigned int nValue = MV_EXPOSURE_AUTO_MODE_ONCE; //One-push exposure mode
    nRet = MV_CC_SetExposureAutoMode(m_handle, nValue);
    if (MV_OK != nRet)
    {
        printf("error: SetExposureAutoMode fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetExposureAutoMode


MV_CC_GetAutoExposureTimeLower

Get camera auto exposure lower limit information

int MV_CC_GetAutoExposureTimeLower(
  void             *handle,
  MVCC_INTVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Auto exposure lower limit information

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Through this interface, get camera auto exposure lower limit value, including current value, max. and min. supported value and increment.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get device auto exposure lower limit
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetAutoExposureTimeLower(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetAutoExposureTimeLower fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetAutoExposureTimeLower


MV_CC_SetAutoExposureTimeLower

Set camera auto exposure lower limit value

int MV_CC_SetAutoExposureTimeLower(
  void                  *handle,
  const unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nValue
[in] Auto exposure lower limit value

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Set auto exposure lower limit value through this interface.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get auto exposure lower limit
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetAutoExposureTimeLower(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetAutoExposureTimeLower fail [%x]\n", nRet);
        return;
    }

    //Set auto exposure lower limit
    unsigned int nValue = struIntValue.nMax;   //Set as max. value
    nRet = MV_CC_SetAutoExposureTimeLower(m_handle, nValue);
    if (MV_OK != nRet)
    {
        printf("error: SetAutoExposureTimeLower fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetAutoExposureTimeLower


MV_CC_GetAutoExposureTimeUpper

Get camera auto exposure upper limit information

int MV_CC_GetAutoExposureTimeUpper(
  void             *handle,
  MVCC_INTVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Auto exposure upper limit information

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Through this interface, get camera auto exposure upper limit value, including current value, max. and min. supported value and increment.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get device auto exposure lower limit
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetAutoExposureTimeUpper(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetAutoExposureTimeUpper fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetAutoExposureTimeUpper


MV_CC_SetAutoExposureTimeUpper

Set camera auto exposure upper limit value

int MV_CC_SetAutoExposureTimeUpper(
  void                  *handle,
  const unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nValue
[in] Auto exposure upper limit value

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Set auto exposure upper limit value through this interface.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get auto exposure upper limit value
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetAutoExposureTimeUpper(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetAutoExposureTimeUpper fail [%x]\n", nRet);
        return;
    }

    //Set auto exposure upper limit value
    unsigned int nValue = struIntValue.nMax;   //Set as max. value

    nRet = MV_CC_SetAutoExposureTimeUpper(m_handle, nValue);
    if (MV_OK != nRet)
    {
        printf("error: SetAutoExposureTimeLower fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetAutoExposureTimeUpper


MV_CC_GetExposureTime

Get camera exposure value information

int MV_CC_GetExposureTime(
  void               *handle,
  MVCC_FLOATVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Exposure value information

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get camera exposure information, including current value, max. and min. supported value.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get camera exposure value
    MVCC_FLOATVALUE struFloatValue = {0};

    nRet = MV_CC_GetExposureTime(m_handle, &struFloatValue);
    if (MV_OK != nRet)
    {
        printf("error: GetExposureTime fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetExposureTime


MV_CC_SetExposureTime

Set camera exposure value

int MV_CC_SetExposureTime(
  void           *handle,
  const float    fValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
fValue
[in] Exposure value

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Set exposure value through this interface, setting exposure time will shut auto exposure mode, and the mode is switched to MV_EXPOSURE_AUTO_MODE_OFF.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get camera exposure value
    MVCC_FLOATVALUE struFloatValue = {0};

    nRet = MV_CC_GetExposureTime(m_handle, &struFloatValue);
    if (MV_OK != nRet)
    {
        printf("error: GetExposureTime fail [%x]\n", nRet);
        return;
    }

    //Set device gain
    float fValue = struFloatValue.fMax;    //Set as max. gain value
    nRet = MV_CC_SetExposureTime(m_handle, fValue);
    if (MV_OK != nRet)
    {
        printf("error: SetExposureTime fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetExposureTime


MV_CC_GetBrightness

Get camera image brightness information

int MV_CC_GetBrightness(
  void             *handle,
  MVCC_INTVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Image brightness information

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get image brightness information, including current value, max. and min. supported value and increment.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get camera image brightness information
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetBrightness(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetBrightness fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetBrightness


MV_CC_SetBrightness

Set camera image brightness

int MV_CC_SetBrightness(
  void                  *handle,
  const unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nValue
[in] Image brightness

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to set image brightness.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get camera image brightness information
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetBrightness(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetBrightness fail [%x]\n", nRet);
        return;
    }

    //Set camera image brightness
    unsigned int nValue = struIntValue.nMax; //Set as max. value

    nRet = MV_CC_SetBrightness(m_handle, nValue);
    if (MV_OK != nRet)
    {
        printf("error: SetBrightness fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetBrightness


MV_CC_GetSharpness

Get sharpness information

int MV_CC_GetSharpness(
  void             *handle,
  MVCC_INTVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Image sharpness information

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get sharpness information, including current value, max. and min. supported value and increment.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get image sharpness information
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetSharpness(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetSharpness fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetSharpness


MV_CC_SetSharpness

Set sharpness

int MV_CC_SetSharpness(
  void                  *handle,
  const unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nValue
[in] Image sharpness

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to set sharpness.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get image sharpness information
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetSharpness(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetSharpness fail [%x]\n", nRet);
        return;
    }

    //Set image sharpness
    unsigned int nValue = struIntValue.nMax; //Set as max. value

    nRet = MV_CC_SetSharpness(m_handle, nValue);
    if (MV_OK != nRet)
    {
        printf("error: SetSharpness fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetSharpness


MV_CC_GetHue

Get image hue information

int MV_CC_GetHue(
  void             *handle,
  MVCC_INTVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Hue information

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get hue information, including current value, max. and min. supported value and increment.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get hue information
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetHue(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetHue fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetHue


MV_CC_SetHue

Set image hue

int MV_CC_SetHue(
  void                  *handle,
  const unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nValue
[in] Image hue

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

  • After the device is connected, call this interface to set hue.
  • For black/white camera, return 0x80000100 (general GenIcam error) to mean not supported.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get hue information
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetHue(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetHue fail [%x]\n", nRet);
        return;
    }

    //Set hue
    unsigned int nValue = struIntValue.nMax; //Set as max. value

    nRet = MV_CC_SetHue(m_handle, nValue);
    if (MV_OK != nRet)
    {
        printf("error: SetHue fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetHue


MV_CC_GetSaturation

Get saturation information

int MV_CC_GetSaturation(
  void             *handle,
  MVCC_INTVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Image saturation information

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get saturation information, including current value, max. and min. supported value and increment.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get image saturation information
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetSaturation(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetSaturation fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetSaturation


MV_CC_SetSaturation

Set saturation

int MV_CC_SetSaturation(
  void                  *handle,
  const unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nValue
[in] Image saturation

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to set saturation. For black/white camera, return 0x80000100 (general GenIcam error) to mean not supported.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get image saturation information
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetSaturation(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetSaturation fail [%x]\n", nRet);
        return;
    }

    //Set image saturation
    unsigned int nValue = struIntValue.nMax; //Set as max. value

    nRet = MV_CC_SetSaturation(m_handle, nValue);
    if (MV_OK != nRet)
    {
        printf("error: SetSaturation fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetSaturation


MV_CC_GetGammaSelector

Get camera Gamma type

int MV_CC_GetGammaSelector(
  void              *handle,
  MVCC_ENUMVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Gamma type, for detailed enumeration type see: MV_CAM_GAMMA_SELECTOR

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get camera Gamma type.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get Gamma type
    MVCC_ENUMVALUE struEnumValue = {0};
    nRet = MV_CC_GetGammaSelector(m_handle, &struEnumValue);
    if (MV_OK != nRet)
    {
        printf("error: GetGammaSelector fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetGammaSelector


MV_CC_SetGammaSelector

Set camera Gamma type

int MV_CC_SetGammaSelector(
  void                  *handle,
  const unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nValue
[in] Gamma type, for detailed enumeration type see: MV_CAM_GAMMA_SELECTOR

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to set camera Gamma type. For custom type (MV_GAMMA_SELECTOR_USER), call MV_CC_GetGamma and MV_CC_SetGamma to get and set custom Gamma value.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Set Gamma type
    unsigned int enMode = MV_GAMMA_SELECTOR_SRGB; //Set Gamma type as sRGB
    nRet = MV_CC_SetGammaSelector(m_handle, enMode);
    if (MV_OK != nRet)
    {
        printf("error: SetGammaSelector fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetGammaSelector


MV_CC_GetGamma

Get camera Gamma value information

int MV_CC_GetGamma(
  void               *handle,
  MVCC_FLOATVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Gamma value information

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get camera Gamma information, including current value, max. and min. supported value.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get camera Gamma value
    MVCC_FLOATVALUE struFloatValue = {0};

    nRet = MV_CC_GetGamma(m_handle, &struFloatValue);
    if (MV_OK != nRet)
    {
        printf("error: GetGamma fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetGamma


MV_CC_SetGamma

Set camera Gamma value

int MV_CC_SetGamma(
  void           *handle,
  const float    fValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
fValue
[in] Gamma value

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Set camera Gamma value through this interface, Gamma Selector must be set as User (call MV_CC_SetGammaSelector to set) to set Gamma value. After calling this interface, the device will enable Gamma before setting Gamma value.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get camera Gamma value
    MVCC_FLOATVALUE struFloatValue = {0};

    nRet = MV_CC_GetGamma(m_handle, &struFloatValue);
    if (MV_OK != nRet)
    {
        printf("error: GetGamma fail [%x]\n", nRet);
        return;
    }

    //Set camera Gamma value
    unsigned int fValue = struFloatValue.fMax;    //Set as max. value
    nRet = MV_CC_SetGamma(m_handle, fValue);
    if (MV_OK != nRet)
    {
        printf("error: SetGamma fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetGamma


MV_CC_GetBalanceWhiteAuto

Get auto white balance mode

int MV_CC_GetBalanceWhiteAuto(
  void              *handle,
  MVCC_ENUMVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Auto white balance mode, for detailed enumeration type value see: MV_CAM_BALANCEWHITE_AUTO

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

  • After the device is connected, call this interface to get camera auto white balance mode.
  • If white balance mode is MV_BALANCEWHITE_AUTO_OFF, the camera will not automatically adjust white balance mode. Call MV_CC_SetBalanceRatioRed, MV_CC_SetBalanceRatioGreen, MV_CC_SetBalanceRatioBlue to set red, green and blue ratio of white balance mode.
    If white balance mode is MV_BALANCEWHITE_AUTO_ONCE, the camera will adjust white balance mode once according to the environment, and then set white balance mode to MV_BALANCEWHITE_AUTO_OFF.
    If white balance mode is MV_BALANCEWHITE_AUTO_CONTINUOUS, the camera will adjust the white balance mode according to environment.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get auto white balance mode
    MVCC_ENUMVALUE struEnumValue = {0};
    nRet = MV_CC_GetBalanceWhiteAuto(m_handle, &struEnumValue);
    if (MV_OK != nRet)
    {
        printf("error: GetBalanceWhiteAuto fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetBalanceWhiteAuto


MV_CC_SetBalanceWhiteAuto

Set auto white balance mode

int MV_CC_SetBalanceWhiteAuto(
  void                  *handle,
  const unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nValue
[in] Auto white balance mode, for detailed enumeration type value see: MV_CAM_BALANCEWHITE_AUTO

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

  • After the device is connected, call this interface to set camera auto white balance mode.
  • If white balance mode is MV_BALANCEWHITE_AUTO_OFF, the camera will not automatically adjust white balance mode. Call MV_CC_SetBalanceRatioRed, MV_CC_SetBalanceRatioGreen, MV_CC_SetBalanceRatioBlue to set red, green and blue ratio of white balance mode.
    If white balance mode is MV_BALANCEWHITE_AUTO_ONCE, the camera will adjust white balance mode once according to the environment, and then set white balance mode to MV_BALANCEWHITE_AUTO_OFF.
    If white balance mode is MV_BALANCEWHITE_AUTO_CONTINUOUS, the camera will adjust the white balance mode according to environment.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Set auto white balance mode
    unsigned int nValue = MV_BALANCEWHITE_AUTO_ONCE; //One-push white balance mode
    nRet = MV_CC_SetBalanceWhiteAuto(m_handle, nValue);
    if (MV_OK != nRet)
    {
        printf("error: SetBalanceWhiteAuto fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetBalanceWhiteAuto


MV_CC_GetBalanceRatioRed

Get camera image white balance red ratio information

int MV_CC_GetBalanceRatioRed(
  void             *handle,
  MVCC_INTVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Image white balance red ratio information

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get camera white balance red ratio information, including current value, max. and min. supported value and increment.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get camera white balance red ratio information
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetBalanceRatioRed(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetBalanceRatioRed fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetBalanceRatioRed


MV_CC_SetBalanceRatioRed

Set camera image white balance red ratio

int MV_CC_SetBalanceRatioRed(
  void                  *handle,
  const unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nValue
[in] Image white balance red ratio

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to set camera white balance red ratio

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get camera white balance red ratio
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetBalanceRatioRed(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetBalanceRatioRed fail [%x]\n", nRet);
        return;
    }

    //Set camera white balance red ratio
    unsigned int nValue = struIntValue.nMax; //Set as max. value

    nRet = MV_CC_SetBalanceRatioRed(m_handle, nValue);
    if (MV_OK != nRet)
    {
        printf("error: SetBalanceRatioRed fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetBalanceRatioRed


MV_CC_GetBalanceRatioGreen

Get camera image white balance green ratio information

int MV_CC_GetBalanceRatioGreen(
  void             *handle,
  MVCC_INTVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Image white balance green ratio information

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get camera white balance green ratio information, including current value, max. and min. supported value and increment.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get camera white balance green ratio information
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetBalanceRatioGreen(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetBalanceRatioGreen fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetBalanceRatioGreen


MV_CC_SetBalanceRatioGreen

Set camera image white balance green ratio

int MV_CC_SetBalanceRatioGreen(
  void                  *handle,
  const unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nValue
[in] Image white balance green ratio

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get camera white balance green ratio.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get camera white balance green ratio
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetBalanceRatioGreen(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetBalanceRatioGreen fail [%x]\n", nRet);
        return;
    }

    //Set camera white balance green ratio
    unsigned int nValue = struIntValue.nMax; //Set as max. value

    nRet = MV_CC_SetBalanceRatioGreen(m_handle, nValue);
    if (MV_OK != nRet)
    {
        printf("error: SetBalanceRatioGreen fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetBalanceRatioGreen


MV_CC_GetBalanceRatioBlue

Get camera image white balance blue ratio information

int MV_CC_GetBalanceRatioBlue(
  void             *handle,
  MVCC_INTVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Image white balance blue ratio information

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get camera white balance blue ratio information, including current value, max. and min. supported value and increment.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get camera white balance blue ratio information
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetBalanceRatioBlue(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetBalanceRatioBlue fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetBalanceRatioBlue


MV_CC_SetBalanceRatioBlue

Set camera image white balance blue ratio

int MV_CC_SetBalanceRatioBlue(
  void                  *handle,
  const unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nValue
[in] Image white balance blue ratio

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to set camera white balance blue ratio.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get camera white balance blue ratio
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetBalanceRatioBlue(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetBalanceRatioBlue fail [%x]\n", nRet);
        return;
    }

    //Set camera white balance blue ratio
    unsigned int nValue = struIntValue.nMax; //Set as max. value

    nRet = MV_CC_SetBalanceRatioBlue(m_handle, nValue);
    if (MV_OK != nRet)
    {
        printf("error: SetBalanceRatioBlue fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetBalanceRatioBlue


MV_CC_GetIntValue

Get camera int node value

int MV_CC_GetIntValue(
  void             *handle,
  const char       *strKey,
  MVCC_INTVALUE    *pIntValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
strKey
[in] Node name
pIntValue
[out] Obtained node value

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get specified int nodes. For value of strKey, see XML Node Parameter Type List. The node values of IInteger can be obtained through this interface, strKey value corresponds to the Name column.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get int parameter
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_CC_GetIntValue(m_handle, "Width", &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetIntValue fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetIntValue


MV_CC_SetIntValue

Set camera int node value

int MV_CC_SetIntValue(
  void            *handle,
  const char      *strKey,
  unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
strKey
[in] Node name
nValue
[in] Node Value

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to set specified int nodes. For value of strKey, see XML Node Parameter Type List. The node values of IInteger can be set through this interface, strKey value corresponds to the Name column.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Set int parameters
    unsigned int nValue = 752;

    nRet = MV_CC_SetIntValue(m_handle, "Width", nValue);
    if (MV_OK != nRet)
    {
        printf("error: SetIntValue fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetIntValue


MV_CC_GetStringValue

Get camera string node value

int MV_CC_GetStringValue(
  void                *handle,
  const char          *strKey,
  MVCC_STRINGVALUE    *pStringValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
strKey
[in] Node name
pStringValue
[out] Obtained node value

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get specified string nodes. For value of strKey, see XML Node Parameter Type List. The node values of IString can be obtained through this interface, strKey value corresponds to the Name column.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get string parameters
    MVCC_STRINGVALUE struStringValue = {0};

    nRet = MV_CC_GetStringValue(m_handle, "DeviceUserID", &struStringValue);
    if (MV_OK != nRet)
    {
        printf("error: GetStringValue fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetStringValue


MV_CC_SetStringValue

Set camera string node value

int MV_CC_SetStringValue(
  void          *handle,
  const char    *strKey,
  const char    *sValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
strKey
[in] Node name
sValue
[in] Node value

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to set specified string nodes. For value of strKey, see XML Node Parameter Type List. The node values of IString can be set through this interface, strKey value corresponds to the Name column.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Set string parameters
    nRet = MV_CC_SetStringValue(m_handle, "DeviceUserID", "HikCamera");
    if (MV_OK != nRet)
    {
        printf("error: SetStringValue fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetStringValue


MV_CC_GetBoolValue

Get camera bool node value

int MV_CC_GetBoolValue(
  void          *handle,
  const char    *strKey,
  bool          *pBoolValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
strKey
[in] Node name
pBoolValue
[out] Obtained node value

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get specified bool nodes. For value of strKey, see XML Node Parameter Type List. The node values of IBoolean can be obtained through this interface, strKey value corresponds to the Name column.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get bool parameters
    bool bValue = 0;

    nRet = MV_CC_GetBoolValue(m_handle, "ReverseX", &bValue);
    if (MV_OK != nRet)
    {
        printf("error: GetBoolValue fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetBoolValue


MV_CC_SetBoolValue

Set camera bool node value

int MV_CC_SetBoolValue(
  void          *handle,
  const char    *strKey,
  bool          pBoolValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
strKey
[in] Node name
pBoolValue
[in] Node value

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to set specified bool nodes. For value of strKey, see XML Node Parameter Type List. The node values of IBoolean can be set through this interface, strKey value corresponds to the Name column.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Set bool parameters
    bool nValue = TRUE;

    nRet = MV_CC_SetBoolValue(m_handle, "ReverseX", nValue);
    if (MV_OK != nRet)
    {
        printf("error: SetBoolValue fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetBoolValue


MV_CC_GetFloatValue

Get camera float node value

int MV_CC_GetFloatValue(
  void               *handle,
  const char         *strKey,
  MVCC_FLOATVALUE    *pFloatValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
strKey
[in] Node name
pFloatValue
[out] Obtained node value

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get specified float node. For detailed strKey value see: XML Node Parameter Type List. The node values of IFloat can be obtained through this interface, strKey value corresponds to the Name column.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get float parameters
    MVCC_FLOATVALUE struFloatValue = {0};

    nRet = MV_CC_GetFloatValue(m_handle, "TriggerDelay", &struFloatValue);
    if (MV_OK != nRet)
    {
        printf("error: GetFloatValue fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetFloatValue


MV_CC_SetFloatValue

Set camera float node value

int MV_CC_SetFloatValue(
  void          *handle,
  const char    *strKey,
  float         fValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
strKey
[in] Node name
fValue
[in] Node value

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to set specified float node. For detailed strKey value see: XML Node Parameter Type List. The node values of IFloat can be set through this interface, strKey value corresponds to the Name column.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Set float parameters
    float fValue = 0.0;

    nRet = MV_CC_SetFloatValue(m_handle, "TriggerDelay", fValue);
    if (MV_OK != nRet)
    {
        printf("error: SetFloatValue fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetFloatValue


MV_CC_GetEnumValue

Get camera Enum node value

int MV_CC_GetEnumValue(
  void              *handle,
  const char        *strKey,
  MVCC_ENUMVALUE    *pEnumValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
strKey
[in] Node name
pEnumValue
[out] Obtained node value

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get specified Enum nodes. For value of strKey, see XML Node Parameter Type List, The node values of IEnumeration can be obtained through this interface, strKey value corresponds to the Name column.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get Enum parameters
    MVCC_ENUMVALUE struEnumValue = {0};

    nRet = MV_CC_GetEnumValue(m_handle, "TriggerSource", &struEnumValue);
    if (MV_OK != nRet)
    {
        printf("error: GetEnumValue fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetEnumValue


MV_CC_SetEnumValue

Set camera Enum node value

int MV_CC_SetEnumValue(
  void            *handle,
  const char      *strKey,
  unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
strKey
[in] Node name
nValue
[in] Node value

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to get specified Enum nodes. For value of strKey, see XML Node Parameter Type List, The node values of IEnumeration can be obtained through this interface, strKey value corresponds to the Name column.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Set Enum parameters
    unsigned int enMode = MV_TRIGGER_SOURCE_SOFTWARE; //Set trigger as soft trigger

    nRet = MV_CC_SetEnumValue(m_handle, "TriggerSource", enMode);
    if (MV_OK != nRet)
    {
        printf("error: SetEnumValue fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_GetEnumValue


MV_CC_SetCommandValue

Set camera Command node

int MV_CC_SetCommandValue(
  void             *handle,
  const char       *strKey
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
strKey
[in] Node name

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to set specified Command nodes. For value of strKey, see XML Node Parameter Type List. The node values of ICommand can be set through this interface, strKey value corresponds to the Name column.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Set Command node
    nRet = MV_CC_SetCommandValue(m_handle, "TriggerSoftware");
    if (MV_OK != nRet)
    {
        printf("error: SetCommandValue fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;


MV_CC_LocalUpgrade

Device local upgrade

int MV_CC_LocalUpgrade(
  void          *handle,
  const void    *pFilePathName
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pFilePathName
[in] Upgrade pack path, including folder absolute path or relative path

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Send firmware to device for upgrade through this interface. The interface will return after the firmware is sent to device, and the process may cost longer time.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void*  m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    //Connect device
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Device local upgrade
    nRet = MV_CC_LocalUpgrade(m_handle, "C://digicap.dav");
    if (MV_OK != nRet)
    {
        printf("error: LocalUpgrade fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_OpenDevice MV_CC_GetUpgradeProcess


MV_CC_GetUpgradeProcess

Get current upgrade progress

int MV_CC_GetUpgradeProcess(
  void            *handle,
  unsigned int    *pnProcess
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pnProcess
[out] Current upgrade progress, 0 to 100

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Get upgrade progress percentage.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void*  m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Device local upgrade
    nRet = MV_CC_LocalUpgrade(m_handle, "C://digicap.dav");
    if (MV_OK != nRet)
    {
        printf("error: LocalUpgrade fail [%x]\n", nRet);
        return;
    }

    //Get upgrade progress
    unsigned int iProcess = 0;
    while(1)
    {
        nRet = MV_CC_GetUpgradeProcess(m_handle, &iProcess);
        if(iProcess == 100)
        {
            printf("Upgrade finished!\n");
            break;
        }
        Sleep(1000);
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_LocalUpgrade


MV_CC_ReadMemory

Read data from device register

int MV_CC_ReadMemory(
  void       *handle,
  void       *pBuffer,
  __int64    nAddress,
  __int64    nLength
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pBuffer
[out] Data buffer, saving memory value that is read (memory value is stored based on big endian mode)
nAddress
[in] Memory address to be read, the address can be obtained from Camera.xml, in a form similar to xml node value of xxx_RegAddr (Camera.xml will automatically generate in current program directory after the device is opened).
nLength
[in] Length of memory to be read

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Access device, read the data from certain register.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    else
    {
        unsigned int nAccessMode = MV_ACCESS_Exclusive;
        unsigned short nSwitchoverKey = 0;

        //Connect device
        nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
        if (MV_OK != nRet)
        {
            printf("error: OpenDevice fail [%x]\n", nRet);
            return;
        }
        //...other processing
    }

    //Read data from device register
    unsigned int nWidth = 0;
    nRet = MV_CC_ReadMemory(m_handle, &nWidth, 0x00030360L, 4L);
    if (MV_OK != nRet)
    {
        printf("error: ReadMemory [%x]\n", nRet);
        break;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_WriteMemory


MV_CC_WriteMemory

Write data into device register

int MV_CC_WriteMemory(
  void          *handle,
  const void    *pBuffer,
  __int64       nAddress,
  __int64       nLength
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pBuffer
[in] Memory value to be written (the value is to be stored according to big endian mode)
nAddress
[in] Memory address to be written, the address can be obtained from Camera.xml, in a form similar to xml node value of xxx_RegAddr (Camera.xml will automatically generate in current program directory after the device is opened).
nLength
[in] Length of memory to be written

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Access device, write a piece of data into a certain segment of register.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    else
    {
        unsigned int nAccessMode = MV_ACCESS_Exclusive;
        unsigned short nSwitchoverKey = 0;

        //Connect device
        nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
        if (MV_OK != nRet)
        {
            printf("error: OpenDevice fail [%x]\n", nRet);
            return;
        }
        //...other processing
    }

    //Read data from device register
    unsigned int nWidth = 0;
    nRet = MV_CC_ReadMemory(m_handle, &nWidth, 0x00030360L, 4L);
    if (MV_OK != nRet)
    {
        printf("error: ReadMemory [%x]\n", nRet);
        break;
    }

    // Write data into device register
    unsigned int nWidth = 320;
    nRet = MV_CC_WriteMemory(m_handle, &nWidth, 0x00030360L, 4L);
    if (MV_OK != nRet)
    {
        printf("error: WriteMemory [%x]\n", nRet);
        break;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_ReadMemory


MV_CC_GetAllMatchInfo

Get all type information

int MV_CC_GetAllMatchInfo(
  void                 *handle,
  MV_ALL_MATCH_INFO    *pstInfo
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstInfo
[in&out] Information structure

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

  • Input required information type (specify nType in structure MV_ALL_MATCH_INFO) in the interface and get corresponding information (return in pInfo of structure MV_ALL_MATCH_INFO).
  • The calling precondition of this interface is determined by obtained information type. Call after enabling capture to get MV_MATCH_TYPE_NET_DETECT information of GigE device, and call after starting device to get MV_MATCH_TYPE_USB_DETECT information of U3V device.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    else
    {
        unsigned int nAccessMode = MV_ACCESS_Exclusive;
        unsigned short nSwitchoverKey = 0;

        //Connect device
        nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
        if (MV_OK != nRet)
        {
            printf("error: OpenDevice fail [%x]\n", nRet);
            return;
        }
    }

    //...other processing

    //Start acquiring images
    nRet = MV_CC_StartGrabbing(m_handle);
    if (MV_OK != nRet)
    {
         printf("error: StartGrabbing fail [%x]\n", nRet);
        return;
    }

    Sleep(5000);

    //Get camera network data flow and packet loss information
    MV_ALL_MATCH_INFO struMatchInfo = {0};
    MV_MATCH_INFO_NET_DETECT stMatchInfoNetDetect;
    struMatchInfo.pInfo = &stMatchInfoNetDetect;

    struMatchInfo.nType = MV_MATCH_TYPE_NET_DETECT;
    memset(struMatchInfo.pInfo, 0, sizeof(MV_MATCH_INFO_NET_DETECT));
    struMatchInfo.nInfoSize = sizeof(MV_MATCH_INFO_NET_DETECT);

    nRet = MV_CC_GetAllMatchInfo(m_handle, &struMatchInfo);
    if (MV_OK != nRet)
    {
        printf("error: GetAllMatchInfo fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Stop acquiring images
    nRet = MV_CC_StopGrabbing(m_handle);
    if (MV_OK != nRet)
    {
        OutputString(_T("Operation: Stop Grabbing......failed!"));
        return;
    }

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_StartGrabbing


MV_XML_GetGenICamXML

Get camera XML description file

int MV_XML_GetGenICamXML(
  void             *handle,
  unsigned char    *pData,
  unsigned int     nDataSize,
  unsigned int     *pnDataLen
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pData
[in&out] Address of cache that saves XML file data
nDataSize
[in] Cache size
pnDataLen
[out] Length of XML file data

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Data will not be copied when pData is NULL or nDataSize is smaller than actual xml file, the actual xml file size is returned by pnDataLen;
When pData is valid cache address and big enough, the data will be copied to the cache, and the actual xml file size is returned by pnDataLen.

Example

Example code is for reference only.

#include "MvCameraControl.h"

#define MAX_XML_FILE_SIZE       (1024*1024*3)

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    unsigned char* pXMLBuf = (unsigned char*)malloc(MAX_XML_FILE_SIZE);
    if (NULL == pXMLBuf)
    {
        printf("error: malloc xml buffer failed!\n");
        break;
    }

   unsigned int nXMLDataLen = 0;
   nRet = MV_XML_GetGenICamXML(m_handle, pXMLBuf, MAX_XML_FILE_SIZE, &nXMLDataLen);
   if (MV_OK != nRet || nXMLDataLen > MAX_XML_FILE_SIZE)
   {
        printf("error: GetGenICamXML failed! [%x]\n", nRet);
        break;
   }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_OpenDevice


MV_XML_GetRootNode

Get root node

int MV_XML_GetRootNode(
  void                   *handle,
  MV_XML_NODE_FEATURE    *pstNode
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstNode
[out] Basic node properties

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Resolve XML to get root node through this interface, call after MV_CC_OpenDevice.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    //Connect device
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get XML root node
    MV_XML_NODE_FEATURE stRootNode;
    memset(&stRootNode, 0, sizeof(MV_XML_NODE_FEATURE));
    nRet = MV_XML_GetRootNode(handle, &stRootNode);
    if (MV_OK != nRet)
    {
        printf("error: GetRootNode fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_OpenDevice MV_XML_GetChildren MV_XML_GetNodeFeature


MV_XML_GetChildren

Get all sub nodes of a node

int MV_XML_GetChildren(
  void                   *handle,
  MV_XML_NODE_FEATURE    *pstNode,
  MV_XML_NODES_LIST      *pstNodesList
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstNode
[in] Parent node
pstNodesList
[out] Sub node list

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Resolve XML, get information of all sub nodes of a node.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    //Connect device
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get XML root node
    MV_XML_NODE_FEATURE stRootNode;
    memset(&stRootNode, 0, sizeof(MV_XML_NODE_FEATURE));
    nRet = MV_XML_GetRootNode(handle, &stRootNode);
    if (MV_OK != nRet)
    {
        printf("error: GetRootNode fail [%x]\n", nRet);
        return;
    }

    //Get sub node
    MV_XML_NODES_LIST stNodesList;
    memset(&stNodesList, 0, sizeof(MV_XML_NODES_LIST));
    nRet = MV_XML_GetChildren(handle, &stRootNode, &stNodesList);
    if (MV_OK != nRet)
    {
        printf("error: GetChildren fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_XML_GetRootNode MV_XML_GetNodeFeature


MV_XML_GetNodeFeature

Get detailed information of a node

int MV_XML_GetNodeFeature(
  void                   *handle,
  MV_XML_NODE_FEATURE    *pstNode,
  void                   *pstFeature
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstNode
[in] Node information
pstFeature
[out] Address of storage of detailed node information, different node types correspond to different information structures.

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Resolve basic node information and get detailed node information, different node types correspond to different information structures. The interface only supports getting sub node detailed information below:

pstNode->enType Node Type | Value | pstFeature Information Structure
IFT_IInteger | 3 | MV_XML_FEATURE_Integer
IFT_IBoolean | 4 | MV_XML_FEATURE_Boolean
IFT_ICommand | 5 | MV_XML_FEATURE_Command
IFT_IFloat | 6 | MV_XML_FEATURE_Float
IFT_IString | 7 | MV_XML_FEATURE_String
IFT_IRegister | 8 | MV_XML_FEATURE_Register
IFT_IEnumeration | 10 | MV_XML_FEATURE_Enumeration
IFT_IEnumEntry | 11 | MV_XML_FEATURE_EnumEntry
IFT_IPort | 12 | MV_XML_FEATURE_Port

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    //Connect device
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get XML root node
    MV_XML_NODE_FEATURE stRootNode;
    memset(&stRootNode, 0, sizeof(MV_XML_NODE_FEATURE));
    nRet = MV_XML_GetRootNode(handle, &stRootNode);
    if (MV_OK != nRet)
    {
        printf("error: GetRootNode fail [%x]\n", nRet);
        return;
    }

    //Get detailed node information
    MV_XML_NODE_FEATURE stNode;
    memset(&stNode, 0, sizeof(MV_XML_NODE_FEATURE));
    stNode.enType = IFT_IInteger;
    strcpy(stNode.strName, "Width");

    MV_XML_FEATURE_Integer stFeatureInteger;
    memset(&stFeatureInteger, 0, sizeof(MV_XML_FEATURE_Integer));

    nRet = MV_XML_GetNodeFeature(m_handle, &stNode, &stFeatureInteger);
    if (MV_OK != nRet)
    {
        printf("error: GetNodeFeature fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_OpenDevice


MV_XML_UpdateNodeFeature

Set property value of a node

int MV_XML_UpdateNodeFeature(
  void                    *handle,
  MV_XML_InterfaceType    enType,
  void                    *pstFeature
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
enType
[in] Node type, for details see: MV_XML_InterfaceType
pstFeature
[in] Node information, for details see "Remarks"

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After getting the detailed information of a node, call this interface to set its properties. The interface only supports getting sub node detailed information below:

enType Node Type | Value | pstFeature Information Structure
IFT_IInteger | 3 | MV_XML_FEATURE_Integer
IFT_IBoolean | 4 | MV_XML_FEATURE_Boolean
IFT_ICommand | 5 | MV_XML_FEATURE_Command
IFT_IFloat | 6 | MV_XML_FEATURE_Float
IFT_IString | 7 | MV_XML_FEATURE_String
IFT_IEnumeration | 10 | MV_XML_FEATURE_Enumeration

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    //Connect device
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get XML root node
    MV_XML_NODE_FEATURE stRootNode;
    memset(&stRootNode, 0, sizeof(MV_XML_NODE_FEATURE));
    nRet = MV_XML_GetRootNode(handle, &stRootNode);
    if (MV_OK != nRet)
    {
        printf("error: GetRootNode fail [%x]\n", nRet);
        return;
    }

    //Get detailed node information
    MV_XML_NODE_FEATURE stNode;
    memset(&stNode, 0, sizeof(MV_XML_NODE_FEATURE));
    stNode.enType = IFT_IInteger;
    strcpy(stNode.strName, "Width");

    MV_XML_FEATURE_Integer stFeatureInteger;
    memset(&stFeatureInteger, 0, sizeof(MV_XML_FEATURE_Integer));

    nRet = MV_XML_GetNodeFeature(m_handle, &stNode, &stFeatureInteger);
    if (MV_OK != nRet)
    {
        printf("error: GetNodeFeature fail [%x]\n", nRet);
        return;
    }

    //Set node property value
    enType = IFT_IInteger;
    stFeatureInteger.enVisivility = 0; //Always visible
    nRet = MV_XML_UpdateNodeFeature(m_handle, enType, &stFeatureInteger);
    if (MV_OK != nRet)
    {
        printf("error: UpdateNodeFeature fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_XML_GetNodeFeature


MV_XML_RegisterUpdateCallBack

Register XML node properties update callback (when node properties are updated, the registered callback function cbUpdate will return related nodes in pstNodesList).

int MV_XML_RegisterUpdateCallBack(
  void        *handle,
  cbUpdate    fUpdateCallBack,
  void        *pUser
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
fUpdateCallBack
[in] Properties update callback function
pUser
[in] User data

Callback Function

void(__stdcall* cbUpdate)(
  MV_XML_InterfaceType    enType,
  void                    *pstFeature,
  MV_XML_NODES_LIST       *pstNodesList,
  void                    *pUser
);

Callback Function Parameters

enType
[out] Node type, for details see: MV_XML_InterfaceType
pstFeature
[out] Node properties information, for details see "Remarks"
pstNodesList
[out] Node list
pUser
[out] User data

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

pstFeature is the input information when updating, and can be converted to specified structure according to enType, and only strName and nValue of the structure are valid. The interface only supports the update callback information of the following nodes:

enType Node Type | Value | pstFeature Information Structure
IFT_IInteger | 3 | MV_XML_FEATURE_Integer
IFT_IBoolean | 4 | MV_XML_FEATURE_Boolean

Example

Example code is for reference only.

#include "MvCameraControl.h"

//Properties update callback function
void __stdcall MyCbFunc(MV_XML_InterfaceType enType, void* pstFeature, MV_XML_NODES_LIST* pstNodesList, void* pUser)
{
    for (int i = 0; i < pstNodesList->nNodeNum; i++)
    {
        MV_XML_InterfaceType enType = pstNodesList->stNodes[i].enType;
        printf("UpdateCallBack: Interface type [%d]\n", enType);
    }
}

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Register node properties update callback function
    nRet = MV_XML_RegisterUpdateCallBack(m_handle, MyCbFunc, NULL);
    if (MV_OK != nRet)
    {
        printf("error: RegisterUpdateCallBack fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_CreateHandle


MV_GIGE_ForceIp

Force set camera IP

int MV_GIGE_ForceIp(
  void            *handle,
  unsigned int    nIP
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nIP
[in] IP address to set

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Force set device IP address, only supported by GigEVision cameras.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Set device IP address
    unsigned int nIP = 0x0a0f0636; //10.15.6.54
    nRet = MV_GIGE_ForceIp(m_handle, nIP);
    if (MV_OK != nRet)
    {
        printf("error: ForceIp fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_CreateHandle


MV_GIGE_SetIpConfig

Configure IP mode

int MV_GIGE_SetIpConfig(
  void            *handle,
  unsigned int    nType
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nType
[in] IP configuration mode, for details see below:
Macro Definition | Value | Description
MV_IP_CFG_STATIC | 0x05000000 | Static mode
MV_IP_CFG_DHCP | 0x06000000 | DHCP mode
MV_IP_CFG_LLA | 0x04000000 | LLA(Link-local address)

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Send command to set camera IP mode, such as DHCP and LLA, only supported by GigEVision.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }

    //Set device IP address
    unsigned int nType = MV_IP_CFG_STATIC; //Static mode
    nRet = MV_GIGE_SetIpConfig(m_handle, nType);
    if (MV_OK != nRet)
    {
        printf("error: SetIpConfig fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_OpenDevice


MV_GIGE_SetNetTransMode

Set SDK internal priority network mode

int MV_GIGE_SetNetTransMode(
  void            *handle,
  unsigned int    nType
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nType
[in] Network mode, for details see below:
Macro Definition | Value | Description
MV_NET_TRANS_DRIVER | 0x00000001 | Driver mode
MV_NET_TRANS_SOCKET | 0x00000002 | Socket mode

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Set SDK internal priority network mode through this interface, driver mode by default, only supported by GigEVision camera.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }

    //Set priority network mode
    unsigned int nType = MV_NET_TRANS_SOCKET; //Socket mode
    nRet = MV_GIGE_SetNetTransMode(m_handle, nType);
    if (MV_OK != nRet)
    {
        printf("error: SetNetTransMode fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_CreateHandle


MV_GIGE_GetNetTransInfo

Get network transmission information

int MV_GIGE_GetNetTransInfo(
  void                *handle,
  MV_NETTRANS_INFO    *pstInfo
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstInfo
[out] Network transmission information, including received data size, number of lost frames

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Get network transmission information through this interface, including received data size, number of lost frames. Call this interface after start image acquiring through MV_CC_StartGrabbing.

Example

Example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

#define MAX_BUF_SIZE    (1920*1080*3)

void main()
{
     int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    else
    {
        unsigned int nAccessMode = MV_ACCESS_Exclusive;
        unsigned short nSwitchoverKey = 0;

        //Connect device
        nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
        if (MV_OK != nRet)
        {
            printf("error: OpenDevice fail [%x]\n", nRet);
            return;
        }
        //...other processing
    }

    //Start acquiring image
    nRet = MV_CC_StartGrabbing(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing fail [%x]\n", nRet);
        return;
    }

    unsigned int    nTestFrameSize = 0;
    unsigned char*  g_pFrameBuf = NULL;
    g_pFrameBuf = (unsigned char*)malloc(MAX_BUF_SIZE);

    MV_FRAME_OUT_INFO stInfo;
    memset(&stInfo, 0, sizeof(MV_FRAME_OUT_INFO));

    MV_NETTRANS_INFO stNetTransInfo = {0};

    //The frequency of calling this interface should be controlled by upper layer application according to frame rate.
    //The codes are for reference only. In practical application, it is recommended to create a new thread for image acquisition and processing.
    while(1)
    {
        if (nTestFrameSize > 99)
        {
            break;
        }
        nRet = MV_CC_GetOneFrame(m_handle, g_pFrameBuf, MAX_BUF_SIZE, &stInfo);
        if (MV_OK != nRet)
        {
            Sleep(10);
        }
        else
        {
            //...Image data processing

            // Get network transmission information
            if ((nTestFrameSize % 10) == 0)
            {
                nRet = MV_GIGE_GetNetTransInfo(m_handle, &stNetTransInfo);
                if(MV_OK == nRet)
                {
                    printf("GetDataSize [%I64d]\n", stNetTransInfo.nReviceDataSize);
                }
            }

            nTestFrameSize++;
        }
    }

    //...other processing

    //Stop acquiring image
    nRet = MV_CC_StopGrabbing(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: StopGrabbing fail [%x]\n", nRet);
        return;
    }

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_CreateHandle


MV_GIGE_GetGevSCPSPacketSize

Get SCPS packet size

int MV_GIGE_GetGevSCPSPacketSize(
  void             *handle,
  MVCC_INTVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] SCPS packet size

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Get SCPS packet size, including current value, max. and min. supported value and increment, only supported by GigEVision camera.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Ger SCPS packet size
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_GIGE_GetGevSCPSPacketSize(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetGevSCPSPacketSize fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_GIGE_SetGevSCPSPacketSize


MV_GIGE_SetGevSCPSPacketSize

Set SCPS packet size

int MV_GIGE_SetGevSCPSPacketSize(
  void                 *handle,
  const unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nValue
[in] SCPS packet size

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Set SCPS packet size through this interface, only supported by GigEVision camera. The packet size is determined by system MTU value size and cannot exceed it. To set system MTU value see:

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get SCPS packet size information
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_GIGE_GetGevSCPSPacketSize(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetGevSCPSPacketSize fail [%x]\n", nRet);
        return;
    }

    //Set SCPS packet size
    unsigned int nValue = struIntValue.nMax; //Set as max. value
    nRet = MV_GIGE_SetGevSCPSPacketSize(m_handle, nValue);
    if (MV_OK != nRet)
    {
        printf("error: SetGevSCPSPacketSize fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_GIGE_GetGevSCPSPacketSize


MV_GIGE_GetGevSCPD

Get network packet sending interval information

int MV_GIGE_GetGevSCPD(
  void             *handle,
  MVCC_INTVALUE    *pstValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pstValue
[out] Network packet sending interval information

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Get network packet sending interval, including current value, max. and min. supported value and increment, only supported by GigEVision camera.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get network packet sending interval information
    MVCC_INTVALUE struIntValue = {0};

    nRet = MV_GIGE_GetGevSCPD(m_handle, &struIntValue);
    if (MV_OK != nRet)
    {
        printf("error: GetGevSCPD fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_GIGE_SetGevSCPD


MV_GIGE_SetGevSCPD

Set network packet sending interval

int MV_GIGE_SetGevSCPD(
  void            *handle,
  unsigned int    nValue
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nValue
[in] SCPS packet size

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

  • Get network packet sending interval through this interface, only supported by GigEVision camera.
  • The interface must be called after opening device and before enabling capture.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get network packet sending interval information
    unsigned int nValue = 0; //Current value
    unsigned int nMax = 0;   //Max. value
    unsigned int nMin = 0;   //Min. value
    unsigned int nInc = 0;   //Increment

    nRet = MV_GIGE_GetGevSCPD(m_handle, &nValue, &nMax, &nMin, &nInc);
    if (MV_OK != nRet)
    {
        printf("error: MV_GIGE_GetGevSCPD fail [%x]\n", nRet);
        return;
    }

    //Set network packet sending interval
    nValue = nMax;          //Set as max. value
    nRet = MV_GIGE_SetGevSCPD(m_handle, nValue);
    if (MV_OK != nRet)
    {
        printf("error: SetGevSCPD fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_GIGE_GetGevSCPD


MV_GIGE_GetGevSCDA

Get receiving terminal IP address

int MV_GIGE_GetGevSCDA(
  void            *handle,
  unsigned int    *pnIP
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pnIP
[out] Receiving terminal IP address

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Get the IP address of receiving terminal through this interface, and get the port of receiving terminal through MV_GIGE_GetGevSCSP. The camera will send image data to specified IP address and port, only supported by GigEVision.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }

    //Start acquiring image
    nRet = MV_CC_StartGrabbing(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Get IP address of receiving terminal
    unsigned int nIP = 0;

    nRet = MV_GIGE_GetGevSCDA(m_handle, &nIP);
    if (MV_OK != nRet)
    {
        printf("error: GetGevSCDA fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_GIGE_SetGevSCDA


MV_GIGE_SetGevSCDA

Set receiving terminal IP address

int MV_GIGE_SetGevSCDA(
  void            *handle,
  unsigned int    nIP
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nIP
[in] Receiving terminal IP address

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

  • Set the IP address of receiving terminal through this interface, and get the port of receiving terminal through MV_GIGE_SetGevSCSP. The camera will send image data to specified IP address and port, only supported by GigEVision.
  • The interface cannot be called after streaming started, otherwise access permission error will return (0x80000106).
  • The interface is not supported in current version.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Set IP address of receiving terminal
    unsigned int nIP = 0x0a0f0637; //10.15.6.55

    nRet = MV_GIGE_SetGevSCDA(m_handle, nIP);
    if (MV_OK != nRet)
    {
        printf("error: SetGevSCDA fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_GIGE_GetGevSCDA


MV_GIGE_GetGevSCSP

Get receiving terminal port No.

int MV_GIGE_GetGevSCSP(
  void            *handle,
  unsigned int    *pnPort
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
pnPort
[out] Receiving terminal port No.

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

Get the port No. of receiving terminal through this interface, and get the IP address of receiving terminal through MV_GIGE_GetGevSCDA. The camera will send image data to specified IP address and port, only supported by GigEVision.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Get port No. of receiving terminal
    unsigned int nPort = 0;

    nRet = MV_GIGE_GetGevSCSP(m_handle, &nPort);
    if (MV_OK != nRet)
    {
        printf("error: GetGevSCSP fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_GIGE_SetGevSCSP


MV_GIGE_SetGevSCSP

Set receiving terminal port No.

int MV_GIGE_SetGevSCSP(
  void            *handle,
  unsigned int    nPort
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nPort
[in] Receiving terminal port No.

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

  • Set the port No. of receiving terminal through this interface, and get the IP address of receiving terminal through MV_GIGE_SetGevSCDA. The camera will send image data to specified IP address and port, only supported by GigEVision.
  • The interface cannot be called after streaming started, otherwise access permission error will return (0x80000106).
  • The interface is not supported in current version.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Set port No. of receiving terminal
    unsigned int nIP = 8000;

    nRet = MV_GIGE_SetGevSCSP(m_handle, nIP);
    if (MV_OK != nRet)
    {
        printf("error: SetGevSCDP fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_GIGE_GetGevSCSP


MV_GIGE_SetGvcpTimeout

Set GVCP command timeout time

int MV_GIGE_SetGvcpTimeout(
  void            *handle,
  unsigned int    nMillisec
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
nMillisec
[in] Heartbeat time, unit: ms

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to set GVCP command timeout time.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Set GVCP command timeout time
    unsigned int nMillisec = 100; //ms
    nRet = MV_GIGE_SetGvcpTimeout(m_handle, nMillisec);
    if (MV_OK != nRet)
    {
        printf("error: SetGvcpTimeout fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;


MV_GIGE_SetResend

Set resend packet properties

int MV_GIGE_SetResend(
  void            *handle,
  unsigned int    bEnable,
  unsigned int    nMaxResendPercent,
  unsigned int    nResendTimeout
);

Parameters

handle
[in] Device handle, return value of MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.
bEnable
[in] Enable resend packet: 0- no, 1- yes
nMaxResendPercent
[in] Max. resend packet percentage, range: 0 to 100
nResendTimeout
[in] Resend packet timeout time, unit: ms

Return Values

Return MV_OK(0) on success; return error code on failure.

Remarks

After the device is connected, call this interface to set resend packet properties, only supported by GigEVision camera.

Example

Example code is for reference only.

#include "MvCameraControl.h"

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;

    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing

    //Set resend packet properties
    nRet = MV_GIGE_SetResend(m_handle, 1, 1, 100);
    if (MV_OK != nRet)
    {
        printf("error: MV_GIGE_SetResend fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

See Also

MV_CC_SetHeartBeatTimeout


MvCamCtrl::CTlFactory::GetInstance

Get transport layer factory example.

static CTlFactory& GetInstance(
);

Return Values

Return transport layer factory example: CTlFactory example

Example

The example code is for reference only.

#include "TlFactory.h"
using namespace MvCamCtrl;

void main()
{
    // Get single transport layer example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Call the interface in the example
    unsigned int nSupportedTls = tlFactory.EnumerateTls();

    //...Other processes
}

See Also

MvCamCtrl::CTlFactory::EnumerateTls MvCamCtrl::CTlFactory::EnumDevices MvCamCtrl::CTlFactory::CreateDevice MvCamCtrl::CTlFactory::DestroyDevice


MvCamCtrl::CTlFactory::GetSDKVersion

Get SDK version No..

virtual unsigned int GetSDKVersion(
);

Return Values

Return SDK version No.:
|Major |Minor |Revise | Test
|8bits |8bits |8bits |8bits

Remarks

For example, if the return value is 0x01000001, the SDK version No. is V1.0.0.1

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;
    unsigned int SDKVersion = -1;

    // Get factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    SDKVersion = tlFactory.GetSDKVersion();
}

See Also

MvCamCtrl::CTlFactory::GetInstance


MvCamCtrl::CTlFactory::EnumerateTls

Transport layer types supported by enumeration.

unsigned int EnumerateTls(
);

Return Values

Return supported transport layer types, which are marked with bit and support reset, the optional protocol types are listed below:

Macro Definition | Value | Description
MV_UNKNOW_DEVICE | 0x00000000 | Unknown device type
MV_GIGE_DEVICE | 0x00000001 | GigE device
MV_1394_DEVICE | 0x00000002 | 1394-a/b device
MV_USB_DEVICE | 0x00000004 | USB3.0 device
MV_CAMERALINK_DEVICE | 0x00000008 | CameraLink device

For example: nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE, which means searching GigE and USB3.0 device

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
using namespace MvCamCtrl;

void main()
{
    // Get single transport layer example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Call the interface in the example
    unsigned int nSupportedTls = tlFactory.EnumerateTls();
    if (MV_GIGE_DEVICE == (nSupportedTls & MV_GIGE_DEVICE))
    {
        //Support GigE Vision transport protocol, the following operation is for the device supports this protocol
    }
    //...Other processes
}

See Also

MvCamCtrl::CTlFactory::GetInstance


MvCamCtrl::CTlFactory::EnumDevices

Enumerate all the devices of specified transport protocol within the subnet.

virtual int EnumDevices(
  unsigned int              nTLayerType,
  MV_CC_DEVICE_INFO_LIST    &stDevList,
);

Parameters

nTLayerType
[in] Transport layer protocol types, which are marked with bit and support reset, the optional protocol types are listed below:
Macro Definition | Value | Description
MV_UNKNOW_DEVICE | 0x00000000 | Unknown device type
MV_GIGE_DEVICE | 0x00000001 | GigE device
MV_1394_DEVICE | 0x00000002 | 1394-a/b device
MV_USB_DEVICE | 0x00000004 | USB3.0 device
MV_CAMERALINK_DEVICE | 0x00000008 | CameraLink device
For example: nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE, which means searching GigE and USB3.0 device
stDevList
[out] The found device information list

Return Values

Successed, return MV_OK（0）; failed, return Error Code.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }
    //...Other processes
}

See Also

MvCamCtrl::CTlFactory::GetInstance


MvCamCtrl::CTlFactory::CreateDevice

Create device example.

virtual IMvDevice* CreateDevice(
  const MV_CC_DEVICE_INFO    &device
);

Parameters

device
[in] Device information, including device version, MAC address, transport layer type and others.

Return Values

Successed, return device example; failed, return NULL.

Remarks

Create device objects of corresponding types according to the inputted device information.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    IMvDevice* MyDevice = tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i]));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }
    //...Other processes
}

See Also

MvCamCtrl::CTlFactory::GetInstance MvCamCtrl::CTlFactory::DestroyDevice


MvCamCtrl::CTlFactory::DestroyDevice

Destroy device example and corresponding resources.

virtual int DestroyDevice(
  IMvDevice*    pDevice
);

Parameters

pDevice
[in] Device example（IMvDevice）

Return Values

Successed, return MV_OK（0）; failed, return Error Code.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first found online devices and create device example
    int i=0;
    IMvDevice* MyDevice = tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i]));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Destroy device from factory
    nRet = tlFactory.DestroyDevice(MyDevice);
    if (MV_OK != nRet)
    {
        printf("error: DestroyDevice fail [%x]\n", nRet);
    }
    //...Other processes
}

See Also

MvCamCtrl::CTlFactory::CreateDevice


MvCamCtrl::CTlFactory::IsDeviceAccessible

Judge whether the specified device is accessible.

virtual bool IsDeviceAccessible(
  const MV_CC_DEVICE_INFO&    deviceInfo
);

Parameters

deviceInfo
[in] Specified device information

Return Values

Return true means accessable; return false means no permission or device is offline.

Remarks

Read device CCP register value, judge whether the current status has an accessing permission.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first found online devices and judge whether the device is accessable
    if(!tlFactory.IsDeviceAccessible(*(stDevList.pDeviceInfo[i])))
    {
        printf("error: IsDeviceAccessible\n");
        break;
    }

    // Select the first found online devices and create device example
    int i=0;
    IMvDevice* MyDevice = tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i]));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }
    //...Other processes
}

See Also

MvCamCtrl::CTlFactory::GetInstance


MvCamCtrl::CMvGigEDevice::RegisterExceptionCallBack

Register exception message callback function.

virtual int RegisterExceptionCallBack(
  cbException    fExceptionCallBack,
  void           *pUser
);

Parameters

fExceptionCallBack
[in] Callback function of receiving exception message
pUser
[in] User data

Callback Function

void(__stdcall* cbException)(
  unsigned int    nMsgType,
  void            *pUser
);

Callback Function Parameters

nMsgType
[out] Exception Message type
pUser
[out] User data

Return Values

Successed, return MV_OK（0）; failed, return Error Code.

Remarks

This interface should be called after opening device via MvCamCtrl::CMvGigEDevice::Open. Get exception message in the callback after device is disconnected. If GigE device is offline, you should first call MvCamCtrl::CTlFactory::DestroyDevice to close device, and then call MvCamCtrl::CTlFactory::CreateDevice to open device again.

The macro definitions of exception message types are listed below:

Macro Definition | Value | Description
MV_GIGE_EXCEPTION_DEV_DISCONNECT | 0x00008001 | Device disconnected

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

//Exception callback function
void __stdcall ExceptionCB(unsigned int nMsgType, void* pUser)
{
    printf("Exception message is: 0x%x", nMsgType);
}

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    // Register exception message callback function
    nRet = MyDevice->RegisterExceptionCallBack(ExceptionCB, NULL);
    if (MV_OK != nRet)
    {
         printf("error: RegisterExceptionCallBack [%x]\n", nRet);
    }

    //...Device operations

    // Close device
    nRet = MyDevice->Close();
    if (MV_OK != nRet)
    {
        printf("error: Close fail [%x]\n", nRet);
    }

    //...Other processes
}

See Also

MvCamCtrl::CTlFactory::CreateDevice


MvCamCtrl::CMvGigEDevice::RegisterEventCallBack

Register event callback function.

virtual int RegisterEventCallBack(
  cbEvent    fEventCallBack,
  void       *pUser
);

Parameters

fEventCallBack
[in] Callback function for receiving event
pUser
[in] User data

Callback Function

void(__stdcall* cbEvent)(
  unsigned int    nExternalEventId,
  void            *pUser
);

Callback Function Parameters

nExternalEventId
[out] External output, see value definitions in Enumeration Type: MV_GIGE_EVENT
pUser
[out] User data

Return Values

Successed, return MV_OK（0); failed, return Error Code.

Remarks

Set event callback via this interface, you can get the event information, such as acquisition, exposure and so on in the callback function.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

//Callback function exception
void __stdcall EventCallBack(unsigned int nExternalEventId, void* pUser)
{
    switch(nUserDefinedId)
    {
    case MV_EVENT_ExposureEnd:
        printf("ExposureEnd!\n");
        break;
    case MV_EVENT_FrameStartOvertrigger:
        printf("FrameStartOvertrigger!\n");
        break;
    case MV_EVENT_AcquisitionStartOvertrigger:
        printf("AcquisitionStartOvertrigger!\n");
        break;
    case MV_EVENT_FrameStart:
        printf("FrameStart!\n");
        break;
    case MV_EVENT_AcquisitionStart:
        printf("AcquisitionStart!\n");
        break;
    case MV_EVENT_EventOverrun:
        printf("EventOverrun!\n");
        break;
    default:
        printf("no such eventId[%d]\n", nUserDefinedId);
    }
}

void main()
{
   int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    //Register event callback function
    nRet = MyDevice->RegisterEventCallBack(EventCallBack, NULL);
    if (MV_OK != nRet)
    {
        printf("error: RegisterEventCallBack fail [%x]\n", nRet);
        return;
    }

    // Start image acquisition
    nRet = MyDevice->StartGrabbing();
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing [%x]\n", nRet);
        break;
    }

    //...Other processes

    // Stop image acquisition
    nRet = MyDevice->StopGrabbing();
    if (MV_OK != nRet)
    {
         printf("error: StopGrabbing fail [%x]\n", nRet);
    }

    // Close device
    nRet = MyDevice->Close();
    if (MV_OK != nRet)
    {
        printf("error: Close fail [%x]\n", nRet);
    }

    // Destroy device from factory
    nRet = tlFactory.DestroyDevice(MyDevice);
    if (MV_OK != nRet)
    {
        printf("error: DestroyDevice fail [%x]\n", nRet);
    }
}

See Also

MvCamCtrl::CTlFactory::CreateDevice


MvCamCtrl::CMvGigEDevice::RegisterImageCallBack

Register image data callback function.

virtual int RegisterImageCallBack(
  cbOutput    fOutputCallBack,
  void        *pUser
);

Parameters

fOutputCallBack
[in] Image data callback function
pUser
[in] User data

Callback Function

void(__stdcall* cbOutput)(
  unsigned char        *pData,
  MV_FRAME_OUT_INFO    *pFrameInfo
  void                 *pUser
);

Callback Function Parameters

pData
[out] Cache address used for saving image data
pFrameInfo
[out] Obtained frame information, including width, height, pixel format and so on
pUser
[out] User data

Return Values

Successed, return MV_OK（0); failed, return Error Code.

Remarks

  • Set the image data callback function via this interface before calling MvCamCtrl::CMvGigEDevice::StartGrabbing.
  • There are two image data acquisition modes, but the two modes cannot be reused:
    Mode 1: Call MvCamCtrl::CMvGigEDevice::RegisterImageCallBack to set image data callback function, and then call MvCamCtrl::CMvGigEDevice::StartGrabbing to start the acquisition, the acquired image data will be returned in the set callback function.
    Mode 2: Call MvCamCtrl::CMvGigEDevice::StartGrabbing to start the acquisition, and then circularly call MvCamCtrl::CMvGigEDevice::GetOneFrame in the application layer to get the frame data of specified pixel format. When getting the frame data, the upper-level application layer should control the frequency of calling this interface according to the frame rate.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

void __stdcall ImageCallBack(unsigned char * pData, MV_FRAME_OUT_INFO* pFrameInfo, void* pUser)
{
    if (pFrameInfo)
    {
        // Add the system time when outputting
        char   szInfo[128] = {0};
        SYSTEMTIME sys;
        GetLocalTime( &sys );
        sprintf_s(szInfo, 128, "[%d-%02d-%02d %02d:%02d:%02d:%04d] : GetOneFrame succeed, width[%d], height[%d]", sys.wYear, sys.wMonth,
            sys.wDay, sys.wHour, sys.wMinute, sys.wSecond, sys.wMilliseconds, pFrameInfo->nWidth, pFrameInfo->nHeight);

        printf("%s\n", szInfo);
    }
}

void main()
{
   int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    //Register data callback function
    nRet = MyDevice->RegisterImageCallBack(ImageCallBack, NULL);
    if (MV_OK != nRet)
    {
        printf("error: RegisterImageCallBack fail [%x]\n", nRet);
        return;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    // Start the image acquisition
    nRet = MyDevice->StartGrabbing();
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing [%x]\n", nRet);
        break;
    }

    //...Other processes

    // Stop the image acquisition
    nRet = MyDevice->StopGrabbing();
    if (MV_OK != nRet)
    {
         printf("error: StopGrabbing fail [%x]\n", nRet);
    }

    // Close device
    nRet = MyDevice->Close();
    if (MV_OK != nRet)
    {
        printf("error: Close fail [%x]\n", nRet);
    }

    // Destroy device from factory
    nRet = tlFactory.DestroyDevice(MyDevice);
    if (MV_OK != nRet)
    {
        printf("error: DestroyDevice fail [%x]\n", nRet);
    }
}

See Also

MvCamCtrl::CMvGigEDevice::RegisterImageCallBackEx MvCamCtrl::CMvGigEDevice::StartGrabbing


MvCamCtrl::CMvGigEDevice::RegisterImageCallBackEx

Register image data callback function.

virtual int RegisterImageCallBackEx(
  cbOutput    fOutputCallBack,
  void        *pUser
);

Parameters

fOutputCallBack
[in] Image data callback function
pUser
[in] User data

Callback Function

void(__stdcall* cbOutput)(
  unsigned char           *pData,
  MV_FRAME_OUT_INFO_EX    *pFrameInfo
  void                    *pUser
);

Callback Function Parameters

pData
[out] Cache address for saving image data
pFrameInfo
[out] Obtained frame information, including width, height, pixel format, chunk information and so on
pUser
[out] User data

Return Values

Successed, return MV_OK（0）; failed, return Error Code.

Remarks

  • Set the image data callback function via this interface before calling MvCamCtrl::CMvGigEDevice::StartGrabbing.
  • There are two image data acquisition modes, but the two modes cannot be reused:
    Mode 1: Call MvCamCtrl::CMvGigEDevice::RegisterImageCallBack to set image data callback function, and then call MvCamCtrl::CMvGigEDevice::StartGrabbing to start the acquisition, the acquired image data will be returned in the set callback function.
    Mode 2: Call MvCamCtrl::CMvGigEDevice::StartGrabbing to start the acquisition, and then circularly call MvCamCtrl::CMvGigEDevice::GetOneFrame in the application layer to get the frame data of specified pixel format. When getting the frame data, the upper-level application layer should control the frequency of calling this interface according to the frame rate.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

void __stdcall ImageCallBack(unsigned char * pData, MV_FRAME_OUT_INFO_EX* pFrameInfo, void* pUser)
{
    if (pFrameInfo)
    {
        // Add the system time when outputting
        char   szInfo[128] = {0};
        SYSTEMTIME sys;
        GetLocalTime( &sys );
        sprintf_s(szInfo, 128, "[%d-%02d-%02d %02d:%02d:%02d:%04d] : GetOneFrame succeed, width[%d], height[%d]", sys.wYear, sys.wMonth,
            sys.wDay, sys.wHour, sys.wMinute, sys.wSecond, sys.wMilliseconds, pFrameInfo->nWidth, pFrameInfo->nHeight);

        printf("%s\n", szInfo);
    }
}

void main()
{
   int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    //Register data callback function
    nRet = MyDevice->RegisterImageCallBackEx(ImageCallBack, NULL);
    if (MV_OK != nRet)
    {
        printf("error: RegisterImageCallBack fail [%x]\n", nRet);
        return;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    // Start the image acquisition
    nRet = MyDevice->StartGrabbing();
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing [%x]\n", nRet);
        break;
    }

    //...Other processes

    //  Stop the image acquisition
    nRet = MyDevice->StopGrabbing();
    if (MV_OK != nRet)
    {
         printf("error: StopGrabbing fail [%x]\n", nRet);
    }

    // Close device
    nRet = MyDevice->Close();
    if (MV_OK != nRet)
    {
        printf("error: Close fail [%x]\n", nRet);
    }

    // Destroy device from factory
    nRet = tlFactory.DestroyDevice(MyDevice);
    if (MV_OK != nRet)
    {
        printf("error: DestroyDevice fail [%x]\n", nRet);
    }
}

See Also

MvCamCtrl::CMvGigEDevice::RegisterImageCallBack MvCamCtrl::CMvGigEDevice::StartGrabbing


MvCamCtrl::CMvGigEDevice::SetIpConfig

IP configuration modes.

virtual int SetIpConfig(
  unsigned int    nType
);

Parameters

nType
[in] IP configuration modes, the definitions are below:
Macro Definition | Value | Description
MV_IP_CFG_STATIC | 0x05000000 | Fixed IP Address Mode
MV_IP_CFG_DHCP | 0x06000000 | DHCP Auto-Obtain IP Mode
MV_IP_CFG_LLA | 0x04000000 | LLA(Link-local address), Link Local Address

Return Values

Successed, return MV_OK（0）; failed, return Error Code.

Remarks

Before connecting device and getting device exclusive permission, you should create device example via CreateDevice.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
            return;
        }
    }

    //IP configuration mode
    nRet = MyDevice->SetIpConfig(0x02000000); //Set as DHCP Auto-Obtain IP
    if (MV_OK != nRet)
    {
        printf("error: SetIpConfig [%x]\n", nRet);
        return;
    }

    //...Other processes
}

See Also

MvCamCtrl::CTlFactory::CreateDevice


MvCamCtrl::CMvGigEDevice::ForceIp

Force setting the device IP address.

virtual int ForceIp(
  unsigned int    nIP
);

Parameters

nIP
[in] The set IP address

Return Values

Successed, return MV_OK（0); Failed, return Error Code.

Remarks

Create device handle via CreateDevice, Force setting the IP address by calling this interface before opening the device.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    //Force setting the device IP address
    nRet = MyDevice->ForceIp(0x0a0f0636); //10.15.6.54
    if (MV_OK != nRet)
    {
        printf("error: ForceIp [%x]\n", nRet);
        continue;
        break;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    //...Other processing methods
}

See Also

MvCamCtrl::CTlFactory::CreateDevice


MvCamCtrl::CMvGigEDevice::IsOpen

Judge the device status.

virtual bool IsOpen(
);

Return Values

TRUE means that the device is opened (connected), FALSE means that the device is free.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    //...Other processes
}

See Also

MvCamCtrl::CTlFactory::CreateDevice MvCamCtrl::CMvGigEDevice::Open


MvCamCtrl::CMvGigEDevice::Open

Open device (Connect device).

virtual int Open(
  unsigned int      nAccessMode = MV_ACCESS_Exclusive,
  unsigned short    nSwitchoverKey = 0
);

Parameters

nAccessMode
[in] Device access mode, the default is exclusive mode, the definitions are listed below:
Macro Definition | Value | Description
MV_ACCESS_Exclusive | 1 | Exclusive permission, the other APPs are only allowed to read CCP register.
MV_ACCESS_ExclusiveWithSwitch | 2 | Preempt permission from mode5, and then open as the exclusive permission.
MV_ACCESS_Control | 3 | Control permission, the other APPs are allowed to read all the registers.
MV_ACCESS_ControlWithSwitch | 4 | Preempt permission from mode5, and then open as the control permission.
MV_ACCESS_ControlSwitchEnable | 5 | Open as the control permission that can be preempted.
MV_ACCESS_ControlSwitchEnableWithKey | 6 | Preempt permission from mode5, and then open as the control permission that can be preempted.
MV_ACCESS_Monitor | 7 | Open device in read mode, applicable to the control permission.
nSwitchoverKey
[in] Password for switching permissions. By default, it is none. and it is valid when the access modes (mode2/4/6) support permission switch.

Return Values

Successed, return MV_OK（0); failed, return Error Code.

Remarks

  • Before connecting device and get device exclusive permission, you should create device example via MvCamCtrl::CTlFactory::CreateDevice.
  • When calling the interface, there is no need to input nAccessMode and nSwitchoverKey, and the default device access mode is exclusive permission.The devices do not support the following three preeemption modes: MV_ACCESS_ExclusiveWithSwitch, MV_ACCESS_ControlWithSwitch and MV_ACCESS_ControlSwitchEnableWithKey.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        return;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        unsigned int nAccessMode = MV_ACCESS_Exclusive;
        unsigned short nSwitchoverKey = 0;
        nRet = MyDevice->Open(nAccessMode, nSwitchoverKey);
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
            return;
        }
    }

    //...Other processes
}

See Also

MvCamCtrl::CTlFactory::CreateDevice MvCamCtrl::CMvGigEDevice::Close


MvCamCtrl::CMvGigEDevice::Close

Close device.

virtual int Close(
);

Return Values

Successed, return MV_OK（0）; Failed, return Error Code.

Remarks

After connecting devive via MvCamCtrl::CMvGigEDevice::Open, disconnect the device via this interface, release the exclusive permission.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open the device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    //...Device operations

    // Close the device
    nRet = MyDevice->Close();
    if (MV_OK != nRet)
    {
        printf("error: Close fail [%x]\n", nRet);
    }

    //...Other processing methods
}

See Also

MvCamCtrl::CMvGigEDevice::Open


MvCamCtrl::CMvGigEDevice::IsDriverWorking

Get the working status of driver.

virtual int IsDriverWorking(
);

Return Values

Return 0 means that driver is exception, return 1 means that the driver is working normally.

Remarks

After connect the device via MvCamCtrl::CMvGigEDevice::Open, you can determine whether the driver is working normally via this interface.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    // Get driver working status
    nRet = MyDevice->IsDriverWorking();
    if (nRet == 0)
    {
        printf("The driver is abnormal.");
    }

    //...Device operation

    // Close device
    nRet = MyDevice->Close();
    if (MV_OK != nRet)
    {
        printf("error: Close fail [%x]\n", nRet);
    }

    // Destroy device from factory
    nRet = tlFactory.DestroyDevice(MyDevice);
    if (MV_OK != nRet)
    {
        printf("error: DestroyDevice fail [%x]\n", nRet);
    }
}

See Also

MvCamCtrl::CMvGigEDevice::Open


MvCamCtrl::CMvGigEDevice::SetThrowAbnormalImage

Discard exception frame data.

virtual int SetThrowAbnormalImage(
  int    bThrow
);

Parameters

bThrow
[in] Whether to discard exception frame data: 0- Do not discard，1- Discard

Return Values

Successed, return MV_OK（0）; failed, return Error Code.

Remarks

  • Set whether to discard exception frame data via this interface. When discarding exception frame in stream error status, it can avoid blurred screen but the frame skip will occur. Call this interface before calling MvCamCtrl::CMvGigEDevice::StartGrabbing.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

void __stdcall ImageCallBack(unsigned char * pData, MV_FRAME_OUT_INFO* pFrameInfo, void* pUser)
{
    if (pFrameInfo)
    {
        // Add system time when outputting
        char   szInfo[128] = {0};
        SYSTEMTIME sys;
        GetLocalTime( &sys );
        sprintf_s(szInfo, 128, "[%d-%02d-%02d %02d:%02d:%02d:%04d] : GetOneFrame succeed, width[%d], height[%d]", sys.wYear, sys.wMonth,
            sys.wDay, sys.wHour, sys.wMinute, sys.wSecond, sys.wMilliseconds, pFrameInfo->nWidth, pFrameInfo->nHeight);

        printf("%s\n", szInfo);
    }
}

void main()
{
   int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    //Register data callback function
    nRet = MyDevice->RegisterImageCallBack(ImageCallBack, NULL);
    if (MV_OK != nRet)
    {
        printf("error: RegisterImageCallBack fail [%x]\n", nRet);
        return;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    //Whether to discard exception frame data
    int bThrow = 1; //0-不丢弃，1-丢弃
    nRet = MyDevice->SetThrowAbnormalImage(bThrow);
    if (MV_OK != nRet)
    {
        printf("error: SetThrowAbnormalImage fail [%x]\n", nRet);
        return;
    }

    // Start the image acquisition
    nRet = MyDevice->StartGrabbing();
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing [%x]\n", nRet);
        break;
    }

    //...Other processes

    // Stop the image acquisition
    nRet = MyDevice->StopGrabbing();
    if (MV_OK != nRet)
    {
         printf("error: StopGrabbing fail [%x]\n", nRet);
    }

    // Close device
    nRet = MyDevice->Close();
    if (MV_OK != nRet)
    {
        printf("error: Close fail [%x]\n", nRet);
    }

    // Destroy device from factory
    nRet = tlFactory.DestroyDevice(MyDevice);
    if (MV_OK != nRet)
    {
        printf("error: DestroyDevice fail [%x]\n", nRet);
    }
}

See Also

MvCamCtrl::CMvGigEDevice::StartGrabbing


MvCamCtrl::CMvGigEDevice::SetImageNodeNum

Set the number of SDK internal image cache node.

virtual int SetImageNodeNum(
  unsigned int    nNum
);

Parameters

nNum
[in] The number of SDK internal image cache nodes, range from 1 to 30

Return Values

Successed, return MV_OK（0）; failed, return Error Code.

Remarks

Call this interface to set the number of SDK internal image cache nodes before calling MvCamCtrl::CMvGigEDevice::StartGrabbing to start capturing.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

void __stdcall ImageCallBack(unsigned char * pData, MV_FRAME_OUT_INFO* pFrameInfo, void* pUser)
{
    if (pFrameInfo)
    {
        // Add the system time when outputting
        char   szInfo[128] = {0};
        SYSTEMTIME sys;
        GetLocalTime( &sys );
        sprintf_s(szInfo, 128, "[%d-%02d-%02d %02d:%02d:%02d:%04d] : GetOneFrame succeed, width[%d], height[%d]", sys.wYear, sys.wMonth,
            sys.wDay, sys.wHour, sys.wMinute, sys.wSecond, sys.wMilliseconds, pFrameInfo->nWidth, pFrameInfo->nHeight);

        printf("%s\n", szInfo);
    }
}

void main()
{
   int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    //Register data callback function
    nRet = MyDevice->RegisterImageCallBack(ImageCallBack, NULL);
    if (MV_OK != nRet)
    {
        printf("error: RegisterImageCallBack fail [%x]\n", nRet);
        return;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    //...Other processes

    //Set the number of SDK internal image cache nodes
    unsigned int nNum = 15;
    nRet = MyDevice->SetImageNodeNum(nNum);
    if (MV_OK != nRet)
    {
        printf("error: SetImageNodeNum fail [%x]\n", nRet);
        return;
    }

    // Start the image acquisition
    nRet = MyDevice->StartGrabbing();
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing [%x]\n", nRet);
        break;
    }

    //...Other processes

    // Stop the image acquisition
    nRet = MyDevice->StopGrabbing();
    if (MV_OK != nRet)
    {
         printf("error: StopGrabbing fail [%x]\n", nRet);
    }

    // Close device
    nRet = MyDevice->Close();
    if (MV_OK != nRet)
    {
        printf("error: Close fail [%x]\n", nRet);
    }

    // Destroy device from factory
    nRet = tlFactory.DestroyDevice(MyDevice);
    if (MV_OK != nRet)
    {
        printf("error: DestroyDevice fail [%x]\n", nRet);
    }
}

See Also

MvCamCtrl::CMvGigEDevice::Open MvCamCtrl::CMvGigEDevice::StartGrabbing


MvCamCtrl::CMvGigEDevice::SetAcquisitionMode

Set camera acquisition mode.

virtual int SetAcquisitionMode(
  MV_CAM_ACQUISITION_MODE    enMode
);

Parameters

enMode
[in] Acquisition mode, see value definition in Enumeration Type: MV_CAM_ACQUISITION_MODE

Return Values

Successed, return MV_OK（0）; failed, return Error Code.

Remarks

After connecting the device, call this interface to set the camera acquisition mode, including single frame, multiple frame or continuous acquisition mode.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    //Set device acquisition mode
    unsigned int enMode = 2; //Continuous acquisition mode
    nRet = MyDevice->SetAcquisitionMode(enMode);
    if (MV_OK != nRet)
    {
        printf("error: SetAcquisitionMode [%x]\n", nRet);
    }

    //...Other processes
}

See Also

MvCamCtrl::CTlFactory::CreateDevice


MvCamCtrl::CMvGigEDevice::StartGrabbing

Start the image acquisition.

virtual int StartGrabbing(
);

Return Values

Successed, return MV_OK（0）; failed, return Error Code.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    // Start the image acquisition
    nRet = MyDevice->StartGrabbing();
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing [%x]\n", nRet);
        break;
    }

    //...Other processes
}

See Also

MvCamCtrl::CMvGigEDevice::RegisterImageCallBack MvCamCtrl::CMvGigEDevice::GetOneFrame MvCamCtrl::CMvGigEDevice::StopGrabbing


MvCamCtrl::CMvGigEDevice::GetOneFrame

Get a frame image data.

virtual int GetOneFrame(
  unsigned char        *pData,
  unsigned int         nDataSize,
  MV_FRAME_OUT_INFO    *pFrameInfo
);

Parameters

pData
[in] Cache address used for saving image data
nDataSize
[in] Cache size
pFrameInfo
[out] Obtained frame information

Return Values

Successed, return MV_OK（0); failed, return Error Code.

Remarks

Before calling this interface to get the image data frame, you should call MvCamCtrl::CMvGigEDevice::StartGrabbing to start the image acquisition. This interface can help to get the frame data automatically. And the upper-level application program should control the frequency of calling this interface according to frame rate.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

#define MAX_BUF_SIZE    (1920*1080*3)

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    // Start the image acquisition
    nRet = MyDevice->StartGrabbing();
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing [%x]\n", nRet);
        break;
    }

    unsigned int    nTestFrameSize = 0;
    unsigned char*  g_pFrameBuf = NULL;
    g_pFrameBuf = (unsigned char*)malloc(MAX_BUF_SIZE);

    MV_FRAME_OUT_INFO stInfo;
    memset(&stInfo, 0, sizeof(MV_FRAME_OUT_INFO));

    // The upper-level application program should control the frequency of calling this interface according to frame rate.
    // The example code is for reference only, please create another thread to acquire and process the image data in the practical application.
    while(1)
    {
        if (nTestFrameSize > 99)
        {
            break;
        }
        nRet = MyDevice->GetOneFrame(g_pFrameBuf, MAX_BUF_SIZE, &stInfo);
        if (MV_OK != nRet)
        {
            Sleep(10);
        }
        else
        {
            //...Process image data
            nTestFrameSize++;
        }
    }

    // Stop the image acquisition
    nRet = MyDevice->StopGrabbing();
    if (MV_OK != nRet)
    {
         printf("error: StopGrabbing fail [%x]\n", nRet);
    }

    //...Other processes
}

See Also

MvCamCtrl::CMvGigEDevice::GetOneFrameEx MvCamCtrl::CMvGigEDevice::StartGrabbing


MvCamCtrl::CMvGigEDevice::GetOneFrameEx

Get a frame image data, support getting chunk information.

virtual int GetOneFrameEx(
  unsigned char           *pData,
  unsigned int            nDataSize,
  MV_FRAME_OUT_INFO_EX    *pFrameInfo
);

Parameters

pData
[in] Cache address used for saving image data
nDataSize
[in] Cache size
pFrameInfo
[out] Obtained frame information, including chunk information

Return Values

Successed, return MV_OK（0); failed, return Error Code.

Remarks

Before calling this interface to get the image data frame, you should call MvCamCtrl::CMvGigEDevice::StartGrabbingto start the image acquisition. This interface can help to get the frame data automatically. And the upper-level application program should control the frequency of calling this interface according to frame rate.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

#define MAX_BUF_SIZE    (1920*1080*3)

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    // Start the image acquisition
    nRet = MyDevice->StartGrabbing();
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing [%x]\n", nRet);
        break;
    }

    unsigned int    nTestFrameSize = 0;
    unsigned char*  g_pFrameBuf = NULL;
    g_pFrameBuf = (unsigned char*)malloc(MAX_BUF_SIZE);

    MV_FRAME_OUT_INFO_EX stInfo;
    memset(&stInfo, 0, sizeof(MV_FRAME_OUT_INFO_EX));

    //The upper-level application program should control the frequency of calling this interface according to frame rate.
    //The example code is for reference only, please create another thread to acquire and process the image data in the practical application.
    while(1)
    {
        if (nTestFrameSize > 99)
        {
            break;
        }
        nRet = MyDevice->GetOneFrameEx(g_pFrameBuf, MAX_BUF_SIZE, &stInfo);
        if (MV_OK != nRet)
        {
            Sleep(10);
        }
        else
        {
            //...Process image data
            nTestFrameSize++;
        }
    }

    // Stop the image acquisition
    nRet = MyDevice->StopGrabbing();
    if (MV_OK != nRet)
    {
         printf("error: StopGrabbing fail [%x]\n", nRet);
    }

    //...Other processes
}

See Also

MvCamCtrl::CMvGigEDevice::GetOneFrame MvCamCtrl::CMvGigEDevice::StartGrabbing


MvCamCtrl::CMvGigEDevice::Display

Display acquired images.

virtual int Display(
  void    *hWnd
);

Parameters

hWnd
[in] Window handle

Return Values

Successed, return MV_OK（0）; Failed, return Error Code.

Remarks

This interface should be called after StartGrabbing, display the acquired images.

Example

The example code is for reference only.

#include <stdio.h>
#include "Windows.h"
#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

typedef HWND (WINAPI *PROCGETCONSOLEWINDOW)();
PROCGETCONSOLEWINDOW GetConsoleWindow;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    // Start the image acquisition
    nRet = MyDevice->StartGrabbing();
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing [%x]\n", nRet);
        return;
    }

    //Get control panel window handle
    HMODULE hKernel32 = GetModuleHandle("kernel32");
    GetConsoleWindow = (PROCGETCONSOLEWINDOW)GetProcAddress(hKernel32,"GetConsoleWindow");
    HWND hWnd = GetConsoleWindow(); //Window handle

    //Display image
    nRet = MyDevice->Display(hWnd);
    if (MV_OK != nRet)
    {
        printf("error: Display [%x]\n", nRet);
        return;
    }

    //...Other processing methods
}

See Also

MvCamCtrl::CMvGigEDevice::StartGrabbing


MvCamCtrl::CMvGigEDevice::StopGrabbing

Stop the image acquisition.

virtual int StopGrabbing(
);

Return Values

Successed, return MV_OK（0）; failed, return Error Code.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    // Start the image acquisition
    nRet = MyDevice->StartGrabbing();
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing [%x]\n", nRet);
        break;
    }

    //...Process image data

    // Stop the image acquisition
    nRet = MyDevice->StopGrabbing();
    if (MV_OK != nRet)
    {
         printf("error: StopGrabbing fail [%x]\n", nRet);
    }

    // Close device
    nRet = MyDevice->Close();
    if (MV_OK != nRet)
    {
        printf("error: Close fail [%x]\n", nRet);
    }

    // Destroy device from factory
    nRet = tlFactory.DestroyDevice(MyDevice);
    if (MV_OK != nRet)
    {
        printf("error: DestroyDevice fail [%x]\n", nRet);
    }
}

See Also

MvCamCtrl::CMvGigEDevice::StartGrabbing


MvCamCtrl::CMvGigEDevice::GetAllMatchInfo

Get different type information.

virtual int GetAllMatchInfo(
  MV_ALL_MATCH_INFO    *pstInfo
);

Parameters

pstInfo
[in&out] Information structure

Return Values

Successed, return MV_OK（0); Failed, return Error Code.

Remarks

Input the obtained information type（nType in MV_ALL_MATCH_INFO structure）in the interface, get corresponding information (return in the pInfo of MV_ALL_MATCH_INFO structure). Before calling this interface, it should start the image acquisition via MvCamCtrl::CMvGigEDevice::StartGrabbing, apply cache for pInfo, and input the cache size of pInfoSize.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        return;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    //...Other processing methods

    // Start the image acquisition
    nRet = MyDevice->StartGrabbing();
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing [%x]\n", nRet);
        break;
    }

    Sleep(5000);

    //Get camera network flow and packet loss information
    MV_ALL_MATCH_INFO struMatchInfo={0};
    MV_MATCH_INFO_NET_DETECT stMatchInfoNetDetect;
    struMatchInfo.pInfo = &stMatchInfoNetDetect;

    struMatchInfo.nType = MV_MATCH_TYPE_NET_DETECT; //Network flow and packet loss information
    memset(struMatchInfo.pInfo, 0, sizeof(MV_MATCH_INFO_NET_DETECT));
    struMatchInfo.nInfoSize = sizeof(MV_MATCH_INFO_NET_DETECT);

    nRet = MyDevice->GetAllMatchInfo(&struMatchInfo);

    if (MV_OK != nRet)
    {
        printf("error: GetAllMatchInfo fail [%x]\n", nRet);
        return;
    }

    //...Other processing methods

    // Stop the image acquisition
    nRet = MyDevice->StopGrabbing();
    if (MV_OK != nRet)
    {
         printf("error: StopGrabbing fail [%x]\n", nRet);
    }

    // Close device
    nRet = MyDevice->Close();
    if (MV_OK != nRet)
    {
        printf("error: Close fail [%x]\n", nRet);
    }

    // Destroy device from the factory
    nRet = tlFactory.DestroyDevice(MyDevice);
    if (MV_OK != nRet)
    {
        printf("error: DestroyDevice fail [%x]\n", nRet);
    }
}

See Also

MvCamCtrl::CMvGigEDevice::StartGrabbing


MvCamCtrl::CMvGigEDevice::GetDeviceInfo

Get device information.

virtual int GetDeviceInfo(
  MV_CC_DEVICE_INFO&    deviceInfo
);

Parameters

deviceInfo
[out] Device information

Return Values

Successed, return MV_OK（0); Failed, return Error Code.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        return;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    // Get device information
    MV_CC_DEVICE_INFO deviceInfo;
    memset(&deviceInfo, 0, sizeof(MV_CC_DEVICE_INFO));
    nRet = MyDevice->GetDeviceInfo(*(&deviceInfo));
    if (MV_OK != nRet)
    {
        printf("error: GetDeviceInfo[%x]\n", nRet);
        return;
    }

    //...Other processing methods
}

See Also

MvCamCtrl::CMvGigEDevice::StartGrabbing


MvCamCtrl::CMvGigEDevice::GetGenICamXML

Get device XML description file.

virtual int GetGenICamXML(
  unsigned char    *pData,
  unsigned int     nDataSize,
  unsigned int     *pnDataLen
);

Parameters

pData
[in&out] The cache address for saving XML file data
nDataSize
[in] Cache size
pnDataLen
[out] XML file data length

Return Values

Successed, return MV_OK（0); Failed, return Error Code.

Remarks

When pData is NULL or nDataSize is smaller than the actual XML file size, do not copy the data, and return the XML file size via pnDataLen;
When the pData cache address is valid and the cache is large enough, copy the whole data and save it to this cache, return the actual XML file size via pnDataLen.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

#define MAX_XML_FILE_SIZE       (1024*1024*1)

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    unsigned char* pXMLBuf = (unsigned char*)malloc(MAX_XML_FILE_SIZE);
    if (NULL == pXMLBuf)
    {
        printf("error: malloc xml buffer failed!\n");
        break;
    }

   unsigned int nXMLDataLen = 0;
   nRet = MyDevice->GetGenICamXML(pXMLBuf, MAX_XML_FILE_SIZE, &nXMLDataLen);
   if (MV_OK != nRet || nXMLDataLen > MAX_XML_FILE_SIZE)
   {
        printf("error: GetGenICamXML failed! [%x]\n", nRet);
        break;
   }

    //...Other processes

    //Close device
    nRet = MyDevice->Close();
    if (MV_OK != nRet)
    {
        printf("error: Close fail [%x]\n", nRet);
    }

    //Destroy device from the factory
    nRet = tlFactory.DestroyDevice(MyDevice);
    if (MV_OK != nRet)
    {
        printf("error: DestroyDevice fail [%x]\n", nRet);
    }
}

See Also

MvCamCtrl::CMvGigEDevice::Open


MvCamCtrl::CMvGigEDevice::GetNetTransInfo

Get network transport information.

virtual int GetNetTransInfo(
  MV_NETTRANS_INFO    *pstInfo
);

Parameters

pstInfo
[out] Network transport information, including received data size, lost frame quantity and so on.

Return Values

Successed, return MV_OK（0); Failed, return Error Code.

Remarks

Call this interface to get the network transport information, including received data size, lost frame quantity and so on.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

#define MAX_BUF_SIZE    (1920*1080*3)

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    // Start the image acquisition
    nRet = MyDevice->StartGrabbing();
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing [%x]\n", nRet);
        break;
    }

    unsigned int    nTestFrameSize = 0;
    unsigned char*  g_pFrameBuf = NULL;
    g_pFrameBuf = (unsigned char*)malloc(MAX_BUF_SIZE);

    MV_FRAME_OUT_INFO stInfo;
    memset(&stInfo, 0, sizeof(MV_FRAME_OUT_INFO));

    MV_NETTRANS_INFO stNetTransInfo = {0};

    // The upper-level application program should control the frequency of calling this interface according to frame rate.
    // The example code is for reference only, please create another thread to acquire and process the image in the practical application.
    {
        if (nTestFrameSize > 99)
        {
            break;
        }
        nRet = MyDevice->GetOneFrame(g_pFrameBuf, MAX_BUF_SIZE, &stInfo);
        if (MV_OK != nRet)
        {
            Sleep(10);
        }
        else
        {
            //...Process image data

            // Get network transport information
            if ((nTestFrameSize % 10) == 0)
            {
                nRet = MyDevice->GetNetTransInfo(&stNetTransInfo);
                printf("GetDataSize [%I64d], nRet[%x]\n", stNetTransInfo.nReviceDataSize, nRet);
            }

            nTestFrameSize++;
        }
    }

    // Stop the image acquisition
    nRet = MyDevice->StopGrabbing();
    if (MV_OK != nRet)
    {
         printf("error: StopGrabbing fail [%x]\n", nRet);
    }

    //...Other processes
}

See Also

MvCamCtrl::CMvGigEDevice::StartGrabbing


MvCamCtrl::CMvGigEDevice::SetNetTransMode

Set the preferred SDK internal network mode.

virtual int SetNetTransMode(
  unsigned int    nType
);

Parameters

nType
[in] Network mode, the definitions are below:
Macro Definition | Value | Description
MV_NET_TRANS_DRIVER | 0x00000001 | Drive Mode
MV_NET_TRANS_SOCKET | 0x00000002 | Socket Mode

Return Values

Successed, return MV_OK（0）; failed, return Error Code.

Remarks

Set the preferred SDK internal network mode via this interface. By default, the preferred mode is Drive Mode, which only supported by GigEVision camera.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        return;
    }

    //Set the preferred SDK internal network mode
    unsigned int nType = MV_NET_TRANS_SOCKET; //Socket Mode
    nRet = MyDevice->SetNetTransMode(nType);
    if (MV_OK != nRet)
    {
        printf("error: SetNetTransMode [%x]\n", nRet);
        return;
    }

    //...Other processes
}

See Also

MvCamCtrl::CTlFactory::CreateDevice


MvCamCtrl::CMvGigEDevice::GetTlProxy

Get transport layer proxy used by GenICam.

virtual TlProxy GetTlProxy(
);

Return Values

Successed, return transport layer proxy example (TlProxy); failed, return NULL.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        return;
    }

    TlProxy m_pMyPortTl = MyDevice->GetTlProxy();
    if (NULL == m_pMyPortTl)
    {
        printf("error: get gige transport layer failed!\n");
        return;
    }

    //...Other processes
}

See Also

MvCamCtrl::CTlFactory::CreateDevice


MvCamCtrl::CMvGigEDevice::LocalUpgrade

Device local upgrade.

virtual int LocalUpgrade(
  const void    *pFilePathName
);

Parameters

pFilePathName
[in] File path of upgrade package, including the absolue path of file name.

Return Values

Successed, return MV_OK（0); failed, return Error Code.

Remarks

Send the upgrade firmware to device for upgrade via this interface. This interface will start returning until the upgrade firmware was successfully sent to device, the responding time may be quite long.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        return;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
            return;
        }
    }

    //Device local upgrade
    nRet = MyDevice->LocalUpgrade("C://digicap.dav");
    if (MV_OK != nRet)
    {
        printf("error: LocalUpgrade [%x]\n", nRet);
        return;
    }
    //...Other processes
}

See Also

MvCamCtrl::CTlFactory::CreateDevice MvCamCtrl::CMvGigEDevice::Open


MvCamCtrl::CMvGigEDevice::GetUpgradeProcess

Get upgrade progress.

virtual int GetUpgradeProcess(
  unsigned int    *pnProcess
);

Parameters

pnProcess
[out] Upgrade progress, range from 0 to 100

Return Values

Successed, return MV_OK（0); failed, return Error Code.

Remarks

Get upgrade progress percentage.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        return;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
            return;
        }
    }

    //Device local upgrade
    nRet = MyDevice->LocalUpgrade("C://digicap.dav");
    if (MV_OK != nRet)
    {
        printf("error: LocalUpgrade [%x]\n", nRet);
        return;
    }

    //Get upgrade progress
    unsigned int iProcess = 0;
    while(1)
    {
        nRet = MyDevice->GetUpgradeProcess(&iProcess);
        if(iProcess == 100)
        {
            printf("error: GetUpgradeProcess [%x]\n", nRet);
            break;
        }
        Sleep(1000);
    }

    //...Other processes
}

See Also

MvCamCtrl::CMvGigEDevice::LocalUpgrade


MvCamCtrl::CMvGigEDevice::GetOptimalPacketSize

Get the best packet size.

virtual int GetOptimalPacketSize(
);

Return Values

Successed, the returned value is larger than 0, it means the packet size; failed, the returned value is smaller than 0, see corresponding Error Code.

Remarks

Get the best packet size, the corresponding GigEVision device is SCPS, the corresponding U3V device is the packet read from the driver every time and its size is the same with that of the packet transported within the network. This interface should be called after MV_CC_OpenDevice, and before MV_CC_StartGrabbing.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        return;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
            return;
        }
    }

    // Get the best packet size
    int iPacketSize = MyDevice->GetOptimalPacketSize();

    //...Other processes
}

See Also

MvCamCtrl::CTlFactory::CreateDevice MvCamCtrl::CMvGigEDevice::Open


MvCamCtrl::CMvGigEDevice::ReadMemory

Read data from device register.

virtual int ReadMemory(
  void       *pBuffer,
  __int64    nAddress,
  __int64    nLength
);

Parameters

pBuffer
[out] Data buffer, save the read memory value (the memory value is stored as big-end mode)
nAddress
[in] Memory address to be read, get this address from the Camera.xml file of device, such as the XML node value of xxx_RegAddr（the Camera.xml file of device will automatically generate in the application program catalog after opening the device)
nLength
[in] Memory length to be read

Return Values

Successed, return MV_OK（0）; failed, return Error Code.

Remarks

Login the device, read the data of a register segment.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    // Read data from device register
    unsigned int nWidth = 0;
    nRet = MyDevice->ReadMemory(&nWidth, 0x00030360L, 4L);
    if (MV_OK != nRet)
    {
        printf("error: ReadMemory [%x]\n", nRet);
        break;
    }

    //...Other processes
}

See Also

MvCamCtrl::CTlFactory::CreateDevice MvCamCtrl::CMvGigEDevice::WriteMemory


MvCamCtrl::CMvGigEDevice::WriteMemory

Write data into device register.

virtual int WriteMemory(
  const void    *pBuffer,
  __int64       nAddress,
  __int64       nLength
);

Parameters

pBuffer
[in] Memory value to be written (notice that the memory value should be stored as big-end mode)
nAddress
[in] Memory address to be written. You can get this address from the Camera.xml file of device, such as the XML node value of xxx_RegAddr (the Camera.xml file of device will automatically generate in the application program catalog after opening the device)
nLength
[in] Memory length to be written

Return Values

Successed, return MV_OK（0）; failed, return Error Code.

Remarks

Login the device, write a piece of data to a register segment.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvGigEDevice* MyDevice = dynamic_cast<CMvGigEDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    // Read data from device register
    unsigned int nWidth = 0;
    nRet = MyDevice->ReadMemory(&nWidth, 0x00030360L, 4L);
    if (MV_OK != nRet)
    {
        printf("error: ReadMemory [%x]\n", nRet);
        break;
    }

    // Write data into device register
    unsigned int nWidth = 320;
    nRet = MyDevice->WriteMemory(&nWidth, 0x00030360L, 4L);
    if (MV_OK != nRet)
    {
        printf("error: WriteMemory [%x]\n", nRet);
        break;
    }

    //...Other processes
}

See Also

MvCamCtrl::CTlFactory::CreateDevice MvCamCtrl::CMvGigEDevice::ReadMemory


MvCamCtrl::CMvUsb3VDevice::RegisterExceptionCallBack

Register exception message callback function.

virtual int RegisterExceptionCallBack(
  cbException    fExceptionCallBack,
  void           *pUser
);

Parameters

fExceptionCallBack
[in] Callback function of receiving exception message
pUser
[in] User data

Callback Function

void(__stdcall* cbException)(
  unsigned int    nMsgType,
  void            *pUser
);

Callback Function Parameters

nMsgType
[out] Exception Message type
pUser
[out] User data

Return Values

Successed, return MV_OK（0）; failed, return Error Code.

Remarks

This interface should be called after opening device via MvCamCtrl::CMvUsb3VDevice::Open.

The macro definitions of exception message types are listed below:

Macro Definition | Value | Description
MV_GIGE_EXCEPTION_DEV_DISCONNECT | 0x00008001 | Device disconnected

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvUsb3VDevice.h"
using namespace MvCamCtrl;

//Exception callback function
void __stdcall ExceptionCB(unsigned int nMsgType, void* pUser)
{
    printf("Exception message is: 0x%x", nMsgType);
}

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the USB 3.0 devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_USB_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvUsb3VDevice* MyDevice = dynamic_cast<CMvUsb3VDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    // Register exception message callback function
    nRet = MyDevice->RegisterExceptionCallBack(ExceptionCB, NULL);
    if (MV_OK != nRet)
    {
         printf("error: RegisterExceptionCallBack [%x]\n", nRet);
    }

    //...Device operations

    // Close device
    nRet = MyDevice->Close();
    if (MV_OK != nRet)
    {
        printf("error: Close fail [%x]\n", nRet);
    }

    //...Other processes
}

See Also

MvCamCtrl::CTlFactory::CreateDevice


MvCamCtrl::CMvUsb3VDevice::RegisterImageCallBack

Register image data callback function.

virtual int RegisterImageCallBack(
  cbOutput    fOutputCallBack,
  void        *pUser
);

Parameters

fOutputCallBack
[in] Image data callback function
pUser
[in] User data

Callback Function

void(__stdcall* cbOutput)(
  unsigned char        *pData,
  MV_FRAME_OUT_INFO    *pFrameInfo
  void                 *pUser
);

Callback Function Parameters

pData
[out] Cache address used for saving image data
pFrameInfo
[out] Obtained frame information, including width, height, pixel format and so on.
pUser
[out] User data

Return Values

Successed, return MV_OK（0); failed, return Error Code.

Remarks

  • Set the image data callback function via this interface before calling MvCamCtrl::CMvUsb3VDevice::StartGrabbing.
  • There are two image data acquisition modes, but the two modes cannot be reused:
    Mode 1: Call MvCamCtrl::CMvUsb3VDevice::RegisterImageCallBack to set image data callback function, and then call MvCamCtrl::CMvUsb3VDevice::StartGrabbing to start the acquisition, the acquired image data will be returned in the set callback function.
    Mode 2: Call MvCamCtrl::CMvUsb3VDevice::StartGrabbing to start the acquisition, and then circularly call MvCamCtrl::CMvUsb3VDevice::GetOneFrame in the application layer to get the frame data of specified pixel format. When getting the frame data, the upper-level application layer should control the frequency of calling this interface according to the frame rate.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvUsb3VDevice.h"
using namespace MvCamCtrl;

void __stdcall ImageCallBack(unsigned char * pData, MV_FRAME_OUT_INFO* pFrameInfo, void* pUser)
{
    if (pFrameInfo)
    {
        // Add the system time when outputting
        char   szInfo[128] = {0};
        SYSTEMTIME sys;
        GetLocalTime( &sys );
        sprintf_s(szInfo, 128, "[%d-%02d-%02d %02d:%02d:%02d:%04d] : GetOneFrame succeed, width[%d], height[%d]", sys.wYear, sys.wMonth,
            sys.wDay, sys.wHour, sys.wMinute, sys.wSecond, sys.wMilliseconds, pFrameInfo->nWidth, pFrameInfo->nHeight);

        printf("%s\n", szInfo);
    }
}

void main()
{
   int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the USB 3.0 devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_USB_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvUsb3VDevice* MyDevice = dynamic_cast<CMvUsb3VDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    //Register data callback function
    nRet = MyDevice->RegisterImageCallBack(ImageCallBack, NULL);
    if (MV_OK != nRet)
    {
        printf("error: RegisterImageCallBack fail [%x]\n", nRet);
        return;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    // Start the image acquisition
    nRet = MyDevice->StartGrabbing();
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing [%x]\n", nRet);
        break;
    }

    //...Other processes

    // Stop the image acquisition
    nRet = MyDevice->StopGrabbing();
    if (MV_OK != nRet)
    {
         printf("error: StopGrabbing fail [%x]\n", nRet);
    }

    // Close device
    nRet = MyDevice->Close();
    if (MV_OK != nRet)
    {
        printf("error: Close fail [%x]\n", nRet);
    }

    // Destroy device from factory
    nRet = tlFactory.DestroyDevice(MyDevice);
    if (MV_OK != nRet)
    {
        printf("error: DestroyDevice fail [%x]\n", nRet);
    }
}

See Also

MvCamCtrl::CMvUsb3VDevice::StartGrabbing


MvCamCtrl::CMvUsb3VDevice::IsOpen

Judge the device status.

virtual bool IsOpen(
);

Return Values

TRUE means that the device is opened (connected), FALSE means that the device is free.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvUsb3VDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the USB3.0 devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_USB_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvUsb3VDevice* MyDevice = dynamic_cast<CMvUsb3VDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    //...Other processes
}

See Also

MvCamCtrl::CTlFactory::CreateDevice MvCamCtrl::CMvUsb3VDevice::Open


MvCamCtrl::CMvUsb3VDevice::Open

Open device (Connect device).

virtual int Open(
  unsigned int      nAccessMode = MV_ACCESS_Exclusive,
  unsigned short    nSwitchoverKey = 0
);

Parameters

nAccessMode
[in] Device access mode, the default is exclusive mode, the definitions are listed below:
Macro Definition | Value | Description
MV_ACCESS_Exclusive | 1 | Exclusive permission, the other APPs are only allowed to read CCP register.
MV_ACCESS_ExclusiveWithSwitch | 2 | Preempt permission from mode5, and then open as the exclusive permission.
MV_ACCESS_Control | 3 | Control permission, the other APPs are allowed to read all the registers.
MV_ACCESS_ControlWithSwitch | 4 | Preempt permission from mode5, and then open as the control permission.
MV_ACCESS_ControlSwitchEnable | 5 | Open as the control permission that can be preempted.
MV_ACCESS_ControlSwitchEnableWithKey | 6 | Preempt permission from mode5, and then open as the control permission that can be preempted.
MV_ACCESS_Monitor | 7 | Open device in read mode, applicable to the control permission.
nSwitchoverKey
[in] Password for switching permissions. By default, it is none. and it is valid when the access modes (mode2/4/6) support permission switch.

Return Values

Successed, return MV_OK（0); failed, return Error Code.

Remarks

  • Before connecting device and get device exclusive permission, you should create device example via MvCamCtrl::CTlFactory::CreateDevice.
  • For U3V device, the two parameters, nAccessMode and nSwitchoverKey, are invalid, the default device access mode is exclusive permission.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvUsb3VDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the USB 3.0 devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_USB_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvUsb3VDevice* MyDevice = dynamic_cast<CMvUsb3VDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        return;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        unsigned int nAccessMode = MV_ACCESS_Exclusive;
        unsigned short nSwitchoverKey = 0;
        nRet = MyDevice->Open(nAccessMode,nSwitchoverKey);
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
            return;
        }
    }

    //...Other processes
}

See Also

MvCamCtrl::CTlFactory::CreateDevice MvCamCtrl::CMvUsb3VDevice::Close


MvCamCtrl::CMvUsb3VDevice::Close

Close device.

virtual int Close(
);

Return Values

Successed, return MV_OK（0）; failed, return Error Code.

Remarks

After connecting device via MvCamCtrl::CMvUsb3VDevice::Open, you can disconnect the device and release exclusive permission via this interface.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvUsb3VDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the USB3.0 devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_USB_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvUsb3VDevice* MyDevice = dynamic_cast<CMvUsb3VDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    //...Device operations

    // Close device
    nRet = MyDevice->Close();
    if (MV_OK != nRet)
    {
        printf("error: Close fail [%x]\n", nRet);
    }

    //...Other processes
}

See Also

MvCamCtrl::CMvUsb3VDevice::Open


MvCamCtrl::CMvUsb3VDevice::SetImageNodeNum

Set the number of SDK internal image cache node.

virtual int SetImageNodeNum(
  unsigned int    nNum
);

Parameters

nNum
[in] The number of SDK internal image cache nodes, range from 1 to 30

Return Values

Successed, return MV_OK（0）; failed, return Error Code.

Remarks

Call this interface to set the number of SDK internal image cache nodes before calling MvCamCtrl::CMvUsb3VDevice::StartGrabbing to start capturing.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvUsb3VDevice.h"
using namespace MvCamCtrl;

void __stdcall ImageCallBack(unsigned char * pData, MV_FRAME_OUT_INFO* pFrameInfo, void* pUser)
{
    if (pFrameInfo)
    {
        // Add the system time when outputting
        char   szInfo[128] = {0};
        SYSTEMTIME sys;
        GetLocalTime( &sys );
        sprintf_s(szInfo, 128, "[%d-%02d-%02d %02d:%02d:%02d:%04d] : GetOneFrame succeed, width[%d], height[%d]", sys.wYear, sys.wMonth,
            sys.wDay, sys.wHour, sys.wMinute, sys.wSecond, sys.wMilliseconds, pFrameInfo->nWidth, pFrameInfo->nHeight);

        printf("%s\n", szInfo);
    }
}

void main()
{
   int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the USB 3.0 devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_USB_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvUsb3VDevice* MyDevice = dynamic_cast<CMvUsb3VDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    //Register data callback function
    nRet = MyDevice->RegisterImageCallBack(ImageCallBack, NULL);
    if (MV_OK != nRet)
    {
        printf("error: RegisterImageCallBack fail [%x]\n", nRet);
        return;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    //...Other processes

    //Set the number of SDK internal image cache nodes
    unsigned int nNum = 15;
    nRet = MyDevice->SetImageNodeNum(nNum);
    if (MV_OK != nRet)
    {
        printf("error: SetImageNodeNum fail [%x]\n", nRet);
        return;
    }

    // Start the image acquisition
    nRet = MyDevice->StartGrabbing();
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing [%x]\n", nRet);
        break;
    }

    //...Other processes

    // Stop the image acquisition
    nRet = MyDevice->StopGrabbing();
    if (MV_OK != nRet)
    {
         printf("error: StopGrabbing fail [%x]\n", nRet);
    }

    // Close device
    nRet = MyDevice->Close();
    if (MV_OK != nRet)
    {
        printf("error: Close fail [%x]\n", nRet);
    }

    // Destroy device from factory
    nRet = tlFactory.DestroyDevice(MyDevice);
    if (MV_OK != nRet)
    {
        printf("error: DestroyDevice fail [%x]\n", nRet);
    }
}

See Also

MvCamCtrl::CMvUsb3VDevice::Open MvCamCtrl::CMvUsb3VDevice::StartGrabbing


MvCamCtrl::CMvUsb3VDevice::SetAcquisitionMode

Set camera acquisition mode.

virtual int SetAcquisitionMode(
  MV_CAM_ACQUISITION_MODE    enMode
);

Parameters

enMode
[in] Acquisition mode, see value definition in Enumeration Type: MV_CAM_ACQUISITION_MODE

Return Values

Successed, return MV_OK（0）; failed, return Error Code.

Remarks

After connecting the device, call this interface to set the camera acquisition mode, including single frame, multiple frame or continuous acquisition mode.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvUsb3VDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the USB 3.0 devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_USB_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvUsb3VDevice* MyDevice = dynamic_cast<CMvUsb3VDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    //Set device acquisition mode
    unsigned int enMode = 2; //Continuous acquisition mode
    nRet = MyDevice->SetAcquisitionMode(enMode);
    if (MV_OK != nRet)
    {
        printf("error: SetAcquisitionMode [%x]\n", nRet);
    }

    //...Other processes
}

See Also

MvCamCtrl::CTlFactory::CreateDevice


MvCamCtrl::CMvUsb3VDevice::StartGrabbing

Start the image acquisition.

virtual int StartGrabbing(
);

Return Values

Successed, return MV_OK（0）; failed, return Error Code.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvUsb3VDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the USB 3.0 devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_USB_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvUsb3VDevice* MyDevice = dynamic_cast<CMvUsb3VDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    // Start the image acquisition
    nRet = MyDevice->StartGrabbing();
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing [%x]\n", nRet);
        break;
    }

    //...Other processes
}

See Also

MvCamCtrl::CMvUsb3VDevice::RegisterImageCallBack MvCamCtrl::CMvUsb3VDevice::GetOneFrame MvCamCtrl::CMvUsb3VDevice::StopGrabbing


MvCamCtrl::CMvUsb3VDevice::GetOneFrame

Get one frame image data.

virtual int GetOneFrame(
  unsigned char        *pData,
  unsigned int         nDataSize,
  MV_FRAME_OUT_INFO    *pFrameInfo
);

Parameters

pData
[in] Cache address used for saving image data
nDataSize
[in] Cache size
pFrameInfo
[out] Acquired frame information

Return Values

Successed, return MV_OK（0）; failed, return <strong><a href="ErrorCode.html">Error Code</a></strong>.

Remarks

Before calling this interface to get image frame data, you should call MvCamCtrl::CMvUsb3VDevice::StartGrabbing to enable the image acquisition. This interface will get frame data automatically, the upper-level application program should control the frequency of calling this interface according to frame rate.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvUsb3VDevice.h"
using namespace MvCamCtrl;

#define MAX_BUF_SIZE    (1920*1080*3)

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the USB 3.0 devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_USB_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvUsb3VDevice* MyDevice = dynamic_cast<CMvUsb3VDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    // Start the image acquisition
    nRet = MyDevice->StartGrabbing();
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing [%x]\n", nRet);
        break;
    }

    unsigned int    nTestFrameSize = 0;
    unsigned char*  g_pFrameBuf = NULL;
    g_pFrameBuf = (unsigned char*)malloc(MAX_BUF_SIZE);

    MV_FRAME_OUT_INFO stInfo;
    memset(&stInfo, 0, sizeof(MV_FRAME_OUT_INFO));

    //The upper-level application program should control the frequency of calling this interface according to frame rate.
    //The example code is for reference only, please create another thread to acquire and process the image data in the practical application.
    while(1)
    {
        if (nTestFrameSize > 99)
        {
            break;
        }
        nRet = MyDevice->GetOneFrame(g_pFrameBuf, MAX_BUF_SIZE, &stInfo);
        if (MV_OK != nRet)
        {
            Sleep(10);
        }
        else
        {
            //...Process image data
            nTestFrameSize++;
        }
    }

    // Stop the image acquisition
    nRet = MyDevice->StopGrabbing();
    if (MV_OK != nRet)
    {
         printf("error: StopGrabbing fail [%x]\n", nRet);
    }

    //...Other processes
}

See Also

MvCamCtrl::CMvUsb3VDevice::StartGrabbing


MvCamCtrl::CMvUsb3VDevice::Display

Display acquired image.

virtual int Display(
  void    *hWnd
);

Parameters

hWnd
[in] Window handle

Return Values

Successed, return MV_OK（0）; failed, return Error Code.

Remarks

This interface should be called after calling StartGrabbing, display the acquired image.

Example

The example code is for reference only.

#include <stdio.h>
#include "Windows.h"
#include "TlFactory.h"
#include "CameraParams.h"
#include "MvUsb3VDevice.h"
using namespace MvCamCtrl;

typedef HWND (WINAPI *PROCGETCONSOLEWINDOW)();
PROCGETCONSOLEWINDOW GetConsoleWindow;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the USB 3.0 devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_USB_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvUsb3VDevice* MyDevice = dynamic_cast<CMvUsb3VDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    // Start the image acquisition
    nRet = MyDevice->StartGrabbing();
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing [%x]\n", nRet);
        return;
    }

    //Get control panel window handle
    HMODULE hKernel32 = GetModuleHandle("kernel32");
    GetConsoleWindow = (PROCGETCONSOLEWINDOW)GetProcAddress(hKernel32,"GetConsoleWindow");
    HWND hWnd = GetConsoleWindow(); //Window handle

    //Display image
    nRet = MyDevice->Display(hWnd);
    if (MV_OK != nRet)
    {
        printf("error: Display [%x]\n", nRet);
        return;
    }

    //...Other processes
}

See Also

MvCamCtrl::CMvUsb3VDevice::StartGrabbing


MvCamCtrl::CMvUsb3VDevice::StopGrabbing

Stop the image acquisition.

virtual int StopGrabbing(
);

Return Values

Successed, return MV_OK（0）; failed, return Error Code.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvUsb3VDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the USB 3.0 devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_USB_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvUsb3VDevice* MyDevice = dynamic_cast<CMvUsb3VDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    // Start the image acquisition
    nRet = MyDevice->StartGrabbing();
    if (MV_OK != nRet)
    {
        printf("error: StartGrabbing [%x]\n", nRet);
        break;
    }

    //...Process image data

    // Stop the image acquisition
    nRet = MyDevice->StopGrabbing();
    if (MV_OK != nRet)
    {
         printf("error: StopGrabbing fail [%x]\n", nRet);
    }

    // Close device
    nRet = MyDevice->Close();
    if (MV_OK != nRet)
    {
        printf("error: Close fail [%x]\n", nRet);
    }

    // Destroy device from factory
    nRet = tlFactory.DestroyDevice(MyDevice);
    if (MV_OK != nRet)
    {
        printf("error: DestroyDevice fail [%x]\n", nRet);
    }
}

See Also

MvCamCtrl::CMvUsb3VDevice::StartGrabbing


MvCamCtrl::CMvUsb3VDevice::GetAllMatchInfo

Get information of different types.

virtual int GetAllMatchInfo(
  MV_ALL_MATCH_INFO    *pstInfo
);

Parameters

pstInfo
[in&out] Information structure

Return Values

Successed, return MV_OK（0）; failed, return Error Code.

Remarks

Input required information type (nType in MV_ALL_MATCH_INFO structure) to the interface, get corresponding information (return in the pInfo of MV_ALL_MATCH_INFO structure). This interface should be called after opening device via MvCamCtrl::CMvUsb3VDevice::Open. Before calling this interface, you should apply for pInfor cache by yourself, and input the pInfoSize cache size.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvUsb3VDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the USB 3.0 devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_USB_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvUsb3VDevice* MyDevice = dynamic_cast<CMvUsb3VDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        return;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    //...Other processes

    //Get camera network flow and packet loss information
    MV_ALL_MATCH_INFO struMatchInfo = {0};
    MV_MATCH_INFO_NET_DETECT stMatchInfoNetDetect;
    struMatchInfo.pInfo = &stMatchInfoNetDetect;

    struMatchInfo.nType = MV_MATCH_TYPE_NET_DETECT; //Camera network flow and packet loss information
    memset(struMatchInfo.pInfo, 0, sizeof(MV_MATCH_INFO_NET_DETECT));
    struMatchInfo.nInfoSize = sizeof(MV_MATCH_INFO_NET_DETECT);

    nRet = MyDevice->GetAllMatchInfo(&struMatchInfo);

    if (MV_OK != nRet)
    {
        printf("error: GetAllMatchInfo fail [%x]\n", nRet);
        return;
    }

    //...Other processes

    // Stop the image acquisition
    nRet = MyDevice->StopGrabbing();
    if (MV_OK != nRet)
    {
         printf("error: StopGrabbing fail [%x]\n", nRet);
    }

    // Close device
    nRet = MyDevice->Close();
    if (MV_OK != nRet)
    {
        printf("error: Close fail [%x]\n", nRet);
    }

    // Destroy device from factory
    nRet = tlFactory.DestroyDevice(MyDevice);
    if (MV_OK != nRet)
    {
        printf("error: DestroyDevice fail [%x]\n", nRet);
    }
}

See Also

MvCamCtrl::CMvUsb3VDevice::StartGrabbing


MvCamCtrl::CMvUsb3VDevice::GetGenICamXML

Get device XML description file.

virtual int GetGenICamXML(
  unsigned char    *pData,
  unsigned int     nDataSize,
  unsigned int     *pnDataLen
);

Parameters

pData
[in&out] Cache address for saving XML file data
nDataSize
[in] Cache size
pnDataLen
[out] XML file data length

Return Values

Successed, return MV_OK（0）; failed, return Error Code.

Remarks

When pData is NULL or nDataSize is smaller than actual XML file size, do not copy data, return XML file size by pnDataLen;
When pData is a valid cache address and the cache size is large enough, copy the complete data and save it to the cache, and then return actual XML file size by pnDataLen.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvUsb3VDevice.h"
using namespace MvCamCtrl;

#define MAX_XML_FILE_SIZE       (1024*1024*1)

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the USB 3.0 devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_USB_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvUsb3VDevice* MyDevice = dynamic_cast<CMvUsb3VDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    unsigned char* pXMLBuf = (unsigned char*)malloc(MAX_XML_FILE_SIZE);
    if (NULL == pXMLBuf)
    {
        printf("error: malloc xml buffer failed!\n");
        break;
    }

   unsigned int nXMLDataLen = 0;
   nRet = MyDevice->GetGenICamXML(pXMLBuf, MAX_XML_FILE_SIZE, &nXMLDataLen);
   if (MV_OK != nRet || nXMLDataLen > MAX_XML_FILE_SIZE)
   {
        printf("error: GetGenICamXML failed! [%x]\n", nRet);
        break;
   }

    //...Other processes

    //Close device
    nRet = MyDevice->Close();
    if (MV_OK != nRet)
    {
        printf("error: Close fail [%x]\n", nRet);
    }

    //Destroy device from factory
    nRet = tlFactory.DestroyDevice(MyDevice);
    if (MV_OK != nRet)
    {
        printf("error: DestroyDevice fail [%x]\n", nRet);
    }
}

See Also

MvCamCtrl::CMvUsb3VDevice::Open


MvCamCtrl::CMvUsb3VDevice::GetTlProxy

Get transport layer proxy used by GenICam.

virtual TlProxy GetTlProxy(
);

Return Values

Successed, return transport layer proxy example (TlProxy); failed, return NULL.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvUsb3VDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the USB 3.0 devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_USB_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvUsb3VDevice* MyDevice = dynamic_cast<CMvUsb3VDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        return;
    }

    TlProxy m_pMyPortTl = MyDevice->GetTlProxy();
    if (NULL == m_pMyPortTl)
    {
        printf("error: get gige transport layer failed!\n");
        return;
    }

    //...Other processes
}

See Also

MvCamCtrl::CTlFactory::CreateDevice


MvCamCtrl::CMvUsb3VDevice::LocalUpgrade

Device local upgrade.

virtual int LocalUpgrade(
  const void    *pFilePathName
);

Parameters

pFilePathName
[in] File path of upgrade package, including the absolue path of file name.

Return Values

Successed, return MV_OK（0); failed, return Error Code.

Remarks

Send the upgrade firmware to device for upgrade via this interface. This interface will start returning until the upgrade firmware was successfully sent to device, the responding time may be quite long.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvUsb3VDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the USB3.0 devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_USB_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvUsb3VDevice* MyDevice = dynamic_cast<CMvUsb3VDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        return;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
            return;
        }
    }

    //Device local upgrade
    nRet = MyDevice->LocalUpgrade("C://digicap.dav");
    if (MV_OK != nRet)
    {
        printf("error: LocalUpgrade [%x]\n", nRet);
        return;
    }
    //...Other processes
}

See Also

MvCamCtrl::CTlFactory::CreateDevice MvCamCtrl::CMvUsb3VDevice::Open


MvCamCtrl::CMvUsb3VDevice::GetUpgradeProcess

Get upgrade progress.

virtual int GetUpgradeProcess(
  unsigned int    *pnProcess
);

Parameters

pnProcess
[out] Upgrade progress, range from 0 to 100

Return Values

Successed, return MV_OK（0); failed, return Error Code.

Remarks

Get upgrade progress percentage.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvUsb3VDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the USB 3.0 devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_USB_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvUsb3VDevice* MyDevice = dynamic_cast<CMvUsb3VDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        return;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
            return;
        }
    }

    //Device local upgrade
    nRet = MyDevice->LocalUpgrade("C://digicap.dav");
    if (MV_OK != nRet)
    {
        printf("error: LocalUpgrade [%x]\n", nRet);
        return;
    }

    //Get upgrade progress
    unsigned int iProcess = 0;
    while(1)
    {
        nRet = MyDevice->GetUpgradeProcess(&iProcess);
        if(iProcess == 100)
        {
            printf("error: GetUpgradeProcess [%x]\n", nRet);
            break;
        }
        Sleep(1000);
    }

    //...Other processes
}

See Also

MvCamCtrl::CMvUsb3VDevice::LocalUpgrade


MvCamCtrl::CMvUsb3VDevice::ReadMemory

Read data from device register.

virtual int ReadMemory(
  void       *pBuffer,
  __int64    nAddress,
  __int64    nLength
);

Parameters

pBuffer
[out] Data buffer, save the read memory value (the memory value is stored as big-end mode)
nAddress
[in] Memory address to be read, get this address from the Camera.xml file of device, such as the XML node value of xxx_RegAddr（the Camera.xml file of device will automatically generate in the application program catalog after opening the device)
nLength
[in] Memory length to be read

Return Values

Successed, return MV_OK（0）; failed, return Error Code.

Remarks

Login the device, read the data of a register segment.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvUsb3VDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the USB 3.0 devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_USB_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvUsb3VDevice* MyDevice = dynamic_cast<CMvUsb3VDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    // Read data from device register
    unsigned int nWidth = 0;
    nRet = MyDevice->ReadMemory(&nWidth, 0x00030360L, 4L);
    if (MV_OK != nRet)
    {
        printf("error: ReadMemory [%x]\n", nRet);
        break;
    }

    //...Other processes
}

See Also

MvCamCtrl::CTlFactory::CreateDevice MvCamCtrl::CMvUsb3VDevice::WriteMemory


MvCamCtrl::CMvUsb3VDevice::WriteMemory

Write data into device register.

virtual int WriteMemory(
  const void    *pBuffer,
  __int64       nAddress,
  __int64       nLength
);

Parameters

pBuffer
[in] Memory value to be written (notice that the memory value should be stored as big-end mode)
nAddress
[in] Memory address to be written. You can get this address from the Camera.xml file of device, such as the XML node value of xxx_RegAddr (the Camera.xml file of device will automatically generate in the application program catalog after opening the device
nLength
[in] Memory length to be written

Return Values

Successed, return MV_OK（0）; failed, return Error Code.

Remarks

Login the device, write a piece of data to a register segment.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "CameraParams.h"
#include "MvUsb3VDevice.h"
using namespace MvCamCtrl;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    //  Enumerate all the USB 3.0 devices within the subnet, return the device information list
    MV_CC_DEVICE_INFO_LIST stDevList;
    memset(&stDevList, 0, sizeof(MV_CC_DEVICE_INFO_LIST));

    nRet = tlFactory.EnumDevices(MV_USB_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (stDevList.nDeviceNum == 0)
    {
        printf("no camera found\n");
        Sleep(100000000);
    }
    else
    {
        for (int n = 0; n < stDevList.nDeviceNum; n++)
        {
            printf("%d . %s\n", n, stDevList.pDeviceInfo[n]->SpecialInfo.stGigEInfo.chModelName);
        }
        printf("select one：");
        scanf("%d", &i);
        if (i < 0 || i >= stDevList.nDeviceNum)
        {
            printf("error : input\n");
            Sleep(10000000);
        }
    }

    // Select the first searched online devices and create device example
    int i=0;
    CMvUsb3VDevice* MyDevice = dynamic_cast<CMvUsb3VDevice*>(tlFactory.CreateDevice(*(stDevList.pDeviceInfo[i])));

    if (NULL == MyDevice)
    {
        printf("error: CreateDevice\n");
        break;
    }

    // Open device
    if (!MyDevice->IsOpen())
    {
        nRet = MyDevice->Open();
        if (MV_OK != nRet)
        {
            printf("error: Open [%x]\n", nRet);
        }
    }

    // Read data from device register
    unsigned int nWidth = 0;
    nRet = MyDevice->ReadMemory(&nWidth, 0x00030360L, 4L);
    if (MV_OK != nRet)
    {
        printf("error: ReadMemory [%x]\n", nRet);
        break;
    }

    // Write data into device register
    unsigned int nWidth = 320;
    nRet = MyDevice->WriteMemory(&nWidth, 0x00030360L, 4L);
    if (MV_OK != nRet)
    {
        printf("error: WriteMemory [%x]\n", nRet);
        break;
    }

    //...Other processes
}

See Also

MvCamCtrl::CTlFactory::CreateDevice MvCamCtrl::CMvUsb3VDevice::ReadMemory


GenApi::CNodeMapRef::_LoadXMLFromFile

Load device XML file.

void _LoadXMLFromFile(
  GenICam::gcstring    FileName
);

Parameters

FileName
[in] XML file path (contain absolute path of file name)

Return Values

None.

Remarks

This method needs catch to receive exception.
Export XML file from device via interface MvCamCtrl::CMvGigEDevice::GetGenICamXML.

Example

The example code is for reference only.

#include "GenApi/GenApi.h"
using namespace GenApi;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        return;
    }

    if (stDevList.nDeviceNum > 0)
    {
        printf("find [%d] gige device\n", stDevList.nDeviceNum);
    }
    else
    {
        printf("find no gige device\n");
        return;
    }

    // Select the searched online devices and create device example
    CMvGigEDevice *pMvGigEDevice = (CMvGigEDevice *)tlFactory.CreateDevice(*(stDevList.pDeviceInfo[0]));
    if (NULL == pMvGigEDevice)
    {
        return;
    }

    // Open device
    nRet = pMvGigEDevice->Open();
    if (MV_OK != nRet)
    {
        printf("open fail, error code[%x]\n", nRet);
        return -1;
    }

    //Get GenICam used transport proxy
    TlProxy pTlProxy = pMvGigEDevice->GetTlProxy();
    if (NULL == pTlProxy)
    {
        printf("%s\n", "Failed to Get transport layer!");
        return;
    }

    CNodeMapRef* m_Camera = new CNodeMapRef;
    try
    {
        // Load XML
        m_Camera->_LoadXMLFromFile("testdevice.xml");

        // Import transport layer, connect device
        m_Camera->_Connect((IPort*)pTlProxy, "Device");

        // Get corresponding nodes of specified field
        CIntegerPtr ptrNode = m_Camera->_GetNode("Width");
        if (NULL == ptrNode)
        {
            printf("error: m_Camera->_GetNode fail!\n");
            break;
        }

        // Get specified field value
        int nValue = ptrNode->GetValue();
        printf("get value [%x]\n", nValue);

        // Set specified field value
        nValue = 1280;
        ptrNode->SetValue(nValue);
        printf("set value [%x]\n", nValue);
    }
    catch (GenICam::InvalidArgumentException e)
    {
        printf("InvalidArgumentException: [%s]\n",e.what());

    }

    catch (GenICam::OutOfRangeException e)
    {
        printf("OutOfRangeException: [%s]\n",e.what());
    }

    catch (GenICam::PropertyException e)
    {
        printf("PropertyException: [%s]\n",e.what());
    }

    catch (GenICam::RuntimeException e)
    {
        printf("RuntimeException: [%s]\n",e.what());
    }

    catch (GenICam::LogicalErrorException e)
    {
        printf("LogicalErrorException: [%s]\n",e.what());
    }

    catch (GenICam::AccessException e)
    {
        printf("AccessException: [%s]\n",e.what());

    }

    catch (GenICam::TimeoutException e)
    {
        printf("TimeoutException: [%s]\n",e.what());
    }

    catch (GenICam::DynamicCastException e)
    {
        printf("DynamicCastException: [%s]\n",e.what());
    }

    catch (GenICam::GenericException e)
    {
        printf("GenericException: [%s]\n",e.what());
    }

    catch (...)
    {
        printf("other unknown errors\n");
    }

}

See Also

MvCamCtrl::CMvGigEDevice::GetGenICamXML


GenApi::CNodeMapRef::_Connect

Import transport layer, connect device.

virtual bool _Connect(
  IPort*                      pPort,
  const GenICam::gcstring&    PortName
);

Parameters

pPort
[in] Transport layer proxy
PortName
[in] Port name

Return Values

None.

Remarks

  • This method needs catch to receive exception.
  • Get transport layer proxy via interface MvCamCtrl::CMvGigEDevice::GetTlProxy.
  • This function iss only used for setting transport layer proxy, which has nothing to do with the transport layer proxy validity.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "MvErrorDefine.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
#include "NodeMapRef.h"
#include "IPort.h"
#include "GenApi.h"

using namespace MvCamCtrl;
using namespace GenApi;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        return;
    }

    if (stDevList.nDeviceNum > 0)
    {
        printf("find [%d] gige device\n", stDevList.nDeviceNum);
    }
    else
    {
        printf("find no gige device\n");
        return;
    }

    // Select the searched online devices and create device example
    CMvGigEDevice *pMvGigEDevice = (CMvGigEDevice *)tlFactory.CreateDevice(*(stDevList.pDeviceInfo[0]));
    if (NULL == pMvGigEDevice)
    {
        return;
    }

    // Open device
    nRet = pMvGigEDevice->Open();
    if (MV_OK != nRet)
    {
        printf("open fail, error code[%x]\n", nRet);
        return -1;
    }

    //Get GenICam used transport proxy
    TlProxy pTlProxy = pMvGigEDevice->GetTlProxy();
    if (NULL == pTlProxy)
    {
        printf("%s\n", "Failed to Get transport layer!");
        return;
    }

    CNodeMapRef* m_Camera = new CNodeMapRef;
    try
    {
        // Load XML
        m_Camera->_LoadXMLFromFile("testdevice.xml");

        // Import transport layer, connect device
        m_Camera->_Connect((IPort*)pTlProxy, "Device");

        // Get corresponding nodes of specified field
        CIntegerPtr ptrNode = m_Camera->_GetNode("Width");
        if (NULL == ptrNode)
        {
            printf("error: m_Camera->_GetNode fail!\n");
            break;
        }

        // Get specified field value
        int nValue = ptrNode->GetValue();
        printf("get value [%x]\n", nValue);

        // Set specified field value
        nValue = 1280;
        ptrNode->SetValue(nValue);
        printf("set value [%x]\n", nValue);
    }
    catch (...)
    {
         printf("error: GenICam XML module error!\n");
    }

    //...Other processing method

    if (m_Camera)
    {
        m_Camera->_Destroy();

        delete m_Camera;
        m_Camera = NULL;
    }

    nRet = pMvGigEDevice->Close();
    if (MV_OK != nRet)
    {
        printf("Close device fail [%x]\n", nRet);
    }

    nRet = tlFactory.DestroyDevice(pMvGigEDevice);
    if (MV_OK != nRet)
    {
        printf("DestroyDevice fail [%x]\n", nRet);
    }
}

See Also

MvCamCtrl::CMvGigEDevice::GetTlProxy


GenApi::CNodeMapRef::_GetNode

Get nodes of specified field.

virtual INode* _GetNode(
  const GenICam::gcstring&    key
) const;

Parameters

key
[in] Field name, see detailed values in XML Node Parameter Type List

Return Values

None.

Remarks

This method needs catch to receive exception.
Get transport layer proxy via interface MvCamCtrl::CMvGigEDevice::GetTlProxy.

Example

The example code is for reference only.

#include "GenApi/GenApi.h"
using namespace GenApi;

void main()
{
    int nRet = -1;

    // Get a factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the GigE devices within the subnet, return the device information list
    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        return;
    }

    if (stDevList.nDeviceNum > 0)
    {
        printf("find [%d] gige device\n", stDevList.nDeviceNum);
    }
    else
    {
        printf("find no gige device\n");
        return;
    }

    // Select the searched online devices and create device example
    CMvGigEDevice *pMvGigEDevice = (CMvGigEDevice *)tlFactory.CreateDevice(*(stDevList.pDeviceInfo[0]));
    if (NULL == pMvGigEDevice)
    {
        return;
    }

    // Open device
    nRet = pMvGigEDevice->Open();
    if (MV_OK != nRet)
    {
        printf("open fail, error code[%x]\n", nRet);
        return -1;
    }

    //Get GenICam used transport proxy
    TlProxy pTlProxy = pMvGigEDevice->GetTlProxy();
    if (NULL == pTlProxy)
    {
        printf("%s\n", "Failed to Get transport layer!");
        return;
    }

    CNodeMapRef* m_Camera = new CNodeMapRef;
    try
    {
        // Load XML
        m_Camera->_LoadXMLFromFile("testdevice.xml");

        // Import transport layer, connect device
        m_Camera->_Connect((IPort*)pTlProxy, "Device");

        // Get corresponding nodes of specified field
        CIntegerPtr ptrNode = m_Camera->_GetNode("Width");
        if (NULL == ptrNode)
        {
            printf("error: m_Camera->_GetNode fail!\n");
            break;
        }

        // Get specified field value
        int nValue = ptrNode->GetValue();
        printf("get value [%x]\n", nValue);

        // Set specified field value
        nValue = 1280;
        ptrNode->SetValue(nValue);
        printf("set value [%x]\n", nValue);
    }
    catch (...)
    {
         printf("error: GenICam XML module error!\n");
    }
}

See Also

MvCamCtrl::CMvGigEDevice::GetTlProxy


GenApi::IInteger::GetValue

Get specified field value.

virtual int64_t GetValue(
  bool    Verify,
  bool    IgnoreCache
);

Parameters

Verify
[in] Whether to enable value range verfication, the default is false
IgnoreCache
[in] Whether to ignore the cache data, the default is false

Return Values

Successed, return specified field value, failed, throw exception.

Remarks

This method needs catch to receive exception.
The field value returned by interface. Specify different types, e.g., CIntegerPtr, CStringPtr, CRegisterPtr, CEnumerationPtr and so on, according to different field, refer to XML Node Parameter Types for detailed parameter types and values. For more types and GenAPi interface description, refer to GenICam Standard document.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "MvErrorDefine.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
#include "NodeMapRef.h"
#include "IPort.h"
#include "GenApi.h"

using namespace MvCamCtrl;
using namespace GenApi;

void main()
{
    int nRet = -1;

    // Get factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the devices within the subnet, return the device information list
    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        return;
    }

    if (stDevList.nDeviceNum > 0)
    {
        printf("find [%d] gige device\n", stDevList.nDeviceNum);
    }
    else
    {
        printf("find no gige device\n");
        return;
    }

    // Select the found online devices and create device example
    CMvGigEDevice *pMvGigEDevice = (CMvGigEDevice *)tlFactory.CreateDevice(*(stDevList.pDeviceInfo[0]));
    if (NULL == pMvGigEDevice)
    {
        return;
    }

    // Open device
    nRet = pMvGigEDevice->Open();
    if (MV_OK != nRet)
    {
        printf("open fail, error code[%x]\n", nRet);
        return -1;
    }

    //Get transport layer proxy used by GenICam
    TlProxy pTlProxy = pMvGigEDevice->GetTlProxy();
    if (NULL == pTlProxy)
    {
        printf("%s\n", "Failed to Get transport layer!");
        return;
    }

    CNodeMapRef* m_Camera = new CNodeMapRef;
    try
    {
        // Load XML
        m_Camera->_LoadXMLFromFile("testdevice.xml");

        // Import transport layer proxy and connect device
        m_Camera->_Connect((IPort*)pTlProxy, "Device");

        // Get nodes of specified fields
        CIntegerPtr ptrNode = m_Camera->_GetNode("Width");
        if (NULL == ptrNode)
        {
            printf("error: m_Camera->_GetNode fail!\n");
            break;
        }
        int nValue = ptrNode->GetValue(); //Get specified field value
        printf("Device width is:%d\n", nValue);

        CFloatPtr pstSFloat = m_Camera->_GetNode("ExposureTime");
        if (NULL == pstSFloat)
        {
            printf("%s\n" , "Failed to GetNode ExposureTime");
            throw MV_E_NODATA;
        }
        printf("Device exposure duration is :%f\n", pstSFloat->GetValue());

        CEnumerationPtr pstEnumNode = m_Camera->_GetNode("BalanceWhiteAuto");
        if (NULL == pstEnumNode)
        {
            throw MV_E_GC_GENERIC;
        }
        printf("White balance is :%d\n", pstEnumNode->GetIntValue());

        //Destroy transport layer proxy and disconnect the device
        pNodeMapRef->_Destroy();
    }
    catch (...)
    {
         printf("error: GenICam XML module error!\n");
    }

    //...Other processes

    if (m_Camera)
    {
        m_Camera->_Destroy();

        delete m_Camera;
        m_Camera = NULL;
    }

    nRet = pMvGigEDevice->Close();
    if (MV_OK != nRet)
    {
        printf("Close device fail [%x]\n", nRet);
    }

    nRet = tlFactory.DestroyDevice(pMvGigEDevice);
    if (MV_OK != nRet)
    {
        printf("DestroyDevice fail [%x]\n", nRet);
    }
}

See Also

MvCamCtrl::CMvGigEDevice::GetTlProxy GenApi::IInteger::SetValue


GenApi::IInteger::SetValue

Set specified field value.

virtual void SetValue(
  int64_t    Value,
  bool       Verify
);

Parameters

Value
[in] Set parameters
Verify
[in] Whether to enable access mode and value range verification, the default is true

Return Values

None. Failed, throw exception.

Remarks

This method needs catch to receive exception.
The field value returned by interface. Specify different types, e.g., CIntegerPtr, CStringPtr, CRegisterPtr, CEnumerationPtr and so on, according to different field, refer to XML Node Parameter Types for detailed parameter types and values. For more types and GenAPi interface description, refer to GenICam Standard document.

Example

The example code is for reference only.

#include "TlFactory.h"
#include "MvErrorDefine.h"
#include "CameraParams.h"
#include "MvGigEDevice.h"
#include "NodeMapRef.h"
#include "IPort.h"
#include "GenApi.h"

using namespace MvCamCtrl;
using namespace GenApi;

void main()
{
    int nRet = -1;

    // Get factory example
    CTlFactory& tlFactory = CTlFactory::GetInstance();

    // Enumerate all the devices within the subnet, return the device information list
    nRet = tlFactory.EnumDevices(MV_GIGE_DEVICE, stDevList);
    if (MV_OK != nRet)
    {
        return;
    }

    if (stDevList.nDeviceNum > 0)
    {
        printf("find [%d] gige device\n", stDevList.nDeviceNum);
    }
    else
    {
        printf("find no gige device\n");
        return;
    }

    // Select the found online devices and create device example
    CMvGigEDevice *pMvGigEDevice = (CMvGigEDevice *)tlFactory.CreateDevice(*(stDevList.pDeviceInfo[0]));
    if (NULL == pMvGigEDevice)
    {
        return;
    }

    // Open device
    nRet = pMvGigEDevice->Open();
    if (MV_OK != nRet)
    {
        printf("open fail, error code[%x]\n", nRet);
        return -1;
    }

    //Get transport layer proxy used by GenICam
    TlProxy pTlProxy = pMvGigEDevice->GetTlProxy();
    if (NULL == pTlProxy)
    {
        printf("%s\n", "Failed to Get transport layer!");
        return;
    }

    CNodeMapRef* m_Camera = new CNodeMapRef;
    try
    {
        // Load XML
        m_Camera->_LoadXMLFromFile("testdevice.xml");

        // Import transport layer proxy and connect device
        m_Camera->_Connect((IPort*)pTlProxy, "Device");

        // Get nodes of specified fields
        CIntegerPtr ptrNode = m_Camera->_GetNode("Width");
        if (NULL == ptrNode)
        {
            printf("error: m_Camera->_GetNode fail!\n");
            break;
        }
        printf("Device width is:%d\n", ptrNode->GetValue());
        nValue = ptrNode->GetMax();;
        ptrNode->SetValue(nValue); //Set specified field value
        printf("set value [%x]\n", nValue);

        CFloatPtr pstSFloat = m_Camera->_GetNode("ExposureTime");
        if (NULL == pstSFloat)
        {
            printf("%s\n" , "Failed to GetNode ExposureTime");
            throw MV_E_NODATA;
        }
        float fExposureTimeMax = pstSFloat->GetMax();
        float fExposureTimeMin = pstSFloat->GetMin();
        float fExposureTime = 0.0f;
        printf("Input device exposure duration needs to be set(between %f and %f): \n", fExposureTimeMax, fExposureTimeMin);
        scanf("%f", &fExposureTime);
        pstSFloat->SetValue(fExposureTime);
        printf("Setting exposure duration successed.\n");

        CEnumerationPtr pstEnumNode = m_Camera->_GetNode("BalanceWhiteAuto");
        if (NULL == pstEnumNode)
        {
            throw MV_E_GC_GENERIC;
        }
        unsigned int nWhiteAuto = 0;
        printf("Input device auto white balance needs to be set:\n");
        scanf("%d", &nWhiteAuto);
        pstEnumNode->SetIntValue(nWhiteAuto);
        printf("Setting device auto white balance successed.\n");

        //Destroy transport layer proxy and disconnect the device
        pNodeMapRef->_Destroy();
    }
    catch (...)
    {
         printf("error: GenICam XML module error!\n");
    }

    //...Other processes

    if (m_Camera)
    {
        m_Camera->_Destroy();

        delete m_Camera;
        m_Camera = NULL;
    }

    nRet = pMvGigEDevice->Close();
    if (MV_OK != nRet)
    {
        printf("Close device fail [%x]\n", nRet);
    }

    nRet = tlFactory.DestroyDevice(pMvGigEDevice);
    if (MV_OK != nRet)
    {
        printf("DestroyDevice fail [%x]\n", nRet);
    }
}

See Also

MvCamCtrl::CMvGigEDevice::GetTlProxy GenApi::IInteger::GetValue


Cautions

1.Windows System

  • Install camera driver
Before using SDK for connection and development of machine vision camera, make sure appropriate camera driver is installed. If not, disable Windows Firewall when the PC is streaming.
  • NIC
It is recommended to use Intel series 1000M NIC, and go to Local Area Connection Status to enable Jumbo Frame function, as shown below:

2.Linux System

  • Environment variable configuration
Develop under Linux, configure environment variable first, as shown below:
1.Switch to root (operate under root even while operating)
2.Open /etc/rc.local, add before exit 0 (make sure effective when driver restarts):
chmod +x /opt/run_driver.sh
./opt/run_driver.sh
3.Execute in current directory:
chmod 0777 environment.sh run_driver.sh
source environment.sh
4.Under root user, open /etc/profile, add at the end:
export GENICAM_ROOT_V2_4=/opt/GenICam_V2_4
export LD_LIBRARY_PATH=/usr/local/lib
Save and restart.
  • Shut fire wall
If cameras cannot be enumerated in Linux system, shut the fire wall. Below are methods to shut fire wall in different Linux systems (for reference only):
1.Ubuntu
Default as shut when starting
2.Fedora
Shut: systemctl stop firewalld
Shut permanently: chkconfig firewalld off
3.Centos7
Shut temporarily: service firewalld stop or systemctl stop firewalld
Shut permanently: chkconfig firewalld off
4.Centos6.5
Shut temporarily: service iptables stop
Shut permanently: chkconfig iptables off
5.RedHat7
Shut temporarily: service firewalld stop or systemctl stop firewalld
Shut permanently: chkconfig firewalld off
  • NIC
It is recommended to enable jumbo frame in Linux. See below for how (for reference only):
1.Enable temporarily: ifconfig eth0 mtu 7000
2.Enable permanently: write "ifconfig eth0 mtu 7000" to the last line of /opt/run_driver.sh, and it will become effective after restart.
Note: eth0 means NIC name, and may vary in different systems; 7000 means the max. size of the received packet, and the max-sized packet may not be received by older NIC. Set GEVSCPSPacketSize of camera to actual value accordingly.


Machine Vision SDK Programming Guide

V2.0


XML Node Parameter Type List

Function | Name（_GetNode: keyParameters） | Data Type | Value Range Definition | Accessing Mode | Description
Device Control | DeviceType | IEnumeration | 0：Transmitter 1：Receiver 2：Transceiver 3：Peripheral | R | Device type
 | DeviceScanType | IEnumeration | 0：Areascan 1：Linescan | R | The scan mode of device sensor, which means that the device is line scan camera or area scan camera
 | DeviceVendorName | IString | Any null terminates the string | R | Device manufacturer name
 | DeviceModelName | IString | Any null terminates the string | R | Device model
 | DeviceManufacturerInfo | IString | Any null terminates the string | R | Device manufacturer information
 | DeviceVersion | IString | Any null terminates the string | R | Device version
 | DeviceFirmwareVersion | IString | Any null terminates the string | R | Firmware version
 | DeviceSerialNumber | IString | Any null terminates the string | R | Device serial No.
 | DeviceID | IString | Any null terminates the string | R | Device ID
 | DeviceUserID | IString | Any null terminates the string | R/W | Custom name
 | DeviceUptime | Iinteger | ≥0 | R | Device runtime
 | BoardDeviceType | Iinteger | ≥0 | R | Device type
 | DeviceConnectionSelector | Iinteger | ≥0 | R/(W) | Device connection selection
 | DeviceConnectionSpeed | Iinteger | ≥0，unit: Mbps | R | Device connection speed
 | DeviceLinkSelector | IInteger | ≥0 | R/(W) | Device connection selection
 | DeviceLinkSpeed | IInteger | ≥0 | R | Transmission link speed
 | DeviceLinkConnectionCount | IInteger | ≥0 | R | Device connection quantity
 | DeviceLinkHeartbeatMode | IEnumeration | 0：On 1：Off | R/W | Whether needs heartbeat
 | DeviceStreamChannelCount | Iinteger | ≥0 | R | Stream channel quantity
 | DeviceStreamChannelSelector | Iinteger | ≥0 | R/(W) | Stream channel selection
 | DeviceStreamChannelType | Ienumeration | 0：Transmitter 1：Receiver | R | Stream channel type
 | DeviceStreamChannelLink | Iinteger | ≥0 | R | Stream channel connection quantity
 | DeviceStreamChannelEndianness | Ienumeration | 0: Little 1: Big | R | Image data byte-order
 | DeviceStreamChannelPacketSize | IInteger | Relate to camera. Generally, the range is from 220 to 9156, step-by-step is 8； | R/(W) | Stream data packet size of receiving end
 | DeviceEventChannelCount | IInteger | ≥0 | R | Device supported
 | DeviceCharacterSet | IEnumeration | 1：UTF-8 2: ASCII | R | Character set used in device register
 | DeviceReset | ICommand | - | W | Reboot device
 | DeviceMaxThroughput | Iinteger | ≥0 | R | Device maximum throughput (bandwidth)
Image Format Control | WidthMax | IInteger | ＞0 | R | Image maximum width, data after binning
 | HeightMax | IInteger | ＞0 | R | Image maximum height, data after binning
 | RegionSelector | IEnumeration | 0：Region0 1：Region1 2：Region2 8：All | R/(W) | ROI selector
 | RegionDestination | IEnumeration | 0：Stream0 1：Stream1 2：Stream2 | R/(W) | The corresponding stream of ROI
 | Width | IInteger | ＞0 | R/(W) | ROI width
 | Height | IInteger | ＞0 | R/(W) | ROI height
 | OffsetX | IInteger | ≥0 | R/W | ROI offset in horizontal direction
 | OffsetY | IInteger | ≥0 | R/W | ROI offset in vertical direction
 | ReverseScanDirection | Iboolean | ≥0 | R/(W) | Transform the scanning direction
 | PixelFormat | IEnumeration | 0x01080001:Mono8 0x01100003:Mono10 0x010C0004:Mono10Packed 0x01100005:Mono12 0x010C0006:Mono12Packed 0x01100007:Mono16 0x02180014:RGB8Packed 0x02100032:YUV422_8 0x0210001F:YUV422_8_UYVY 0x01080008:BayerGR8 0x01080009:BayerRG8 0x0108000A:BayerGB8 0x0108000B:BayerBG8 0x0110000e:BayerGB10 0x01100012:BayerGB12 0x010C002C:BayerGB12Packed | R/(W) | Image pixel format, different camera models support different pixel format, the actual camera shall prevail.
 | PixelSize | IEnumeration | 8 ：Bpp8 10：Bpp10 12：Bpp12 16：Bpp16 24：Bpp24 32：Bpp32 | R/(W) | Bit quantity contained in a pixel
 | ImageCompressionMode | IEnumeration | 0：Off 1：JPEG | R/(W) | Image compression mode
 | ImageCompressionQuality | Iinteger | ≥50 | R/(W) | Image compression quality
 | TestPatternGeneratorSelector | IEnumeration | 8：Sensor 0：Region0 1: Region1 2: Region2 | R/(W) | Test image generator selection
 | TestPattern | IEnumeration | 0 ：Off 1：Black 2：White 3：GreyHorizontalRamp 4：GreyVerticalRamp 5：GreyHorizontalRampMoving 6：GreyVerticalRampMoving 7：HorizontalLineMoving 8：VerticalLineMoving 9：ColorBar 10：FrameCounter 11：MonoBar 12：TestImage12 13：TestImage13 14：ObliqueMonoBar 15：ObliqueColorBar 16：GradualMonoBar | R/(W) | Test image selection
 | FrameSpecInfoSelector | IEnumeration | 0 ：Timestamp 1：Gain 2：Exposure 3：BrightnessInfo 4：WhiteBalance 5：Framecounter 6：ExtTriggerCount 7：LineInputOutput 8：ROIPosition | R/(W) | Watermark information selection
 | FrameSpecInfo | IBoolean | True False | R/W | Whether to enable the watermark information
Acquisition Control | AcquisitionMode | IEnumeration | 0:SingleFrame 1:MultiFrame 2:Continuous | R/(W) | Acquisition mode, single frame, multi-frame, continuous
 | AcquisitionStart | ICommand | - | W | Start streaming
 | AcquisitionStop | ICommand | - | W | Stop streaming
 | AcquisitionBurstFrameCount | IInteger | ≥0 | R/W | Acquired frame quantity for one time triggering
 | AcquisitionLineRate | IInteger | ≥1 | R/W | Line frequency settings
 | AcquisitionLineRateEnable | IBoolean | True False | R/W | Enable line frequency control
 | ResultingLineRate | IInteger | ≥0, unit: hz | R | Actual line frequency
 | ResultingFrameRate | IFloat | ≥0.0，unit: fps | R | Actual acquisition frame rate of camera
 | TriggerSelector | IEnumeration | 0 ：AcquisitionStart 1：AcquisitionEnd 2：AcquisitionActive 3：FrameStart 4：FrameEnd 5：FrameActive 6：FrameBurstStart 7：FrameBurstEnd 8：FrameBurstActive 9：LineStart 10：ExposureStart 11：ExposureEnd 12：ExposureActive | R/W | Triggering event selection
 | TriggerMode | IEnumeration | 0：Off 1：On | R/W | Trigger mode
 | TriggerSource | IEnumeration | 0:Line0 1:Line1 2:Line2 3.Line3 4:Counter0 7:Software 8:FrequencyConverter | R/W | Trigger source
 | TriggerActivation | IEnumeration | 0:RisingEdge 1:FallingEdge 2.LevelHigh 3.LevelLow | R/W | Triggered rising edge, fallling edge, high level, low level and so on
 | TriggerDelay | IFloat | ≥0.0，unit: us | R/W | Trigger delay
 | ExposureMode | IEnumeration | 0:Timed 1:TriggerWidth | R/W | Exposure mode selection
 | ExposureTime | IFloat | ≥0.0，unit: us | R/W | Exposure time
 | ExposureAuto | IEnumeration | 0：Off 1：Once 2：Continuous | R/W | Auto exposure
 | AutoExposureTimeLowerLimit | IInteger | ≥0，unit: us | R/(W) | Auto exposure time lower limit
 | AutoExposureTimeupperLimit | IInteger | ≥0，unit: us | R/(W) | Auto exposure time upper limit
 | FrameTimeoutEnable | IBoolean | 0：Off 1：On | R/W | Enable frame timeout
 | FrameTimeoutTime | Iinteger | ≥87，unit: ms | R/W | Frame timeout
Analog Control | Gain | IFloat | ≥0.0，unit: dB | R/W | Gain value
 | GainAuto | IEnumeration | 0:Off 1:Once 2:Continuous | R/W | Auto gain
 | AutoGainLowerLimit | IFloat | ≥0.0，unit: dB | R/W | Lower limit of auto gain value
 | AutoGainupperLimit | IFloat | ≥0.0，unit: dB | R/W | Upper limit of auto gain value
 | ADCGainEnable | IBoolean | 0：Off 1：On | R/W | Enable ADC gain
 | DigitalShift | IFloat | ≥0.0 | R | Digital offset adjustment
 | DigitalShiftEnable | IBoolean | 0：Off 1：On | R/W | Enable digital offset
 | Brightness | Iinteger | ≥0 | R/W | Brightness
 | BlackLevel | IFloat | ≥0.0 | R/W | Black level adjustment
 | BlackLevelEnable |  |  |  | Enable black level adjustment
 | BalanceWhiteAuto | IEnumeration | 0:Off 1:Continuous 2:Once | R/W | Auto white balance
 | BalanceRatioSelector | Ienumeration | 0: Red 1: Green 2. Blue | R | White balance ratio selection
 | BalanceRatio | Iinteger | ≥0 | R | White balance value
 | Gamma | IFloat | ＞0.0 | R/W | Gamma adjustment
 | GammaSelector | Ienumeration | 1：User 2：sRGB | R/W | Gamma selection
 | GammaEnable | IBoolean | 0：Off 1：On | R/W | Enable gamma
 | Hue | Iinteger | ≥0 | R | Hue value adjustment
 | HueEnable | Iboolean | 0：Off 1：On | R/W | Enablee hue
 | Saturation | Iinteger | ≥0 | R | Saturation adjustment
 | SaturationEnable | Iboolean | 0：Off 1：On | R/W | Enable saturation
 | AutoFunctionAOISelector | Ienumeration | 0: AOI1 1: AOI2 | R/W | Auto AOI selection
 | AutoFunctionAOIWidth | Iinteger | ≥0 | R/W | Auto AOI width
 | AutoFunctionAOIHeight | Iinteger | ≥0 | R/W | Auto AOI height
 | AutoFunctionAOIOffsetX | Iinteger | ≥0 | R | Auto AOI offset in horizontal direction
 | AutoFunctionAOIUsageIntensity | Iboolean | 0：Off 1：On | R/W | Auto exposure according to AOI area
 | AutoFunctionAOIUsageWhiteBalance | Iboolean | 0：Off 1：On | R | Auto white balance according to AOI area
LUT Control | LUTSelector | IEnumeration | 0:Luminance 1:Red 2:Green 3:Blue | R/W | Brightness, R\G\B
 | LUTEnable | IBoolean | True False | R/W | Enable
 | LUTIndex | IInteger | ≥0 | R/W | Index No.
 | LUTValue | IInteger | Device-specific | R/W | Value
Encoder Control | EncoderSelector | IEnumeration | 0 ：Encoder0 1：Encoder1 2：Encoder2 | R/W | Encoder selection
 | EncoderSourceA | IEnumeration | 0 ：Line0 1：Line1 2：Line2 3：Line3 | R/W | Encoder A source selection
 | EncoderSourceB | IEnumeration | 0 ：Line0 1：Line1 2：Line2 3：Line3 | R/W | Encoder B source selection
 | EncoderTriggerMode | IEnumeration | 0 ：AnyDirection 1：ForwardOnly | R/W | Encoder trigger mode
 | EncoderCounterMode | IEnumeration | 0 ：IgnoreDirection 1：FollowDirection | R/W | Encoder counting mode
 | EncoderCounter | Iinteger | ≥0 | R | Encoder counter value adjustment
 | EncoderCounterMax | Iinteger | ≥1 | R/W | Maximum value of encoder counter
 | EncoderCounterReset | Icommand | - | R/W | Encoder counter reset
 | EncoderMaxReverseCounter | Iinteger | ≥1 | R/W | Maximum value of encoder reverse counter
 | EncoderReverseCounterReset | Icommand | - | R/W | Encoder reverse counter reset
Frequency Converter Control | InputSource | Ienumeration | 0 ：Line0 1：Line1 2：Line2 3：Line3 | R/W | Input source of frequency divider
 | SignalAlignment | Ienumeration | 0：RisingEdge 1：FallingEdge | R/W | Signal dirrection of frequency divider
 | PreDivider | Iinteger | ≥1 | R/W | Prescalar adjustment
 | Multiplier | Iinteger | ≥1 | R/W | Frequency multiplier adjustment
 | PostDivider | Iinteger | ≥1 | R/W | Postscaler adjustment
Shading Correction | ShadingSelector | IEnumeration | 0：FPNCCorrection 1：PRNUCCorrection | R/W | Correction selection of bright and dark field
 | ActivateShading | ICommand | - | R/(W) | Auto correction
 | NUCEnable | IBoolean | 0: Off 1: ON | R/W | Enable NUC switch
 | PRNUCEnable | IBoolean | 0: Off 1: ON | R/W | PRNUC Status switch
Digital IO Control | LineSelector | IEnumeration | 0: Line0 1: Line1 2: Line2 3: Line3 4: Line4 | R/W | I/O selection
 | LineMode | IEnumeration | 0: Input 1: Output 2: Trigger 8: Strobe | R/(W) | I/O mode
 | LineStatus | IBoolean | - | R/(W) | I/O status
 | LineStatusAll | IInteger | ≥0 | R | All I/O status
 | LineDebouncerTime | IInteger | - | R/W | I/O debouncing time
Transport Layer Control | PayloadSize | IInteger | ≥0 | R | Size of one frame data
 | GevVersionMajor | IInteger | GEV main version No. | R | GEV major version No.
 | GevVersionMinor | IInteger | GEV sub-version No. | R | GEV minor version No.
 | GevDeviceModeIsBigEndian | IBoolean | 0：not BigEndian 1: Is BigEndian | R | Big-endian
 | GevDeviceModeCharacterSet | IEnumeration | 1：UTF8 | R | Character set
 | GevInterfaceSelector | IInteger | >=0 | R/(W) | GEV interface quantity
 | GevMACAddress | IInteger | Mac address | R | MAC address
 | GevCurrentIPConfigurationLLA | IBoolean | 0：Off 1：On | R | Whether the IP is LLA
 | GevCurrentIPConfigurationDHCP | IBoolean | 0：Off 1：On | R/W | Whether the IP is DHCP
 | GevCurrentIPConfigurationPersistentIP | IBoolean | 0：Off 1：On | R/W | Whether the IP is static IP
 | GevCurrentIPAddress | Iinteger | IP address | R | IP address
 | GevCurrentSubnetMask | Iinteger | Subnet mask | R | Subnet mask
 | GevCurrentDefaultGateway | Iinteger | Default gateway | R | Default gateway
 | GevFirstURL | IString | - | R | XML first choice path
 | GevSecondURL | IString | - | R | XML second choice path
 | GevNumberOfInterfaces | Iinteger | ≥0 | R | GEV interface quantity
 | GevPersistentIPAddress | Iinteger | ≥0 | R/W | Static IP address
 | GevPersistentSubnetMask | Iinteger | ≥0 | R/W | Static subnet mask
 | GevPersistentDefaultGateway | Iinteger | ≥0 | R/W | Static default gateway
 | GevLinkSpeed | IInteger | ≥0 | R | Network speed
 | GevMessageChannelCount | Iinteger | ≥0 | R | Message channel quantity
 | GevStreamChannelCount | Iinteger | ≥0 | R | Stream channel
 | GevHeartbeatTimeout | Iinteger | ≥0 | R/W | Heartbeeat timeout
 | GevGVCPHeartbeatDisable | IBoolean | 0：Off 1：On | R/W | Close heartbeat
 | GevTimestampTickFrequency | Iinteger | ≥0，unithz | R | Timestamp frequency
 | GevTimestampControlLatch | ICommand | - | W | Get timestamp
 | GevTimestampControlReset | ICommand | - | W | Reset timestamp
 | GevTimestampControlLatchReset | ICommand | - | W | Reset timestamp and meanwhile get timestamp
 | GevTimestampValue | Iinteger | - | R | Timestamp value
 | GevCCP | IEnumeration | 0：OpenAcess 1:ExclusiveAccess 2:ControlAccess | R/W | App control permission
 | GevStreamChannelSelector | Iinteger | >=0 | R/W | Stream channel selection
 | GevSCPInterfaceIndex | Iinteger | >=0 | R | GEV interface index
 | GevSCPHostPort | Iinteger | >=0 | R/(W) | Host port
 | GevSCPDirection | Iinteger | >=0 | R | Show the stream channel direction
 | GevSCPSFireTestPacket | IBoolean | 0：Off 1：On | R/(W) | Enable fire test packet
 | GevSCPSDoNotFragment | IBoolean | 0：Off 1：On | R/W | Enable fire test packet
 | GevSCPSBigEndian | IBoolean | 0：Off 1：On | R | Stream data big-endian and little-endian
 | GevSCPSPacketSize | IInteger | ＞0,Relate to camera. Generally, the range is from 220 to 9156，the step-by-step is 8； | R/W | Network packet size
 | GevSCPD | IInteger | ≥0 | R/W | Forwarding packet delay发包延时
 | GevSCDA | IInteger | IP address | R | Destination address of stream data
 | GevSCSP | IInteger | Port No. | R | Source port of stream data
User Settings Control | UserSetCurrent | Iinteger | >=0 | R | Current user parameter
 | UserSetSelector | IEnumeration | 0:Default 1:UserSet1 2:UserSet2 3:UserSet3 | R/W | Set the loaded parameters
 | UserSetLoad | ICommand | - | W | Load
 | UserSetSave | ICommand | - | W | Save
 | UserSetDefault | IEnumeration | 0:Default 1:UserSet1 2:UserSet2 3:UserSet3 | R/W | Defauult status


Return value description

Type | Value | Description
MV_OK | 0 | Success, no error
General error definition: range 0x80000000-0x800000FF |  |
MV_E_HANDLE | 0x80000000 | Error or invalid handle
MV_E_SUPPORT | 0x80000001 | Not supported function
MV_E_BUFOVER | 0x80000002 | Buffer full
MV_E_CALLORDER | 0x80000003 | Function calling order error
MV_E_PARAMETER | 0x80000004 | Incorrect parameter
MV_E_RESOURCE | 0x80000006 | Resource application failed
MV_E_NODATA | 0x80000007 | No data
MV_E_PRECONDITION | 0x80000008 | Invalid precondition, or the operating environment has changed
MV_E_VERSION | 0x80000009 | Version not matched
MV_E_NOENOUGH_BUF | 0x8000000A | Not enough memory space for input
MV_E_UNKNOW | 0x800000FF | Unknown error
GenICam series error: range 0x80000100-0x800001FF |  |
MV_E_GC_GENERIC | 0x80000100 | General error
MV_E_GC_ARGUMENT | 0x80000101 | Illegal parameter
MV_E_GC_RANGE | 0x80000102 | Value exceeding the range
MV_E_GC_PROPERTY | 0x80000103 | Properties
MV_E_GC_RUNTIME | 0x80000104 | Operating environment error
MV_E_GC_LOGICAL | 0x80000105 | Logic error
MV_E_GC_ACCESS | 0x80000106 | Invalid node access condition
MV_E_GC_TIMEOUT | 0x80000107 | Timeout
MV_E_GC_DYNAMICCAST | 0x80000108 | Conversion exception
MV_E_GC_UNKNOW | 0x800001FF | GenICam unknown error
GigE_STATUS error code: range 0x80000200-0x800002FF |  |
MV_E_NOT_IMPLEMENTED | 0x80000200 | Command not supported by device
MV_E_INVALID_ADDRESS | 0x80000201 | Target address does not exist
MV_E_WRITE_PROTECT | 0x80000202 | Target address cannot be written
MV_E_ACCESS_DENIED | 0x80000203 | Access denied
MV_E_BUSY | 0x80000204 | Device busy, or network disconnected
MV_E_PACKET | 0x80000205 | Network packet data error
MV_E_NETER | 0x80000206 | Network error
USB_STATUS error code: range 0x80000300-0x800003FF |  |
MV_E_USB_READ | 0x80000300 | Reading usb error
MV_E_USB_WRITE | 0x80000301 | Writing usb error
MV_E_USB_DEVICE | 0x80000302 | Device exception
MV_E_USB_GENICAM | 0x80000303 | GenICam error
MV_E_USB_BANDWIDTH | 0x80000304 | Not enough bandwidth
MV_E_USB_UNKNOW | 0x800003FF | Unknown USB error
Error codes for upgrade: range 0x80000400-0x800004FF |  |
MV_E_UPG_FILE_MISMATCH | 0x80000400 | Upgrade firmware not matched
MV_E_UPG_LANGUSGE_MISMATCH | 0x80000401 | Upgrade firmware language not matched
MV_E_UPG_CONFLICT | 0x80000402 | Upgrade conflict (the error code is returned for requesting upgrade while upgrading)
MV_E_UPG_INNER_ERR | 0x80000403 | Internal error while upgrading the camera
MV_E_UPG_UNKNOW | 0x800004FF | Unknown error while upgrading


EPixelType

Pixel Type Enumeration

enum _EPixelType_{
  PixelType_Undefined          = -1,
  PixelType_Mono1packed        = 0x80000000 | PIXEL_MONO | PIXEL_BIT_COUNT(1)  | 0x000c,
  PixelType_Mono2packed        = 0x80000000 | PIXEL_MONO | PIXEL_BIT_COUNT(2)  | 0x000d,
  PixelType_Mono4packed        = 0x80000000 | PIXEL_MONO | PIXEL_BIT_COUNT(4)  | 0x000e,
  PixelType_Mono8              = PIXEL_MONO | PIXEL_BIT_COUNT(8)  | 0x0001,
  PixelType_Mono8signed        = PIXEL_MONO | PIXEL_BIT_COUNT(8)  | 0x0002,
  PixelType_Mono10             = PIXEL_MONO | PIXEL_BIT_COUNT(16) | 0x0003,
  PixelType_Mono10packed       = PIXEL_MONO | PIXEL_BIT_COUNT(12) | 0x0004,
  PixelType_Mono10p            = PIXEL_MONO | PIXEL_BIT_COUNT(10) | 0x0046,
  PixelType_Mono12             = PIXEL_MONO | PIXEL_BIT_COUNT(16) | 0x0005,
  PixelType_Mono12packed       = PIXEL_MONO | PIXEL_BIT_COUNT(12) | 0x0006,
  PixelType_Mono12p            = PIXEL_MONO | PIXEL_BIT_COUNT(12) | 0x0047,
  PixelType_Mono16             = PIXEL_MONO | PIXEL_BIT_COUNT(16) | 0x0007,
  PixelType_BayerGR8           = PIXEL_MONO | PIXEL_BIT_COUNT(8)  | 0x0008,
  PixelType_BayerRG8           = PIXEL_MONO | PIXEL_BIT_COUNT(8)  | 0x0009,
  PixelType_BayerGB8           = PIXEL_MONO | PIXEL_BIT_COUNT(8)  | 0x000a,
  PixelType_BayerBG8           = PIXEL_MONO | PIXEL_BIT_COUNT(8)  | 0x000b,
  PixelType_BayerGR10          = PIXEL_MONO | PIXEL_BIT_COUNT(16) | 0x000c,
  PixelType_BayerRG10          = PIXEL_MONO | PIXEL_BIT_COUNT(16) | 0x000d,
  PixelType_BayerGB10          = PIXEL_MONO | PIXEL_BIT_COUNT(16) | 0x000e,
  PixelType_BayerBG10          = PIXEL_MONO | PIXEL_BIT_COUNT(16) | 0x000f,
  PixelType_BayerGR12          = PIXEL_MONO | PIXEL_BIT_COUNT(16) | 0x0010,
  PixelType_BayerRG12          = PIXEL_MONO | PIXEL_BIT_COUNT(16) | 0x0011,
  PixelType_BayerGB12          = PIXEL_MONO | PIXEL_BIT_COUNT(16) | 0x0012,
  PixelType_BayerBG12          = PIXEL_MONO | PIXEL_BIT_COUNT(16) | 0x0013,
  PixelType_RGB8packed         = PIXEL_COLOR | PIXEL_BIT_COUNT(24) | 0x0014,
  PixelType_BGR8packed         = PIXEL_COLOR | PIXEL_BIT_COUNT(24) | 0x0015,
  PixelType_RGBA8packed        = PIXEL_COLOR | PIXEL_BIT_COUNT(32) | 0x0016,
  PixelType_BGRA8packed        = PIXEL_COLOR | PIXEL_BIT_COUNT(32) | 0x0017,
  PixelType_RGB10packed        = PIXEL_COLOR | PIXEL_BIT_COUNT(48) | 0x0018,
  PixelType_BGR10packed        = PIXEL_COLOR | PIXEL_BIT_COUNT(48) | 0x0019,
  PixelType_RGB12packed        = PIXEL_COLOR | PIXEL_BIT_COUNT(48) | 0x001a,
  PixelType_BGR12packed        = PIXEL_COLOR | PIXEL_BIT_COUNT(48) | 0x001b,
  PixelType_RGB16packed        = PIXEL_COLOR | PIXEL_BIT_COUNT(48) | 0x0033,
  PixelType_BGR10V1packed      = PIXEL_COLOR | PIXEL_BIT_COUNT(32) | 0x001c,
  PixelType_BGR10V2packed      = PIXEL_COLOR | PIXEL_BIT_COUNT(32) | 0x001d,
  PixelType_YUV411packed       = PIXEL_COLOR | PIXEL_BIT_COUNT(12) | 0x001e,
  PixelType_YUV422packed       = PIXEL_COLOR | PIXEL_BIT_COUNT(16) | 0x001f,
  PixelType_YUV444packed       = PIXEL_COLOR | PIXEL_BIT_COUNT(24) | 0x0020,
  PixelType_RGB8planar         = PIXEL_COLOR | PIXEL_BIT_COUNT(24) | 0x0021,
  PixelType_RGB10planar        = PIXEL_COLOR | PIXEL_BIT_COUNT(48) | 0x0022,
  PixelType_RGB12planar        = PIXEL_COLOR | PIXEL_BIT_COUNT(48) | 0x0023,
  PixelType_RGB16planar        = PIXEL_COLOR | PIXEL_BIT_COUNT(48) | 0x0024,
  PixelType_YUV422_YUYV_Packed = PIXEL_COLOR | PIXEL_BIT_COUNT(16) | 0x0032,
  PixelType_BayerGR12Packed    = PIXEL_MONO | PIXEL_BIT_COUNT(12) | 0x002A,
  PixelType_BayerRG12Packed    = PIXEL_MONO | PIXEL_BIT_COUNT(12) | 0x002B,
  PixelType_BayerGB12Packed    = PIXEL_MONO | PIXEL_BIT_COUNT(12) | 0x002C,
  PixelType_BayerBG12Packed    = PIXEL_MONO | PIXEL_BIT_COUNT(12) | 0x002D,
  PixelType_BayerGR12p         = PIXEL_MONO | PIXEL_BIT_COUNT(12) | 0x0057,
  PixelType_BayerRG12p         = PIXEL_MONO | PIXEL_BIT_COUNT(12) | 0x0059,
  PixelType_BayerGB12p         = PIXEL_MONO | PIXEL_BIT_COUNT(12) | 0x0055,
  PixelType_BayerBG12p         = PIXEL_MONO | PIXEL_BIT_COUNT(12) | 0x0053,
  PixelType_BayerGR16          = PIXEL_MONO | PIXEL_BIT_COUNT(16) | 0x002E,
  PixelType_BayerRG16          = PIXEL_MONO | PIXEL_BIT_COUNT(16) | 0x002F,
  PixelType_BayerGB16          = PIXEL_MONO | PIXEL_BIT_COUNT(16) | 0x0030,
  PixelType_BayerBG16          = PIXEL_MONO | PIXEL_BIT_COUNT(16) | 0x0031,
  PixelType_RGB12V1packed      = PIXEL_COLOR | PIXEL_BIT_COUNT(36) | 0X0034
  PixelType_Double             = 0x80000000 | PIXEL_MONO | PIXEL_BIT_COUNT(48) | 0x100,
}EPixelType

Remarks

Macro definitions of enumeration types are listed below:

Macro Definition | Value
PIXEL_MONO | 0x01000000
PIXEL_COLOR( | 0x02000000
PIXEL_BIT_COUNT(n) | ((n) << 16)

See Also

MV_FRAME_OUT_INFO


MV_ALL_MATCH_INFO

Different match type information

struct _MV_ALL_MATCH_INFO_{
  unsigned int    nType;
  void            *pInfo;
  unsigned int    nInfoSize;
}MV_ALL_MATCH_INFO;

Members

nType
[in] Information type should be outputted
pInfo
[out] Application layer should allocate storage for outpout information cache.
nInfoSize
[in] Information cache size

Remarks

The corresponding output structures of pInfo are different as the information types are different, see as the following table:

nType macro definition | Value | Description | pInfo Structure
MV_MATCH_TYPE_NET_DETECT | 0x00000001 | Network flow and packet loss information | MV_MATCH_INFO_NET_DETECT
MV_MATCH_TYPE_USB_DETECT | 0x00000002 | Total byte number of U3V device received by host | MV_MATCH_INFO_NET_DETECT

See Also

C interface：MV_CC_GetAllMatchInfo

C++ interface：MvCamCtrl::CMvGigEDevice::GetAllMatchInfo MvCamCtrl::CMvUsb3VDevice::GetAllMatchInfo


MV_CAM_ACQUISITION_MODE

Acquisition Mode Enumeration

enum _MV_CAM_ACQUISITION_MODE_{
  MV_ACQ_MODE_SINGLE      = 0,  //Single frame mode
  MV_ACQ_MODE_MUTLI       = 1,  //Multi-frame mode
  MV_ACQ_MODE_CONTINUOUS  = 2   //Contimuous acquisition mode
}MV_CAM_ACQUISITION_MODE

See Also

C interface：MV_CC_GetAcquisitionMode MV_CC_SetAcquisitionMode

C++ interface：MvCamCtrl::CMvGigEDevice::SetAcquisitionMode MvCamCtrl::CMvUsb3VDevice::SetAcquisitionMode


MV_CAM_BALANCEWHITE_AUTO

Auto White Balance Mode

enum _MV_CAM_BALANCEWHITE_AUTO_{
  MV_BALANCEWHITE_AUTO_OFF         = 0,  //Disable
  MV_BALANCEWHITE_AUTO_CONTINUOUS  = 1,  //Continuous
  MV_BALANCEWHITE_AUTO_ONCE        = 2   //Once
}MV_CAM_BALANCEWHITE_AUTO

See Also

MV_CC_GetBalanceWhiteAuto MV_CC_SetBalanceWhiteAuto


MV_CAM_EXPOSURE_AUTO_MODE

Auto Exposure Mode

enum _MV_CAM_EXPOSURE_AUTO_MODE_{
  MV_EXPOSURE_AUTO_MODE_OFF         = 0,  //Disable
  MV_EXPOSURE_AUTO_MODE_ONCE        = 1,  //Once
  MV_EXPOSURE_AUTO_MODE_CONTINUOUS  = 2   //Continuous
}MV_CAM_EXPOSURE_AUTO_MODE

See Also

MV_CC_GetExposureAutoMode MV_CC_SetExposureAutoMode


MV_CAM_GAIN_MODE

Gain Mode Enumeration Type

enum _MV_CAM_GAIN_MODEE_{
  MV_GAIN_MODE_OFF         = 0,  //Disable
  MV_GAIN_MODE_ONCE        = 1,  //Once
  MV_GAIN_MODE_CONTINUOUS  = 2   //Continuous
}MV_CAM_GAIN_MODE

See Also

MV_CC_GetGainMode MV_CC_SetGainMode


MV_CAM_GAMMA_SELECTOR

Gamma Type

enum _MV_CAM_GAMMA_SELECTOR_{
  MV_GAMMA_SELECTOR_USER       = 1, //Custom
  MV_GAMMA_SELECTOR_SRGB       = 2  //sRGB type
}MV_CAM_GAMMA_SELECTOR

See Also

MV_CC_GetGammaSelector MV_CC_SetGammaSelector


MV_CAM_TRIGGER_MODE

Trigger Mode

enum _MV_CAM_TRIGGER_MODE_{
  MV_TRIGGER_MODE_OFF    = 0,  //Disable
  MV_TRIGGER_MODE_ON     = 1   //Enable
}MV_CAM_TRIGGER_MODE

See Also

MV_CC_GetTriggerMode MV_CC_SetTriggerMode


MV_CAM_TRIGGER_SOURCE

Trigger Source

enum _MV_CAM_TRIGGER_SOURCE_{
  MV_TRIGGER_SOURCE_LINE0       = 0, //LINE0 hardware trigger
  MV_TRIGGER_SOURCE_LINE1       = 1, //LINE1 hardware trigger
  MV_TRIGGER_SOURCE_LINE2       = 2, //LINE2 hardware trigger
  MV_TRIGGER_SOURCE_LINE3       = 3, //LINE3 hardware trigger
  MV_TRIGGER_SOURCE_COUNTER0    = 4, //COUNTER0 hardware trigger
  MV_TRIGGER_SOURCE_SOFTWARE    = 7  //Software trigger
}MV_CAM_TRIGGER_SOURCE

See Also

MV_CC_GetTriggerSource MV_CC_SetTriggerSource


MV_CC_DEVICE_INFO

Device information structure

struct _MV_CC_DEVICE_INFO_{
  unsigned short             nMajorVer;
  unsigned short             nMinorVer;
  unsigned int               nMacAddrHigh;
  unsigned int               nMacAddrLow;
  unsigned int               nTLayerType;
  unsigned int               nReserved[4];
  union
  {
      MV_GIGE_DEVICE_INFO    stGigEInfo;
      MV_USB3_DEVICE_INFO    stUsb3VInfo;
  }SpecialInfo;
}MV_CC_DEVICE_INFO;

Members

nMajorVer
Major version No.
nMinorVer
Minor version No.
nMacAddrHigh
High MAC address
nMacAddrLow
Low MAC address
nTLayerType
Transport layer type, definitions are listed below:
Macro Definition | Value | Description
MV_UNKNOW_DEVICE | 0x00000000 | Unknown device type
MV_GIGE_DEVICE | 0x00000001 | GigE device
MV_1394_DEVICE | 0x00000002 | 1394-a/b device
MV_USB_DEVICE | 0x00000004 | USB3.0 device
MV_CAMERALINK_DEVICE | 0x00000008 | CameraLink device
nReserved
Reserve byte
stGigEInfo
GIGE device information，valid when nTLayerType is MV_GIGE_DEVICE (different transport layers correspond different device information）
stUsb3VInfo
USB device information, valid when nTLayerType is MV_USB_DEVICE （different transport layers correspond different device information）

See Also

MV_CC_DEVICE_INFO_LIST

C interface：MV_CC_CreateHandle MV_CC_IsDeviceAccessible MV_CC_GetDeviceInfo

C++ interface：MvCamCtrl::CTlFactory::CreateDevice MvCamCtrl::CTlFactory::IsDeviceAccessible MvCamCtrl::CMvGigEDevice::GetDeviceInfo


MV_CC_DEVICE_INFO_LIST

Device information list

struct _MV_CC_DEVICE_INFO_LIST_{
  unsigned int         nDeviceNum;
  MV_CC_DEVICE_INFO    *pDeviceInfo[MV_MAX_DEVICE_NUM];
}MV_CC_DEVICE_INFO_LIST;

Members

nDeviceNum
Online device quantity
pDeviceInfo
Online device information, each array means a device, up to 256 devices can be supported

See Also

C interface：MV_CC_EnumDevices

C++ interface：EnumDevices


MV_FRAME_OUT_INFO

Outputted frame information structure

struct _MV_FRAME_OUT_INFO_{
  unsigned short     nWidth;
  unsigned short     nHeight;
  MvGvspPixelType    enPixelType;
  unsigned int       nFrameNum;
  unsigned int       nDevTimeStampHigh;
  unsigned int       nDevTimeStampLow;
  unsigned int       nReserved0;
  int64_t            nHostTimeStamp;
  unsigned int       nFrameLen;
  unsigned int       nReserved[3];
}MV_FRAME_OUT_INFO;

Members

nWidth
Image width
nHeight
Image height
enPixelType
Pixel format, see detailed definition in "Enumeration Type"：MvGvspPixelType
nFrameNum
Frame No.
nDevTimeStampHigh
Timestamp generated by camera, high-order 32-bits
nDevTimeStampLow
Timestamp generated by camera, low-order 32-bits
nReserved0
Reserved（align 8 bytes）
nHostTimeStamp
Timestamp generated by host
nFrameLen
Frame length
nReserved
Reserved

See Also

C interface：MV_CC_GetOneFrame MV_CC_RegisterImageCallBack

C++ interface：MvCamCtrl::CMvGigEDevice::GetOneFrame MvCamCtrl::CMvGigEDevice::RegisterImageCallBack
MvCamCtrl::CMvUsb3VDevice::GetOneFrame MvCamCtrl::CMvUsb3VDevice::RegisterImageCallBack


MV_FRAME_OUT_INFO_EX

Outputted frame information structure

struct _MV_FRAME_OUT_INFO_EX_{
  unsigned short     nWidth;
  unsigned short     nHeight;
  MvGvspPixelType         enPixelType;
  unsigned int       nFrameNum;
  unsigned int       nDevTimeStampHigh;
  unsigned int       nDevTimeStampLow;
  unsigned int       nReserved0;
  int64_t            nHostTimeStamp;
  unsigned int       nFrameLen;
  unsigned int       nSecondCount;
  unsigned int       nCycleCount;
  unsigned int       nCycleOffset;
  float              fGain;
  float              fExposureTime;
  unsigned int       nAverageBrightness;
  unsigned int       nRed;
  unsigned int       nGreen;
  unsigned int       nBlue;
  unsigned int       nFrameCounter;
  unsigned int       nTriggerIndex;
  unsigned int       nInput;
  unsigned int       nOutput;
  unsigned short     nOffsetX;
  unsigned short     nOffsetY;
  unsigned int       nReserved[41];
}MV_FRAME_OUT_INFO_EX;

Members

nWidth
Image width
nHeight
Image height
enPixelType
Pixel format, see detailed definitions in "Enumeration Type"：MvGvspPixelType
nFrameNum
Frame No.
nDevTimeStampHigh
Timestamp generated by camera, high-order 32-bits
nDevTimeStampLow
Timestamp generated by camera, low-order 32-bits
nReserved0
Reserved（align 8 bytes
nHostTimeStamp
Timestamp generated by host
nFrameLen
Frame length
nSecondCount
Seconds, increase by second
nCycleCount
Clock period counting, increase by 125us, reset in every 1 second.
nCycleOffset
Clock period offset, reset in every 125us
fGain
Gain
fExposureTime
Exposure time
nAverageBrightness
Averagee brightness
nRed
WB red
nGreen
WB green
nBlue
WB blue
nFrameCounter
Frame number
nTriggerIndex
Trigger counting
nInput
Line input
nOutput
Line output
nOffsetX
X value of ROI area offset
nOffsetY
Y value of ROI area offset
nReserved
Reserved

See Also

C interface：MV_CC_GetOneFrameEx MV_CC_RegisterImageCallBackEx

C++ interface：MvCamCtrl::CMvGigEDevice::GetOneFrameEx MvCamCtrl::CMvGigEDevice::RegisterImageCallBackEx


MV_GIGE_DEVICE_INFO

GIGE device information structure

struct _MV_GIGE_DEVICE_INFO_{
  unsigned int     nIpCfgOption;
  unsigned int     nIpCfgCurrent;
  unsigned int     nCurrentIp;
  unsigned int     nCurrentSubNetMask;
  unsigned int     nDefultGateWay;
  unsigned char    chManufacturerName[32];
  unsigned char    chModelName[32];
  unsigned char    chDeviceVersion[32];
  unsigned char    chManufacturerSpecificInfo[48];
  unsigned char    chSerialNumber[16];
  unsigned char    chUserDefinedName[16];
  unsigned int     nNetExport;
  unsigned int     nReserved[4];
}MV_GIGE_DEVICE_INFO;

Members

nIpCfgOption
IP configuration options
nIpCfgCurrent
Current IP configuration
nCurrentIp
Current device IP
nCurrentSubNetMask
Current subnet mask
nDefultGateWay
Default gateway
chManufacturerName
Manufacturer name
chModelName
Model name
chDeviceVersion
Device version
chManufacturerSpecificInfo
Manufacturing batch information
chSerialNumber
Serial No.
chUserDefinedName
Custom name
nNetExport
Network port IP address
nReserved
Reserve bytes

See Also

MV_CC_DEVICE_INFO


MV_GIGE_EVENT

Event enumeration type

enum _MV_GIGE_EVENT_{
  MV_EVENT_ExposureEnd                 = 1,  //The end of each frame exposure, not support
  MV_EVENT_FrameStartOvertrigger       = 2,  //Frame starts over-trigger (the next frame is triggered before the end of the previous frame trigger), not support
  MV_EVENT_AcquisitionStartOvertrigger = 3,  //Streaming start over-trigger（the streaming signal is sent too often), not support
  MV_EVENT_FrameStart                  = 4,  //Start each frame, not support
  MV_EVENT_AcquisitionStart            = 5,  //Strat streaming (continuous or single frame mode), not support
  MV_EVENT_EventOverrun                = 6   //Event over-trigger (the event is sent too often), not support
}MV_GIGE_EVENT

See Also

MV_CC_RegisterEventCallBack MvCamCtrl::CMvGigEDevice::RegisterEventCallBack


MV_IMAGE_BASIC_INFO

Imagee basic information

struct _MV_IMAGE_BASIC_INFO_{
  unsigned short     nWidthValue;
  unsigned short     nWidthMin;
  unsigned short     nWidthMax;
  unsigned short     nWidthInc;
  unsigned short     nHeightValue;
  unsigned short     nHeightMin;
  unsigned short     nHeightMax;
  unsigned short     nHeightInc;
  float              fFrameRateValue;
  float              fFrameRateMin;
  float              fFrameRateMax;
  MvGvspPixelType    enPixelType;
  unsigned int       nSupportedPixelFmtNum;
  MvGvspPixelType    enPixelList[64];
  unsigned int       nReserved[8];
}MV_IMAGE_BASIC_INFO;

Members

nWidthValue
Image width
nWidthMin
Minimum image width
nWidthMax
Maximum image width
nWidthInc
Step-by-step value of image width
nHeightValue
Image height
nHeightMin
Minimum image height
nHeightMax
Maximum image height
nHeightInc
Step-by-step value of image height
fFrameRateValue
Frame rate
fFrameRateMin
Minimum frame rate
fFrameRateMax
Maximum frame rate
enPixelType
Current pixel format, see value definition in "Enumeration Type": MvGvspPixelType
nSupportedPixelFmtNum
Supported pixel format types
enPixelLis
Supported pixel format list, see value definition in "Enumeration Type"：MvGvspPixelType
nReserved
Reserved, set as 0

See Also

MV_CC_GetImageInfo


MV_MATCH_INFO_NET_DETECT

Network flow and packet loss information

struct _MV_MATCH_INFO_NET_DETECT_{
  __int64         nReviceDataSize;
  __int64         nLostPacketCount;
  unsigned int    nLostFrameCount;
  unsigned int    nReserved;
}MV_MATCH_INFO_NET_DETECT;

Members

nReviceDataSize
Received data size[data statistics between StartGrabbing and StopGrabbing]
nLostPacketCount
Packet loss number
nLostFrameCount
Frame loss number
nReserved
Reserved, set as 0

See Also

MV_ALL_MATCH_INFO


MV_NETTRANS_INFO

Network transport information structure

struct _MV_NETTRANS_INFO_{
  __int64    nReviceDataSize;
  int        nThrowFrameCount;
  int        nReserved;
}MV_NETTRANS_INFO;

Members

nReviceDataSize
Received data size
nThrowFrameCount
Frame loss number
nReserved
Reserved

See Also

C interface：MV_GIGE_GetNetTransInfo

C++ interface：GetNetTransInfo


MV_SAVE_IAMGE_TYPE

Picture format type

enum _MV_SAVE_IAMGE_TYPE_{
  MV_Image_Undefined  = 0, //Undefined
  MV_Image_Bmp        = 1, //BMP picture
  MV_Image_Jpeg       = 2, //JPEG picture
  MV_Image_Png        = 3, //PNG picture, not support
  MV_Image_Tif        = 4, //TIF picture, not support
}MV_SAVE_IAMGE_TYPE

See Also

MV_SAVE_IMAGE_PARAM


MV_SAVE_IMAGE_PARAM

Parameter structure for transforming picture format

struct _MV_SAVE_IMAGE_PARAM_{
  unsigned char         *pData;
  unsigned int          nDataLen;
  MvGvspPixelType       enPixelType;
  unsigned short        nWidth;
  unsigned short        nHeight;
  unsigned char         *pImageBuffer;
  unsigned int          nImageLen;
  unsigned int          nBufferSize;
  MV_SAVE_IAMGE_TYPE    enImageType;
}MV_SAVE_IMAGE_PARAM;

Members

pData
[in] Original image data
nDataLen
[in] Original image data length
enPixelType
[in] Pixel format of original image data, see value definition in "Enumeration Type"：MvGvspPixelType
nWidth
[in] Resolution of image width
nHeight
[in] Resolution of image height
pImageBuffer
[out] Output data bufffer area, used for storing transformed picture data
nImageLen
[out] Transformed picture data length
nBufferSize
[in] Output data bufffer area size
enImageType
[in] Output picture format, see value definition in "Enumeration Type"：MV_SAVE_IAMGE_TYPE

See Also

MV_CC_SaveImage


MV_USB3_DEVICE_INFO

USB device information structure

struct _MV_GIGE_DEVICE_INFO_{
  unsigned char     CrtlInEndPoint;
  unsigned char     CrtlOutEndPoint;
  unsigned char     StreamEndPoint;
  unsigned char     EventEndPoint;
  unsigned short    idVendor;
  unsigned short    idProduct;
  unsigned int      nDeviceNumber;
  unsigned char     chDeviceGUID[INFO_MAX_BUFFER_SIZE];
  unsigned char     chVendorName[INFO_MAX_BUFFER_SIZE];
  unsigned char     chModelName[INFO_MAX_BUFFER_SIZE];
  unsigned char     chFamilyName[INFO_MAX_BUFFER_SIZE];
  unsigned char     chDeviceVersion[INFO_MAX_BUFFER_SIZE];
  unsigned char     chManufacturerName[INFO_MAX_BUFFER_SIZE];
  unsigned char     chSerialNumber[INFO_MAX_BUFFER_SIZE];
  unsigned char     chUserDefinedName[INFO_MAX_BUFFER_SIZE];
  unsigned int      nbcdUSB;
  unsigned int      nReserved[3];
}MV_USB3_DEVICE_INFO;

Members

CrtlInEndPoint
Control input port
CrtlOutEndPoint
Control output port
StreamEndPoint
Stream port
EventEndPoint
Event port
idVendor
Supplier ID
idProduct
Product ID
nDeviceNumber
Device No.
chDeviceGUID
Device GUID No.
chVendorName
Supplier name
chModelName
Model name
chFamilyName
Family name
chDeviceVersion
Device version
chManufacturerName
Manufacturer name
chSerialNumber
Serial No.
chUserDefinedName
Custom name
nbcdUSB
Supported USB protocol
nReserved
Reserve bytes

See Also

MV_CC_DEVICE_INFO


MV_XML_AccessMode

Accessing mode enumeration type

enum MV_XML_AccessMode{
  AM_NI,          //!< Not implemented
  AM_NA,          //!< Not available
  AM_WO,          //!< Write Only
  AM_RO,          //!< Read Only
  AM_RW,          //!< Read and Write
  AM_Undefined,   //!< Object is not yet initialized
  AM_CycleDetect  //!< used internally for AccessMode cycle detection
}MV_XML_AccessMode


MV_XML_FEATURE_Base

IBase node information structure

struct _MV_XML_FEATURE_Base_{
  MV_XML_AccessMode    enAccessMode;
}MV_XML_FEATURE_Base;

Members

enAccessMode
Accessing mode, see value definitions in Enumeration Type: MV_XML_AccessMode


MV_XML_FEATURE_Boolean

IBoolean node information structure

struct _MV_XML_FEATURE_Boolean_{
  char                 strName[MV_MAX_XML_NODE_STRLEN_C];
  char                 strDisplayName[MV_MAX_XML_NODE_STRLEN_C];
  char                 strDescription[MV_MAX_XML_DISC_STRLEN_C];
  char                 strToolTip[MV_MAX_XML_DISC_STRLEN_C];
  MV_XML_Visibility    enVisivility;
  MV_XML_AccessMode    enAccessMode;
  int                  bIsLocked;
  bool                 bValue;
}MV_XML_FEATURE_Boolean;

Members

strName
Node name
strDisplayName
Display name
strDescription
Node description, not support, reserved
strToolTip
Prompt
enVisivility
Visible or not, see value definitions in Enumeration Type：MV_XML_Visibility
enAccessMode
Accessing mode, see value definitions in Enumeration Type：MV_XML_AccessMode
bIsLocked
Lock or not (not support, reserved): 0- Unlock, 1- Lock
bValue
Current value

See Also

MV_XML_UpdateNodeFeature MV_XML_GetNodeFeature MV_XML_RegisterUpdateCallBack


MV_XML_FEATURE_Category

ICategory node information structure

struct _MV_XML_FEATURE_Category_{
  char                 strDescription[MV_MAX_XML_DISC_STRLEN_C];
  char                 strDisplayName[MV_MAX_XML_NODE_STRLEN_C];
  char                 strName[MV_MAX_XML_NODE_STRLEN_C];
  char                 strToolTip[MV_MAX_XML_DISC_STRLEN_C];
  MV_XML_Visibility    enVisivility;
}MV_XML_FEATURE_Category;

Members

strDescription
Node description, not support, reserved
strDisplayName
Display name
strName
Node name
strToolTip
Prompt
enVisivility
Visible or not, see value definitions in Enumeration Type：MV_XML_Visibility


MV_XML_FEATURE_Command

ICommand node information structure

struct _MV_XML_FEATURE_Command_{
  char                 strName[MV_MAX_XML_NODE_STRLEN_C];
  char                 strDisplayName[MV_MAX_XML_NODE_STRLEN_C];
  char                 strDescription[MV_MAX_XML_DISC_STRLEN_C];
  char                 strToolTip[MV_MAX_XML_DISC_STRLEN_C];
  MV_XML_Visibility    enVisivility;
  MV_XML_AccessMode    enAccessMode;
  int                  bIsLocked;
}MV_XML_FEATURE_Command;

Members

strName
Node name
strDisplayName
Display name
strDescription
Node Description, not support, reserved
strToolTip
Prompt
enVisivility
Visible or not, see value definitions in Enumeration Type：MV_XML_Visibility
enAccessMode
Accessing mode, see value definitions in Enumeration Type：MV_XML_AccessMode
bIsLocked
Lock or not (not support, reserved): 0- Unlock, 1- Lock

See Also

MV_XML_UpdateNodeFeature MV_XML_GetNodeFeature


MV_XML_FEATURE_EnumEntry

IEnumEntry node information structure

struct _MV_XML_FEATURE_EnumEntry_{
  char                   strName[MV_MAX_XML_NODE_STRLEN_C];
  char                   strDisplayName[MV_MAX_XML_NODE_STRLEN_C];
  char                   strDescription[MV_MAX_XML_DISC_STRLEN_C];
  char                   strToolTip[MV_MAX_XML_DISC_STRLEN_C];
  int                    bIsImplemented;
  int                    nParentsNum;
  MV_XML_NODE_FEATURE    stParentsList[MV_MAX_XML_PARENTS_NUM];
  MV_XML_Visibility      enVisivility;
  __int64                nValue;
  MV_XML_AccessMode      enAccessMode;
  int                    bIsLocked;
  int                    nReserved[8];
}MV_XML_FEATURE_EnumEntry;

Members

strName
Node name
strDisplayName
Display name
strDescription
Node description, not support, reserved
strToolTip
Prompt
bIsImplemented
Take effect or not: 0- No, 1- Yes
nParentsNum
Parent node quantity
stParentsList
Parent node list
enVisivility
Visible or not, see value definitions in Enumeration Type：MV_XML_Visibility
nValue
Current value
enAccessMode
Accessing mode, see value definitions in Enumeration Type：MV_XML_AccessMode
bIsLocked
Lock or not (not support, reserved): 0- Unlock, 1- Lock
nReserved
Reserved, set as 0

See Also

MV_XML_GetNodeFeature


MV_XML_FEATURE_Enumeration

IEnumeration node information structure

struct _MV_XML_FEATURE_Enumeration_{
  MV_XML_Visibility    enVisivility;
  char                 strDescription[MV_MAX_XML_DISC_STRLEN_C];
  char                 strDisplayName[MV_MAX_XML_NODE_STRLEN_C];
  char                 strName[MV_MAX_XML_NODE_STRLEN_C];
  char                 strToolTip[MV_MAX_XML_DISC_STRLEN_C];
  int                  nSymbolicNum;
  char                 strCurrentSymbolic[MV_MAX_XML_SYMBOLIC_STRLEN_C];
  char                 strSymbolic[MV_MAX_XML_SYMBOLIC_NUM][MV_MAX_XML_SYMBOLIC_STRLEN_C];
  MV_XML_AccessMode    enAccessMode;
  int                  bIsLocked;
  __int64              nValue;
}MV_XML_FEATURE_Enumeration;

Members

enVisivility
Visible or not, see value definitions in Enumeration Type：MV_XML_Visibility
strDescription
Node description, not support, reserved
strDisplayName
Display name
strName
Node name
strToolTip
Prompt
nSymbolicNum
Symbol quantity
strCurrentSymbolic
Current symbol index, XML can only update Enumeration nodes via strCurrentSymbilic, see detailed values in XML Node Parameter Type Table
strSymbolic
Symbol information
enAccessMode
Accessing mode, see value definitions in Enumeration Type：MV_XML_AccessMode
bIsLocked
Lock or not (not support, reserved): 0- Unlock, 1- Lock
nValue
Current value

See Also

MV_XML_UpdateNodeFeature MV_XML_GetNodeFeature


MV_XML_FEATURE_Float

IFloat node information structure

struct _MV_XML_FEATURE_Float_{
  char                 strName[MV_MAX_XML_NODE_STRLEN_C];
  char                 strDisplayName[MV_MAX_XML_NODE_STRLEN_C];
  char                 strDescription[MV_MAX_XML_DISC_STRLEN_C];
  char                 strToolTip[MV_MAX_XML_DISC_STRLEN_C];
  MV_XML_Visibility    enVisivility;
  MV_XML_AccessMode    enAccessMode;
  int                  bIsLocked;
  double               dfValue;
  double               dfMinValue;
  double               dfMaxValue;
  double               dfIncrement;
}MV_XML_FEATURE_Float;

Members

strName
Node name
strDisplayName
Display name
strDescription
Node description, not support, reserved
strToolTip
Prompt
enVisivility
Visible or not, see value definitions in Enumeration Type：MV_XML_Visibility
enAccessMode
Accessing mode, see value definitions in Enumeration Type：MV_XML_AccessMode
bIsLocked
Lock or not (not support, reserved): 0- Unlock, 1- Lock
dfValue
Current value
dfMinValue
Minimum value
dfMaxValue
Maximum value
dfIncrement
Increment

See Also

MV_XML_UpdateNodeFeature MV_XML_GetNodeFeature


MV_XML_FEATURE_Integer

IInteger node information structure

struct _MV_XML_FEATURE_Integer_{
  char                 strName[MV_MAX_XML_NODE_STRLEN_C];
  char                 strDisplayName[MV_MAX_XML_NODE_STRLEN_C];
  char                 strDescription[MV_MAX_XML_DISC_STRLEN_C];
  char                 strToolTip[MV_MAX_XML_DISC_STRLEN_C];
  MV_XML_Visibility    enVisivility;
  MV_XML_AccessMode    enAccessMode;
  int                  bIsLocked;
  __int64              nValue;
  __int64              nMinValue;
  __int64              nMaxValue;
  __int64              nIncrement;
}MV_XML_FEATURE_Integer;

Members

strName
Node name
strDisplayName
Display name
strDescription
Node description, not support, reserved
strToolTip
Prompt
enVisivility
Visible or not, see value definitions in Enumeration Type：MV_XML_Visibility
enAccessMode
Accessing mode, see value definitions in Enumeration Type：MV_XML_AccessMode
bIsLocked
Lock or not (not support, reserved): 0- Unlock, 1- Lock
nValue
Current value
nMinValue
Minimum value
nMaxValue
Maximum value
nIncrement
Increment

See Also

MV_XML_UpdateNodeFeature MV_XML_GetNodeFeature MV_XML_RegisterUpdateCallBack


MV_XML_FEATURE_Port

IPort node information structure

struct _MV_XML_FEATURE_Port_{
  MV_XML_Visibility    enVisivility;
  char                 strDescription[MV_MAX_XML_DISC_STRLEN_C];
  char                 strDisplayName[MV_MAX_XML_NODE_STRLEN_C];
  char                 strName[MV_MAX_XML_NODE_STRLEN_C];
  char                 strToolTip[MV_MAX_XML_DISC_STRLEN_C];
  MV_XML_AccessMode    enAccessMode;
  int                  bIsLocked;
}MV_XML_FEATURE_Port;

Members

enVisivility
Visible or not, see value definitions in Enumeration Type：MV_XML_Visibility
strDescription
Node description, not support, reserved
strDisplayName
Display name
strName
Node name
strToolTip
Prompt
enAccessMode
Accessing mode, see value definitions in Enumeration Type：MV_XML_AccessMode
bIsLocked
Lock or not (not support, reserved): 0- Unlock, 1- Lock

See Also

MV_XML_GetNodeFeature


MV_XML_FEATURE_Register

IRegister node information structure

struct _MV_XML_FEATURE_Register_{
  char                 strName[MV_MAX_XML_NODE_STRLEN_C];
  char                 strDisplayName[MV_MAX_XML_NODE_STRLEN_C];
  char                 strDescription[MV_MAX_XML_DISC_STRLEN_C];
  char                 strToolTip[MV_MAX_XML_DISC_STRLEN_C];
  MV_XML_Visibility    enVisivility;
  MV_XML_AccessMode    enAccessMode;
  int                  bIsLocked;
  __int64              nAddrValue;
}MV_XML_FEATURE_Register;

Members

strName
Node name
strDisplayName
Display name
strDescription
Node description, not support, reserved
strToolTip
Prompt
enVisivility
Visible or not, see value definitions in Enumeration Type：MV_XML_Visibility
enAccessMode
Accessing mode, see value definitions in Enumeration Type：MV_XML_AccessMode
bIsLocked
Lock or not (not support, reserved): 0- Unlock, 1- Lock
nAddrValue
Current value

See Also

MV_XML_GetNodeFeature


MV_XML_FEATURE_String

IString node information structure

struct _MV_XML_FEATURE_String_{
  char                 strName[MV_MAX_XML_NODE_STRLEN_C];
  char                 strDisplayName[MV_MAX_XML_NODE_STRLEN_C];
  char                 strDescription[MV_MAX_XML_DISC_STRLEN_C];
  char                 strToolTip[MV_MAX_XML_DISC_STRLEN_C];
  MV_XML_Visibility    enVisivility;
  MV_XML_AccessMode    enAccessMode;
  int                  bIsLocked;
  char                 strValue[MV_MAX_XML_STRVALUE_STRLEN_C];
}MV_XML_FEATURE_String;

Members

strName
Node name
strDisplayName
Disply name
strDescription
Node description, not support, reserved
strToolTip
Prompt
enVisivility
Visible or not, see value definitions in Enumeration Type：MV_XML_Visibility
enAccessMode
Accessing mode, see value definitions in Enumeration Type：MV_XML_AccessMode
bIsLocked
Lock or not (not support, reserved): 0- Unlock, 1- Lock
strValue
Current value

See Also

MV_XML_UpdateNodeFeature MV_XML_GetNodeFeature


MV_XML_FEATURE_Value

IValue node information structure

struct _MV_XML_FEATURE_Value_{
  MV_XML_InterfaceType    enType;
  char                    strDescription[MV_MAX_XML_DISC_STRLEN_C];
  char                    strDisplayName[MV_MAX_XML_NODE_STRLEN_C];
  char                    strName[MV_MAX_XML_NODE_STRLEN_C];
  char                    strToolTip[MV_MAX_XML_DISC_STRLEN_C];
}MV_XML_FEATURE_Value;

Members

enType
Node type, see value definitions in Enumeration Type：MV_XML_InterfaceType
strDescription
Node description, not support, reserved
strDisplayName
Display name
strName
Node name
strToolTip
Prompt


MV_XML_InterfaceType

Node interface type

enum MV_XML_InterfaceType{
  IFT_IValue,       //!> IValue interface
  IFT_IBase,        //!> IBase interface
  IFT_IInteger,     //!> IInteger interface
  IFT_IBoolean,     //!> IBoolean interface
  IFT_ICommand,     //!> ICommand interface
  IFT_IFloat,       //!> IFloat interface
  IFT_IString,      //!> IString interface
  IFT_IRegister,    //!> IRegister interface
  IFT_ICategory,    //!> ICategory interface
  IFT_IEnumeration, //!> IEnumeration interface
  IFT_IEnumEntry,   //!> IEnumEntry interface
  IFT_IPort,        //!> IPort interface
}MV_XML_InterfaceType


MV_XML_NODE_FEATURE

Single node basic property

struct _MV_XML_NODE_FEATURE_{
  MV_XML_InterfaceType    enType;
  MV_XML_Visibility       enVisivility;
  char                    strDescription[MV_MAX_XML_DISC_STRLEN_C];
  char                    strDisplayName[MV_MAX_XML_NODE_STRLEN_C];
  char                    strName[MV_MAX_XML_NODE_STRLEN_C];
  char                    strToolTip[MV_MAX_XML_DISC_STRLEN_C];
}MV_XML_NODE_FEATURE;

Members

enType
Node type, see detailed value definitions in Enumeration Type：MV_XML_InterfaceType
enVisivility
Visible or not, see value definitions in Enumeration Type：MV_XML_Visibility
strDescription
Node description, not support, reserved
strDisplayName
Display name
strName
Node name
strToolTip
Prompt

See Also

MV_XML_NODES_LIST MV_XML_FEATURE_EnumEntry

MV_XML_GetRootNode MV_XML_GetChildren MV_XML_GetNodeFeature


MV_XML_NODES_LIST

Node list

struct _MV_XML_NODES_LIST_{
  unsigned int           nNodeNum;
  MV_XML_NODE_FEATURE    stNodes[MV_MAX_XML_NODE_NUM_C];
}MV_XML_NODES_LIST;

Members

nNodeNum
Node quantity
stNodes
Single node information

See Also

MV_XML_GetChildren MV_XML_RegisterUpdateCallBack


MV_XML_Visibility

Machine Vision Camera SDK Programming Manual

MV_XML_InterfaceType

Visible mode enumeration

enum MV_XML_Visibility{
  V_Beginner      = 0,  //!< Always visible
  V_Expert        = 1,  //!< Visible for experts or Gurus
  V_Guru          = 2,  //!< Visible for Gurus
  V_Invisible     = 3,  //!< Not Visible
  V_Undefined     = 99  //!< Object is not yet initialized
}MV_XML_Visibility

See Also

MV_XML_NODE_FEATURE


MVCC_ENUMVALUE

Enumeration type parameter value

struct _MVCC_ENUMVALUE_T{
  unsigned int    nCurValue;
  unsigned int    nSupportedNum;
  unsigned int    nSupportValue[MV_MAX_XML_SYMBOLIC_NUM];
  unsigned int    nReserved[4];
}MVCC_ENUMVALUE;

Members

nCurValue
Current value
nSupportedNum
Supported valid data quantity
nSupportValue
Supported enumeration types, each array means a kind of type, up to nSupportValue types can be supported
nReserved
Reserved, set as 0

See Also

MV_CC_GetPixelFormat MV_CC_GetAcquisitionMode MV_CC_GetGainMode

MV_CC_GetExposureAutoMode MV_CC_GetTriggerMode MV_CC_GetBalanceWhiteAuto


MVCC_FLOATVALUE

float type parameter value

struct _MVCC_FLOATVALUE_T{
  float           fCurValue;
  float           fMax;
  float           fMin;
  unsigned int    nReserved[4];
}MVCC_FLOATVALUE;

Members

fCurValue
Current value
fMax
Maximum value
fMin
Minimum value
nReserved
Reserved, set as 0

See Also

MV_CC_GetFrameRate MV_CC_GetGain MV_CC_GetExposureTime MV_CC_GetGamma


MVCC_INTVALUE

int type parameter value

struct _MVCC_INTVALUE_T{
  unsigned int    nCurValue;
  unsigned int    nMax;
  unsigned int    nMin;
  unsigned int    nInc;
  unsigned int    nReserved[4];
}MVCC_INTVALUE;

Members

nCurValue
Current value
nMax
Maximum value
nMin
Minimum value
nInc
Increment
nReserved
Reserved, set as 0

See Also

MV_CC_GetWidth MV_CC_GetHeight MV_CC_GetSharpness MV_CC_GetBrightness

MV_CC_GetAOIoffsetX MV_CC_GetAOIoffsetY MV_CC_GetAutoExposureTimeLower MV_CC_GetAutoExposureTimeUpper

MV_CC_GetHue MV_CC_GetSaturation MV_CC_GetBalanceRatioRed MV_CC_GetBalanceRatioGreen MV_CC_GetBalanceRatioBlue


MVCC_STRINGVALUE

string type parameter value

struct _MVCC_STRINGVALUE_T{
  char            chCurValue[256];
  unsigned int    nReserved[4];
}MVCC_STRINGVALUE;

Members

chCurValue
Current value
nReserved
Reserved, set as 0

See Also

MV_CC_GetDeviceUserID


MvGvspPixelType

GigE protocol pixel types enumeration

enum MvGvspPixelType{
  PixelType_Gvsp_Undefined                = -1,

  // Mono buffer format defines
  PixelType_Gvsp_Mono1p                   =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(1) | 0x0037),
  PixelType_Gvsp_Mono2p                   =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(2) | 0x0038),
  PixelType_Gvsp_Mono4p                   =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(4) | 0x0039),
  PixelType_Gvsp_Mono8                    =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0001),
  PixelType_Gvsp_Mono8_Signed             =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8)  | 0x0002),
  PixelType_Gvsp_Mono10                   =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0003),
  PixelType_Gvsp_Mono10_Packed            =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0004),
  PixelType_Gvsp_Mono12                   =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0005),
  PixelType_Gvsp_Mono12_Packed            =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0006),
  PixelType_Gvsp_Mono14                   =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0025),
  PixelType_Gvsp_Mono16                   =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0007),

  // Bayer buffer format defines
  PixelType_Gvsp_BayerGR8                 =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0008),
  PixelType_Gvsp_BayerRG8                 =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x0009),
  PixelType_Gvsp_BayerGB8                 =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x000A),
  PixelType_Gvsp_BayerBG8                 =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(8) | 0x000B),
  PixelType_Gvsp_BayerGR10                =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000C),
  PixelType_Gvsp_BayerRG10                =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000D),
  PixelType_Gvsp_BayerGB10                =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000E),
  PixelType_Gvsp_BayerBG10                =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x000F),
  PixelType_Gvsp_BayerGR12                =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0010),
  PixelType_Gvsp_BayerRG12                =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0011),
  PixelType_Gvsp_BayerGB12                =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0012),
  PixelType_Gvsp_BayerBG12                =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0013),
  PixelType_Gvsp_BayerGR10_Packed         =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0026),
  PixelType_Gvsp_BayerRG10_Packed         =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0027),
  PixelType_Gvsp_BayerGB10_Packed         =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0028),
  PixelType_Gvsp_BayerBG10_Packed         =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x0029),
  PixelType_Gvsp_BayerGR12_Packed         =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002A),
  PixelType_Gvsp_BayerRG12_Packed         =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002B),
  PixelType_Gvsp_BayerGB12_Packed         =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002C),
  PixelType_Gvsp_BayerBG12_Packed         =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(12) | 0x002D),
  PixelType_Gvsp_BayerGR16                =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x002E),
  PixelType_Gvsp_BayerRG16                =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x002F),
  PixelType_Gvsp_BayerGB16                =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0030),
  PixelType_Gvsp_BayerBG16                =   (MV_GVSP_PIX_MONO | MV_PIXEL_BIT_COUNT(16) | 0x0031),

  // RGB Packed buffer format defines
  PixelType_Gvsp_RGB8_Packed              =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0014),
  PixelType_Gvsp_BGR8_Packed              =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0015),
  PixelType_Gvsp_RGBA8_Packed             =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x0016),
  PixelType_Gvsp_BGRA8_Packed             =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x0017),
  PixelType_Gvsp_RGB10_Packed             =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0018),
  PixelType_Gvsp_BGR10_Packed             =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0019),
  PixelType_Gvsp_RGB12_Packed             =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x001A),
  PixelType_Gvsp_BGR12_Packed             =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x001B),
  PixelType_Gvsp_RGB16_Packed             =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0033),
  PixelType_Gvsp_RGB10V1_Packed           =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x001C),
  PixelType_Gvsp_RGB10V2_Packed           =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(32) | 0x001D),
  PixelType_Gvsp_RGB12V1_Packed           =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(36) | 0X0034),
  PixelType_Gvsp_RGB565_Packed            =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0035),
  PixelType_Gvsp_BGR565_Packed            =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0X0036),

  // YUV Packed buffer format defines
  PixelType_Gvsp_YUV411_Packed            =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(12) | 0x001E),
  PixelType_Gvsp_YUV422_Packed            =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x001F),
  PixelType_Gvsp_YUV422_YUYV_Packed       =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0032),
  PixelType_Gvsp_YUV444_Packed            =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0020),
  PixelType_Gvsp_YCBCR8_CBYCR             =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x003A),
  PixelType_Gvsp_YCBCR422_8               =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x003B),
  PixelType_Gvsp_YCBCR422_8_CBYCRY        =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0043),
  PixelType_Gvsp_YCBCR411_8_CBYYCRYY      =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(12) | 0x003C),
  PixelType_Gvsp_YCBCR601_8_CBYCR         =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x003D),
  PixelType_Gvsp_YCBCR601_422_8           =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x003E),
  PixelType_Gvsp_YCBCR601_422_8_CBYCRY    =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0044),
  PixelType_Gvsp_YCBCR601_411_8_CBYYCRYY  =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(12) | 0x003F),
  PixelType_Gvsp_YCBCR709_8_CBYCR         =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0040),
  PixelType_Gvsp_YCBCR709_422_8           =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0041),
  PixelType_Gvsp_YCBCR709_422_8_CBYCRY    =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(16) | 0x0045),
  PixelType_Gvsp_YCBCR709_411_8_CBYYCRYY  =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(12) | 0x0042),

  // RGB Planar buffer format defines
  PixelType_Gvsp_RGB8_Planar              =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(24) | 0x0021),
  PixelType_Gvsp_RGB10_Planar             =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0022),
  PixelType_Gvsp_RGB12_Planar             =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0023),
  PixelType_Gvsp_RGB16_Planar             =   (MV_GVSP_PIX_COLOR | MV_PIXEL_BIT_COUNT(48) | 0x0024),

  // Custom picture format
  PixelType_Gvsp_Jpeg                     =   (MV_GVSP_PIX_CUSTOM | MV_PIXEL_BIT_COUNT(24) | 0x0001)
}MvGvspPixelType

Remarks

The macro definitions of enumeration types are listed below:

Macro Definition | Value
MV_GVSP_PIX_MONO | 0x01000000
MV_GVSP_PIX_COLOR( | 0x02000000
MV_PIXEL_BIT_COUNT(n) | ((n) << 16)

See Also

MV_IMAGE_BASIC_INFO

MV_CC_SetPixelFormat