
Machine Vision Camera SDK (DotNet) Developer Guide
Remarks
• Find specific device and connect according to set device parameters.
• Inputting nAccessMode and nSwitchoverKey are optional when calling this API, and the default
access mode is exclusive. The device does not support the following three modes:
MyCamera.MV_ACCESS_ExclusiveWithSwitch, MyCamera.MV_ACCESS_ControlWithSwitch, and
MyCamera.MV_ACCESS_ControlSwitchEnableWithKey.
• For USB3Vision camera, nAccessMode, nSwitchoverKey are invalid.
Example
C#
using System;
using System.Runtime.InteropServices;
using System.IO;
using MvCamCtrl.NET;
namespace OpenDevice
{
class Program
{
static void Main(string[] args)
{
uint nTLayerType = MyCamera.MV_GIGE_DEVICE | MyCamera.MV_USB_DEVICE;
MyCamera.MV_CC_DEVICE_INFO_LIST stDevList = new MyCamera.MV_CC_DEVICE_INFO_LIST();
int nRet = MyCamera.MV_CC_EnumDevices_NET(nTLayerType, ref stDevList);
if (MyCamera.MV_OK != nRet)
{
Console.WriteLine("Enum device failed:{0:x8}", nRet);
return;
}
Console.WriteLine("The number of devices found: " + Convert.ToString(stDevList.nDeviceNum));
if (0 == stDevList.nDeviceNum)
{
return;
}
MyCamera.MV_CC_DEVICE_INFO stDevInfo;
//Change the device information structure pointer to device information structure
stDevInfo = (MyCamera.MV_CC_DEVICE_INFO)Marshal.PtrToStructure(stDevList.pDeviceInfo[0],
typeof(MyCamera.MV_CC_DEVICE_INFO));
MyCamera device = new MyCamera();
//Create device
nRet = device.MV_CC_CreateDevice_NET(ref stDevInfo);
if (MyCamera.MV_OK != nRet)
{
Console.WriteLine("Create device failed:{0:x8}", nRet);
return;
}
//Open device
nRet = device.MV_CC_OpenDevice_NET();
36






















































































































































































































































































































































































































































































































































































































