using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Runtime.InteropServices;
|
|
namespace MVAPI
|
{
|
|
#region"enum"
|
|
//brief Bayer颜色模式
|
public enum MV_BAYER_MODE
|
{
|
BayerRG, //< RG
|
BayerBG, //< BG
|
BayerGR, //< GR
|
BayerGB, //< GB
|
BayerInvalid
|
}
|
public enum MV_PixelFormatEnums
|
{
|
PixelFormat_Mono8 = 0x01080001, //!<8Bit灰度
|
PixelFormat_BayerBG8 = 0x0108000B, //!<8Bit Bayer图,颜色模式为BGGR
|
PixelFormat_BayerRG8 = 0x01080009, //!<8Bit Bayer图,颜色模式为RGGB
|
PixelFormat_BayerGB8 = 0x0108000A, //!<8Bit Bayer图,颜色模式为GBRG
|
PixelFormat_BayerGR8 = 0x01080008, //!<8Bit Bayer图,颜色模式为GRBG
|
PixelFormat_BayerGRW8 = 0x0108000C, //!<8Bit Bayer图,颜色模式为GRW8
|
PixelFormat_Mono16 = 0x01100007, //!<16Bit灰度
|
PixelFormat_BayerGR16 = 0x0110002E, //!<16Bit Bayer图,颜色模式为GR
|
PixelFormat_BayerRG16 = 0x0110002F, //!<16Bit Bayer图,颜色模式为RG
|
PixelFormat_BayerGB16 = 0x01100030, //!<16Bit Bayer图,颜色模式为GB
|
PixelFormat_BayerBG16 = 0x01100031 //!<16Bit Bayer图,颜色模式为BG
|
};
|
|
public enum TriggerSourceEnums
|
{
|
TriggerSource_Software = 0,
|
TriggerSource_Line1 = 2
|
};
|
|
public enum TriggerModeEnums
|
{
|
TriggerMode_Off,
|
TriggerMode_On
|
};
|
|
public enum TriggerActivationEnums
|
{
|
TriggerActivation_RisingEdge,
|
TriggerActivation_FallingEdge
|
};
|
|
public enum LineSourceEnums
|
{
|
LineSource_Off = 0,
|
LineSource_ExposureActive = 5,
|
LineSource_Timer1Active = 6,
|
LineSource_UserOutput0 = 12
|
};
|
|
public enum UserSetSelectorEnums
|
{
|
UserSetSelector_Default, //!<
|
UserSetSelector_UserSet1, //!<
|
UserSetSelector_UserSet2 //!<
|
};
|
|
public enum SensorTapsEnums
|
{
|
SensorTaps_One, //!<
|
SensorTaps_Two, //!<
|
SensorTaps_Three, //!<
|
SensorTaps_Four, //!<
|
};
|
|
public enum ImageFlipType
|
{
|
FlipHorizontal = 0, //!< Flip Horizontally (Mirror)
|
FlipVertical = 1, //!< Flip Vertically
|
FlipBoth = 2 //!< Flip Vertically
|
};
|
|
enum ImageRotateType
|
{
|
Rotate90DegCw = 0, //!< 顺时针旋转90度
|
Rotate90DegCcw = 1 //!< 逆时针旋转90度
|
};
|
/// \brief Error return code enumeration. This is returned by all \c Jai_Factory.dll functions
|
public enum MVSTATUS_CODES
|
{
|
MVST_SUCCESS = 0, ///< OK
|
MVST_ERROR = -1001, ///< Generic errorcode
|
MVST_ERR_NOT_INITIALIZED = -1002,
|
MVST_ERR_NOT_IMPLEMENTED = -1003,
|
MVST_ERR_RESOURCE_IN_USE = -1004,
|
MVST_ACCESS_DENIED = -1005, ///< Access denied
|
MVST_INVALID_HANDLE = -1006, ///< Invalid handle
|
MVST_INVALID_ID = -1007, ///< Invalid ID
|
MVST_NO_DATA = -1008, ///< No data
|
MVST_INVALID_PARAMETER = -1009, ///< Invalid parameter
|
MVST_FILE_IO = -1010, ///< File IO error
|
MVST_TIMEOUT = -1011, ///< Timeout
|
MVST_ERR_ABORT = -1012, /* GenTL v1.1 */
|
MVST_INVALID_BUFFER_SIZE = -1013, ///< Invalid buffer size
|
MVST_ERR_NOT_AVAILABLE = -1014, /* GenTL v1.2 */
|
MVST_INVALID_ADDRESS = -1015, /* GenTL v1.3 */
|
};
|
|
public enum MVCameraRunEnums
|
{
|
MVCameraRun_ON,
|
MVCameraRun_OFF
|
};
|
|
public enum MVShowWindowEnums
|
{
|
SW_SHOW = 5,
|
SW_HIDE = 0
|
};
|
|
public enum AutoFunctionProfileEnums
|
{
|
AutoFunctionProfile_GainMinimum=0, //!<Keep gain at minimum
|
AutoFunctionProfile_ExposureMinimum=1 //!<Exposure Time at minimum
|
};
|
|
public enum ExposureAutoEnums
|
{
|
ExposureAuto_Off=0, //!<Disables the Exposure Auto function.
|
ExposureAuto_Once=1, //!<Sets operation mode to 'once'.
|
ExposureAuto_Continuous=2 //!<Sets operation mode to 'continuous'.
|
};
|
|
public enum GainAutoEnums
|
{
|
GainAuto_Off=0, //!<Disables the Gain Auto function.
|
GainAuto_Once=1, //!<Sets operation mode to 'once'.
|
GainAuto_Continuous=2 //!<Sets operation mode to 'continuous'.
|
};
|
|
public enum BalanceWhiteAutoEnums
|
{
|
BalanceWhiteAuto_Off=0, //!<Disables the Balance White Auto function.
|
BalanceWhiteAuto_Once=1, //!<Sets operation mode to 'once'.
|
BalanceWhiteAuto_Continuous=2 //!<Sets operation mode to 'continuous'.
|
};
|
|
public enum TestImageEnums
|
{
|
TestImageOff = 0, //!< 测试图关闭,正常传图
|
TestBlackImage = 1,
|
TestWhiteImage = 2,
|
TestGreyHorizontalRampImage = 3,
|
TestGreyVerticalRampImage = 4,
|
TestHorzontalLineMovingImage = 7,
|
TestColorBarImage = 9,
|
TestFrameCounterImage = 10,
|
TestSensorSolidImage = 11, //!< 来自传感器的纯色或彩条图像
|
TestSensorFadeImage = 12 //!< 来自传感器的渐变图像
|
};
|
|
#endregion
|
|
#region"struct"
|
|
[StructLayout(LayoutKind.Explicit)]
|
public struct IMAGE_INFO
|
{
|
[FieldOffset(0)]
|
public UInt64 nTimeStamp; ///< 时间戳,采集到图像的时刻,精度为0.01us ;
|
[FieldOffset(8)]
|
public ushort nBlockId; ///< 帧号,从开始采集开始计数
|
[FieldOffset(16)]
|
public IntPtr pImageBuffer; ///< 图像指针,即指向(0,0)像素所在内存位置的指针,通过该指针可以访问整个图像;
|
[FieldOffset(24)]
|
public ulong nImageSizeAcq; ///< 采集到的图像大小[字节];
|
[FieldOffset(28)]
|
public byte nMissingPackets;///< 传输过程中丢掉的包数量
|
[FieldOffset(32)]
|
public UInt64 nPixelType; ///< Pixel Format Type
|
[FieldOffset(40)]
|
public UInt32 nSizeX; ///< Image width
|
[FieldOffset(44)]
|
public UInt32 nSizeY; ///< Image height
|
[FieldOffset(48)]
|
public UInt32 nOffsetX; ///< Image offset x
|
[FieldOffset(52)]
|
public UInt32 nOffsetY; ///< Image offset y
|
}
|
|
[StructLayout(LayoutKind.Sequential)]
|
public struct MVCamInfo
|
{
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
public byte[] mIpAddr;
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
|
public byte[] mEthernetAddr;
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
|
public string mMfgName;
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
|
public string mModelName;
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
|
public string mSerialNumber;
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
|
public string mUserDefinedName;
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
public byte[] m_IfIp;
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
|
public byte[] m_IfMAC;
|
}
|
|
[StructLayout(LayoutKind.Sequential)]
|
public struct MVStreamStatistic
|
{
|
public ulong m_nTotalBuf;
|
public ulong m_nFailedBuf;
|
public ulong m_nTotalPacket;
|
public ulong m_nFailedPacket;
|
public ulong m_nResendPacketReq;
|
public ulong m_nResendPacket;
|
}
|
|
[StructLayout(LayoutKind.Sequential)]
|
public struct RGBQUAD
|
{
|
public Byte R;
|
public Byte G;
|
public Byte B;
|
public Byte res;
|
};
|
#endregion
|
|
//回调函数声明
|
// [System.Runtime.InteropServices.UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
internal delegate int MV_SNAPPROC(ref IMAGE_INFO pInfo, IntPtr UserVal);
|
|
class MVGigE
|
{
|
|
public Int64 INT64_MAX = 0x7fffffffffffffff; /*maximum signed __int64 value */
|
public UInt64 INT64_MIN = 0x8000000000000000; /*minimum signed __int64 value */
|
public UInt64 UINT64_MAX = 0xffffffffffffffff; /*maximum unsigned __int64 value */
|
|
public Int32 INT32_MAX = 0x7fffffff; /*maximum signed __int32 value */
|
public UInt32 INT32_MIN = 0x80000000; /*minimum signed __int32 value */
|
public UInt32 UInt32_MAX = 0xffffffff; /*maximum unsigned __int32 value */
|
|
public UInt16 UINT16_MAX = 0xffff; /*maximum unsigned __int32 value */
|
|
public byte INT8_MAX = 0x7f; /*maximum signed __int8 value */
|
public byte INT8_MIN = 0x80; /*minimum signed __int8 value */
|
public byte UINT8_MAX = 0xff; /*maximum unsigned __int8 value */
|
|
|
#region"function"
|
/*!
|
* \brief 初始化函数库。在调用函数所有函数之前调用。
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVInitLib();
|
|
/*!
|
* \brief 退出函数库。在程序退出前调用,以释放资源。
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVTerminateLib();
|
|
|
|
/*!
|
* \brief 查找连接到计算机上的相机
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVUpdateCameraList();
|
|
|
/*!
|
* \brief 获取连接到计算机上的相机的数量
|
* \param [out] pNumCams 相机数量
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetNumOfCameras(out int pNumCams);
|
|
|
/*!
|
* \brief 得到第idx个相机的信息。
|
* \param [in] idx idx从0开始,按照相机的IP地址排序,地址小的排在前面。
|
* \param [out] pCamInfo 相机的信息 (IP,MAC,SN,型号...)
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetCameraInfo(byte idx, out MVCamInfo pCamInfo);
|
|
|
/*!
|
* \brief 打开第idx个相机
|
* \param [in] idx idx从0开始,按照相机的IP地址排序,地址小的排在前面。
|
* \param [out] hCam 如果成功,返回的相机句柄
|
* \retval MVST_INVALID_PARAMETER : idx取值不对
|
* MVST_ACCESS_DENIED : 相机无法访问,可能正被别的软件控制
|
* MVST_ERROR : 其他错误
|
* MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVOpenCamByIndex(byte idx, out IntPtr hCam);
|
|
/*!
|
* \brief 打开指定UserDefinedName的相机
|
* \param [in] name UserDefinedName。
|
* \param [out] hCam 如果成功,返回的相机句柄
|
* \retval
|
* MVST_ACCESS_DENIED : 相机无法访问,可能正被别的软件控制
|
* MVST_ERROR : 其他错误
|
* MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVOpenCamByUserDefinedName(string name, out IntPtr hCam);
|
|
/*!
|
* \brief 打开指定IP的相机
|
* \param [in] ip 相机的IP地址。
|
* \param [out] hCam 如果成功,返回的相机句柄。如果失败,为NULL。
|
* \retval
|
* MVST_ACCESS_DENIED : 相机无法访问,可能正被别的软件控制
|
* MVST_ERROR : 其他错误
|
* MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVOpenCamByIP(string ip, out IntPtr hCam);
|
|
/*!
|
* \brief 关闭相机。断开和相机的连接。
|
* \param [in] hCam 相机的句柄
|
* \retval
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVCloseCam(IntPtr hCam);
|
|
/*!
|
* \brief 读取图像宽度
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] int * pWidth 图像宽度[像素]
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetWidth(IntPtr hCam, out int pWidth);
|
|
|
/*!
|
* \brief 读取图像高度
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] int * pHeight 图像高度[像素]
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetHeight(IntPtr hCam, out int pHeight);
|
|
|
/*!
|
* \brief 读取图像的像素格式
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] MV_PixelFormatEnums * pPixelFormat
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetPixelFormat(IntPtr hCam, out MV_PixelFormatEnums pPixelFormat);
|
|
|
/*!
|
* \brief 读取传感器的通道数
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] SensorTapsEnums* pSensorTaps
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetSensorTaps(IntPtr hCam, out SensorTapsEnums pSensorTaps);
|
|
/*!
|
* \brief 读取当前增益值
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] double * pGain
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetGain(IntPtr hCam, out double pGain);
|
|
/*!
|
* \brief 读取增益可以设置的范围
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] double * pGainMin 最小值
|
* \param [out] double * pGainMax 最大值
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetGainRange(IntPtr hCam, out double pGainMin, out double pGainMax);
|
|
/*!
|
* \brief 设置增益
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [in] double fGain 增益
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetGain(IntPtr hCam, double fGain);
|
|
/*!
|
* \brief 当相机传感器为多通道时,设置某个通道的增益
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [in] double fGain 增益
|
* \param [in] int nTap 通道。双通道[0,1],四通道[0,1,2,3]
|
* \retval MVC_ST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetGainTaps(IntPtr hCam, double fGain, int nTap);
|
|
/*!
|
* \brief 当相机传感器为多通道时,读取某个通道的增益
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] out double pGain
|
* \param [in] int nTap 通道。双通道[0,1],四通道[0,1,2,3]
|
* \retval MVC_ST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetGainTaps(int hCam, out double pGain, int nTap);
|
|
/*!
|
* \brief 当相机传感器为多通道时,读取某个通道的增益可设置的范围
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] double * pGainMin 增益最小值
|
* \param [out] double * pGainMax 增益最大值
|
* \param [in] int nTap 通道。双通道[0,1],四通道[0,1,2,3]
|
* \retval MVC_ST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetGainRangeTaps(IntPtr hCam, out double pGainMin, out double pGainMax, int nTap);
|
|
/*!
|
* \brief 读取当前白平衡系数
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] double * pRed 红色平衡系数
|
* \param [out] double * pGreen 绿色平衡系数
|
* \param [out] double * pBlue 蓝色平衡系数
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetWhiteBalance(IntPtr hCam, out double pRed, out double pGreen, out double pBlue);
|
|
/*!
|
* \brief 读取白平衡设置的范围
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] double * pMin 系数最小值
|
* \param [out] double * pMax 系数最大值
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetWhiteBalanceRange(IntPtr hCam, out double pMin, out double pMax);
|
|
/*!
|
* \brief 设置白平衡系数
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [in] double fRed 红色平衡系数
|
* \param [in] double fGreen 绿色平衡系数
|
* \param [in] double fBlue 蓝色平衡系数
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetWhiteBalance(IntPtr hCam, double fRed, double fGreen, double fBlue);
|
|
/*!
|
* \brief 读取是否通道自动平衡
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] out int pBalance 是否自动平衡
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetGainBalance(IntPtr hCam, out int pBalance);
|
|
/*!
|
* \brief 设置是否自动通道平衡
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [in] int nBalance 是否自动通道平衡
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetGainBalance(IntPtr hCam, int nBalance);
|
|
/*!
|
* \brief 读取当前曝光时间
|
* \param [in] hCam
|
* \param [in] pExposuretime 单位us
|
* \retval
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetExposureTime(IntPtr hCam, out double pExposuretime);
|
|
/*!
|
* \brief 读取曝光时间的设置范围
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] double * pExpMin 最短曝光时间 单位为us
|
* \param [out] double * pExpMax 最长曝光时间 单位为us
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetExposureTimeRange(IntPtr hCam, out double pExpMin, out double pExpMax);
|
|
/*!
|
* \brief 设置曝光时间
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [in] double nExp_us 曝光时间 单位为us
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetExposureTime(IntPtr hCam, double nExp_us);
|
|
/*!
|
* \brief 读取帧率可设置的范围
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] out double pFpsMin 最低帧率
|
* \param [out] out double pFpsMax 最高帧率
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetFrameRateRange(IntPtr hCam, out double pFpsMin, out double pFpsMax);
|
|
/*!
|
* \brief 读取当前帧率
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] double * fFPS 帧率 帧/秒
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetFrameRate(IntPtr hCam, out double fFPS);
|
|
/*!
|
* \brief 设置帧率
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [in] double fps 帧率 帧/秒
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetFrameRate(IntPtr hCam, double fps);
|
|
/*!
|
* \brief 开始采集图像
|
* \param [in] hCam 相机句柄
|
* \param [in] StreamCB 回调函数指针
|
* \param [in] nUserVal 用户数据,传递到回调函数的形参
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVStartGrab(IntPtr hCam, MV_SNAPPROC callbackFunc, IntPtr nUserVal);
|
|
/*!
|
* \brief 采集一帧图像。
|
* \param [in] hCam 相机句柄
|
* \param [out] hImage 图像句柄。保存采集到的图像。
|
* \param [in] nWaitMs 等待多长时间,单位ms
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSingleGrab(IntPtr hCam, IntPtr hImage, UInt64 nWaitMs);
|
|
/*!
|
* \brief 停止采集图像
|
* \param [in] hCam 相机句柄
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVStopGrab(IntPtr hCam);
|
|
|
/*!
|
* \brief 读取触发模式
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] TriggerModeEnums * pMode 触发模式 TriggerMode_Off,TriggerMode_On
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetTriggerMode(IntPtr hCam, out TriggerModeEnums pMode);
|
|
/*!
|
* \brief 设置触发模式
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [in] mode 触发模式
|
TriggerMode_Off:相机工作在连续采集模式,
|
TriggerMode_On:相机工作在触发模式,需要有外触发信号或软触发指令才拍摄
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetTriggerMode(IntPtr hCam, TriggerModeEnums mode);
|
|
/*!
|
* \brief 读取触发源
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] TriggerSourceEnums * pSource 触发源,软触发或外触发
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetTriggerSource(IntPtr hCam, out TriggerSourceEnums pSource);
|
|
/*!
|
* \brief 设置触发源
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [in] TriggerSourceEnums source 触发源
|
TriggerSource_Software:通过\c MVTriggerSoftware()函数触发。
|
TriggerSource_Line1:通过连接的触发线触发。
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetTriggerSource(IntPtr hCam, TriggerSourceEnums source);
|
|
/*!
|
* \brief 读取触发极性
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] TriggerActivationEnums * pAct
|
TriggerActivation_RisingEdge: 上升沿触发
|
TriggerActivation_FallingEdge: 下降沿触发
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetTriggerActivation(IntPtr hCam, out TriggerActivationEnums pAct);
|
/*!
|
* \brief 当使用触发线触发时,设置是上升沿触发还是下降沿触发
|
* \param [in] hCam
|
* \param [in] act 上升沿或下降沿
|
TriggerActivation_RisingEdge: 上升沿触发
|
TriggerActivation_FallingEdge: 下降沿触发
|
* \retval
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetTriggerActivation(IntPtr hCam, TriggerActivationEnums act);
|
|
/*!
|
* \brief 读取触发延时
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] UInt32_t * pDelay_us 触发延时,单位us
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetTriggerDelay(IntPtr hCam, out UInt32 pDelay_us);
|
|
/*!
|
* \brief 读取触发延时范围
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] UInt32_t * pMin 触发延时最小值,单位us
|
* \param [out] UInt32_t * pMax 触发延时最大值,单位us
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetTriggerDelayRange(IntPtr hCam, out UInt32 pMin, out UInt32 pMax);
|
/*!
|
* \brief 设置相机接到触发信号后延迟多少微秒后再开始曝光。
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [in] nDelay_us
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetTriggerDelay(IntPtr hCam, UInt32 nDelay_us);
|
|
/*!
|
* \brief 发出软件触发指令
|
* \param [in] HANDLE hCam 相机句柄
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVTriggerSoftware(IntPtr hCam);
|
|
/*!
|
* \brief 读取闪光同步信号源
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] LineSourceEnums * pSource 闪光同步信号源
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetStrobeSource(IntPtr hCam, out LineSourceEnums pSource);
|
/*!
|
* \brief 闪光同步信号源
|
* \param [in] hCam
|
* \param [in] source
|
LineSource_Off:关闭闪光同步
|
LineSource_ExposureActive:曝光的同时闪光
|
LineSource_Timer1Active:由定时器控制
|
LineSource_UserOutput0:由用户通过指令控制
|
* \retval
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetStrobeSource(IntPtr hCam, LineSourceEnums source);
|
|
/*!
|
* \brief 读取闪光同步是否反转
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] BOOL * pInvert
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetStrobeInvert(IntPtr hCam, out bool pInvert);
|
|
/*!
|
* \brief 闪光同步是否反转,即闪光同步有效时输出高电平还是低电平。
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [in] bInvert
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetStrobeInvert(IntPtr hCam, bool bInvert);
|
|
/*!
|
* \brief 读取用户设置的闪光同步
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] BOOL * pSet
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetUserOutputValue0(IntPtr hCam, out bool pSet);
|
|
/*!
|
* \brief 当闪光同步源选为UserOutput时
|
主机可以通过MVSetUserOutputValue0来控制闪光同步输出高电平或低电平。
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [in] bSet 设置电平
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetUserOutputValue0(IntPtr hCam, bool bSet);
|
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetHeartbeatTimeout(IntPtr hCam, ulong nTimeOut);//unit ms
|
|
/*!
|
* \brief 读取网络数据包大小
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] int *pPacketSize 数据包大小
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetPacketSize(IntPtr hCam, out uint pPacketSize);
|
/*!
|
* \brief 读取网络数据包范围
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] UInt32 * pMin 网络数据包最小值
|
* \param [out] UInt32 * pMax 网络数据包最大值
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetPacketSizeRange(IntPtr hCam, out uint pMin, out uint pMax);
|
|
/*!
|
* \brief 获取最大合适传输包大小
|
* \param [in] hCam 相机句柄
|
* \param [out]pPacketSize 最大合适传输数据包
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetOptimalPacketSize(IntPtr hCam, out uint pPacketSize);
|
|
/*!
|
* \brief 设置网络数据包的大小。
|
* \param [in] hCam
|
* \param [in] nPacketSize 网络数据包大小(单位:字节)。该大小应该小于网卡能够支持的最大巨型帧。
|
* \retval
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetPacketSize(IntPtr hCam, uint nPacketSize);
|
|
/*!
|
* \brief 读取网络数据包间隔
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] UInt32 *pDelay_us 数据包间隔时间,单位us
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetPacketDelay(IntPtr hCam, out uint pDelay_us);
|
/*!
|
* \brief 读取网络数据包范围
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] UInt32 * pMin 数据包间隔时间最小值,单位us
|
* \param [out] UInt32 * pMax 数据包间隔时间最大值,单位us
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetPacketDelayRange(IntPtr hCam, out uint pMin, out uint pMax);
|
|
|
/*!
|
* \brief 设置网络数据包之间的时间间隔。如果网卡或电脑的性能欠佳,无法处理高速到达的数据包,
|
可以增加数据包之间的时间间隔以保证图像传输。但是增加该值将增加图像的时间延迟,并有可能影像到帧率。
|
* \param [in] hCam
|
* \param [in] nDelay_us 时间间隔(单位:微秒)
|
* \retval
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetPacketDelay(IntPtr hCam, uint nDelay_us);
|
|
/*!
|
* \brief 读取定时器延时
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] UInt32_t * pDelay 定时器延时
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetTimerDelay(IntPtr hCam, out UInt32 pDelay);
|
|
/*!
|
* \brief 读取定时器延时的范围
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] UInt32_t * pMin 定时器延时的最小值
|
* \param [out] UInt32_t * pMax 定时器延时的最大值
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetTimerDelayRange(IntPtr hCam, out UInt32 pMin, out UInt32 pMax);
|
|
/*!
|
* \brief 当闪光同步源选为Timer1时,设置Timer1在接到触发信号后延迟多少us开始计时
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [in] UInt32_t nDelay 接到触发信号后延迟多少us开始计时
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetTimerDelay(IntPtr hCam, UInt32 nDelay);
|
|
/*!
|
* \brief 读取定时器计时时长
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] UInt32_t * pDuration 定时器计时时长
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetTimerDuration(IntPtr hCam, out UInt32 pDuration);
|
/*!
|
* \brief 读取定时器计时时长取值范围
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] UInt32_t * pMin 定时器计时时长最小值
|
* \param [out] UInt32_t * pMax 定时器计时时长最大值
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetTimerDurationRange(IntPtr hCam, out UInt32 pMin, out UInt32 pMax);
|
|
/*!
|
* \brief 当闪光同步源选为Timer1时,设置Timer1在开始计时后,计时多长时间。
|
* \param [in] HANDLE hCam
|
* \param [in] UInt32_t nDuration 设置Timer1在开始计时后,计时多长时间(us)。即输出高/低电平的脉冲宽度。
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetTimerDuration(IntPtr hCam, UInt32 nDuration);
|
|
//[DllImport("MVGigE.dll")]
|
// public static extern MVSTATUS_CODES MVTRACE(byte format);
|
/// <summary>
|
/// Bayer格式图像数据到RGB格式图像数据转换 ( 转成RGB24位)
|
/// </summary>
|
/// <param name="hCam">该相机句柄</param>
|
/// <param name="psrc">原始图像数据指针</param>
|
/// <param name="pdst">转换后图像存储内存指针</param>
|
/// <param name="dststep">转换步长</param>
|
/// <param name="width">图像宽度</param>
|
/// <param name="height">图像高度</param>
|
/// <param name="pixelformat">像素格式</param>
|
/// <returns>成功返回Success,否则返回错误信息</returns>
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVBayerToBGR(IntPtr hCam, IntPtr psrc, IntPtr pdst, uint dststep, uint width, uint height, MV_PixelFormatEnums pixelformat);
|
|
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVInfo2Image(IntPtr hCam, ref MVAPI.IMAGE_INFO pInfo, IntPtr pImage);
|
|
/// <summary>
|
/// <summary>
|
/// 图像缩放
|
/// </summary>
|
/// <param name="hCam">该相机句柄</param>
|
/// <param name="pSrc">原始图像指针</param>
|
/// <param name="srcWidth">原始图像宽度</param>
|
/// <param name="srcHeight">原始图像高度</param>
|
/// <param name="pDst">缩放后存放图像内存指针</param>
|
/// <param name="fFactorX">水平方向缩放因子</param>
|
/// <param name="fFactorY">垂直方向缩放因子</param>
|
/// <returns>成功返回Success,否则返回错误信息</returns>
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVZoomImageBGR(IntPtr hCam, IntPtr pSrc, int srcWidth, int srcHeight, out IntPtr pDst, double fFactorX, double fFactorY);
|
|
|
/*!
|
* \brief 获取数据传输的统计信息
|
* \param [in] hCam 相机句柄
|
* \param [out] pStatistic 统计信息
|
* \retval JMVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetStreamStatistic(IntPtr hCam, MVStreamStatistic pStatistic);
|
|
|
|
/*!
|
* \brief 读取并应用某组用户预设的参数
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [in] UserSetSelectorEnums userset
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVLoadUserSet(IntPtr hCam, UserSetSelectorEnums userset);
|
|
/*!
|
* \brief 将当前相机的参数保存到用户设置中
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [in] UserSetSelectorEnums userset
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSaveUserSet(IntPtr hCam, UserSetSelectorEnums userset);
|
|
/*!
|
* \brief 设置相机上电开机时默认读取并应用哪一组用户设置
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [in] UserSetSelectorEnums userset
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetDefaultUserSet(IntPtr hCam, UserSetSelectorEnums userset);
|
|
/*!
|
* \brief 读取相机上电开机时默认读取并应用哪一组用户设置
|
* \param [in] HANDLE hCam 相机句柄
|
* \param [out] UserSetSelectorEnums* pUserset 用户设置
|
* \retval MVGIGE_API MVSTATUS_CODES __stdcall
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetDefaultUserSet(IntPtr hCam, out UserSetSelectorEnums pUserset);
|
|
/*!
|
* \brief 图像翻转
|
* \param [in] hCam 相机句柄
|
* \param [in] pSrcImage 源图像指针
|
* \param [out] pDstImage 结果图像指针。如果为NULL,则翻转的结果还在源图像内。
|
* \param [in] flipType 翻转类型。FlipHorizontal:左右翻转,FlipVertical:上下翻转,FlipBoth:旋转180度
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVImageFlip(IntPtr hCam, IntPtr pSrcImage, IntPtr pDstImage, ImageFlipType flipType);
|
/*!
|
* \brief 图像旋转
|
* \param [in] hCam 相机句柄
|
* \param [in] pSrcImage 源图像指针
|
* \param [out] pDstImage 结果图像指针,不能为NULL。结果图像的宽度和高度应该和源图像的宽度和高度互换。
|
* \param [in] roateType 旋转类型:Rotate90DegCw, Rotate90DegCcw
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVImageRotate(IntPtr hCam, IntPtr pSrcImage, IntPtr pDstImage, ImageRotateType roateType);
|
|
/*!
|
* \brief 获取相机版本信息
|
* \param [in] hCam 相机句柄
|
* \param [out] pData 版本信息
|
* \param [in] size 版本信息缓冲区大小
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetDeviceVersion(IntPtr hCam,StringBuilder pData, int size);
|
|
|
|
/*!
|
* \bief 获取相机固件版本信息
|
* \param [in] hCam 相机句柄
|
* \param [out] pData 固件版本信息
|
* \param [in] size 固件版本信息缓冲区大小
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetDeviceFirmwareVersion(IntPtr hCam, StringBuilder pData, int size);
|
|
|
|
/*!
|
* \brief 读取图像宽度可设置的范围
|
* \param [in] hCam 相机句柄
|
* \param [out] pWidthMin 图像宽度可设置的最小值
|
* \param [out] pWidthMax 图像宽度可设置的最大值
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetWidthRange(IntPtr hCam, out int pWidthMin, out int pWidthMax);
|
|
|
|
/*!
|
* \brief 读取图像宽度调整的步长
|
* \param [in] hCam 相机句柄
|
* \param [out] pWidthInc 图像宽度的调整的步长,即图像的宽度 = 最小宽度 + 步长 x 整数
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetWidthInc(IntPtr hCam, out int pWidthInc);
|
|
|
|
/*!
|
* \brief 设置图像的宽度
|
* \param [in] hCam 相机句柄
|
* \param [in] nWidth 图像宽度,应该在宽度可设置范围之内,并且 = 最小宽度 + 步长 x 整数
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetWidth(IntPtr hCam, int nWidth);
|
|
|
|
/*!
|
* \brief 读取图像高度可设置的范围
|
* \param [in] hCam 相机句柄
|
* \param [out] pHeightMin 图像高度可设置的最小值
|
* \param [out] pHeightMax 图像高度可设置的最大值
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetHeightRange(IntPtr hCam, out int pHeightMin, out int pHeightMax);
|
|
|
|
/*!
|
* \brief 设置图像的高度
|
* \param [in] hCam 相机句柄
|
* \param [in] nHeight 图像高度,应该在高度可设置范围之内
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetHeight(IntPtr hCam, int nHeight);
|
|
|
|
/*!
|
* \brief 读取水平方向偏移量。图像宽度设置到小于最大宽度时,可以调整水平偏移量,设置采集窗口的水平起始位置。
|
* \param [in] hCam
|
* \param [out] pOffsetX 水平偏移量
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetOffsetX(IntPtr hCam, out int pOffsetX);
|
|
|
|
/*!
|
* \brief 读取水平方向偏移量取值范围。
|
* \param [in] hCam
|
* \param [out] pOffsetXMin 水平偏移量最小值
|
* \param [out] pOffsetXMax 水平偏移量最大值
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetOffsetXRange(IntPtr hCam, out int pOffsetXMin, out int pOffsetXMax);
|
|
|
|
/*!
|
* \brief 设置水平方向偏移量。图像宽度设置到小于最大宽度时,可以调整水平偏移量,设置采集窗口的水平起始位置。
|
* \param [in] hCam
|
* \param [in] nOffsetX 水平偏移量。应该在水平偏移量允许的范围之内。
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetOffsetX(IntPtr hCam, int nOffsetX);
|
|
|
|
/*!
|
* \brief 读取垂直方向偏移量。图像宽度设置到小于最大宽度时,可以调整垂直偏移量,设置采集窗口的垂直起始位置。
|
* \param [in] hCam
|
* \param [out] pOffsetY 垂直偏移量
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetOffsetY(IntPtr hCam, out int pOffsetY);
|
|
|
|
/*!
|
* \brief 读取垂直方向偏移量取值范围。
|
* \param [in] hCam
|
* \param [out] pOffsetYMin 垂直偏移量最小值
|
* \param [out] pOffsetYMax 垂直偏移量最大值
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetOffsetYRange(IntPtr hCam, out int pOffsetYMin, out int pOffsetYMax);
|
|
|
|
/*!
|
* \brief 设置垂直方向偏移量。图像宽度设置到小于最大宽度时,可以调整垂直偏移量,设置采集窗口的垂直起始位置。
|
* \param [in] hCam
|
* \param [in] nOffsetY 垂直偏移量。应该在垂直偏移量允许的范围之内。
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetOffsetY(IntPtr hCam, int nOffsetY);
|
|
|
|
/*!
|
* \brief 设置图像的像素格式
|
* \param [in] hCam 相机句柄
|
* \param [out] PixelFormat
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetPixelFormat(IntPtr hCam, MV_PixelFormatEnums PixelFormat);
|
|
|
|
/*!
|
* \brief 如果有特殊需要,指定主机端接收图像的端口。一般应用无需设置。
|
* \param[] hCam 相机句柄
|
* \param[] nPort 主机端端口号
|
* \retval: MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetStreamHostPort(IntPtr hCam, int nPort);
|
|
|
|
/*!
|
* \brief 将Bayer格式的16bit单通道图转换为BGR格式的16Bit三通道图
|
* \param [in] hCam 相机句柄
|
* \param [in] psrc 单通道图像的指针
|
* \param [out] pdst 三通道图像指针
|
* \param [in] dststep 三通道图像一行图像的字节数。
|
* \param [in] width 图像宽度
|
* \param [in] height 图像高度
|
* \param [in] pixelformat 像素格式,由MVGetPixelFormat取得
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVBayerToBGR16(IntPtr hCam, IntPtr psrc, IntPtr pdst, UInt32 dststep, UInt32 width, UInt32 height, MV_PixelFormatEnums pixelformat);
|
|
|
|
/*!
|
* \brief 将Bayer格式的8bit单通道图转换为RGB格式的8Bit三通道图
|
* \param [in] hCam 相机句柄
|
* \param [in] psrc 单通道图像的指针
|
* \param [out] pdst 三通道图像指针
|
* \param [in] dststep 三通道图像一行图像的字节数。通常为图像宽度*3,但是会为了4字节对齐会补几个字节。
|
* \param [in] width 图像宽度
|
* \param [in] height 图像高度
|
* \param [in] pixelformat 像素格式,由MVGetPixelFormat取得
|
* \param [in] bMultiCores 是否使用CPU多核计算
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVBayerToRGB(IntPtr hCam, IntPtr psrc, IntPtr pdst, UInt32 dststep, UInt32 width, UInt32 height, MV_PixelFormatEnums pixelformat, bool bMultiCores);
|
|
|
|
/*!
|
* \brief 将Bayer格式的16bit单通道图转换为RGB格式的16Bit三通道图
|
* \param [in] hCam 相机句柄
|
* \param [in] psrc 单通道图像的指针
|
* \param [out] pdst 三通道图像指针
|
* \param [in] dststep 三通道图像一行图像的字节数。
|
* \param [in] width 图像宽度
|
* \param [in] height 图像高度
|
* \param [in] pixelformat 像素格式,由MVGetPixelFormat取得
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVBayerToRGB16(IntPtr hCam, IntPtr psrc, IntPtr pdst, UInt32 dststep, UInt32 width, UInt32 height, MV_PixelFormatEnums pixelformat);
|
|
|
|
/*!
|
* \brief 将Bayer格式的8bit单通道图转换为BGR格式的8Bit三通道图
|
* \param [in] hCam 相机句柄
|
* \param [in] pInfo 采集Callback函数中传来的图像信息指针
|
* \param [out] pImage 转换结果图像的指针
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVImageBayerToBGR(IntPtr hCam, ref IMAGE_INFO pInfo, ref MVImage pImage);
|
|
|
|
/*!
|
* \brief 将Bayer格式的8bit单通道图转换为BGR格式的8Bit三通道图,同时调整图像的GAMMA,颜色和反差
|
* \param [in] hCam 相机句柄
|
* \param [in] pInfo 采集Callback函数中传来的图像信息指针
|
* \param [out] pImage 转换结果图像的指针
|
* \param [in] fGamma Gamma校正值,1为不校正,<1时,将暗部提升。
|
* \param [in] bColorCorrect 是否进行颜色校正,进行颜色校正后,图像会变得更鲜艳。
|
* \param [in] nContrast 是否调整反差,范围为0-50,当该值大于0时,图像反差会更强。
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVImageBayerToBGREx(IntPtr hCam, ref IMAGE_INFO pInfo, ref MVImage pImage, double fGamma, bool bColorCorrect, int nContrast);
|
|
|
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVImageBayerToBGR(IntPtr hCam, ref IMAGE_INFO pInfo, IntPtr pImage);
|
|
|
|
/*!
|
* \brief 将彩色BGR三通道24bit图像转换为灰度单通道8bit图像
|
* \param [in] hCam 相机句柄
|
* \param [in] psrc 彩色BGR三通道24bit图像指针
|
* \param [out] pdst 灰度单通道8bit图像指针
|
* \param [in] width 图像宽度
|
* \param [in] height 图像高度
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVBGRToGray(IntPtr hCam, IntPtr psrc, IntPtr pdst, UInt32 width, UInt32 height);
|
|
|
|
/*!
|
* \brief 将彩色BGR三通道24bit图像转换为灰度单通道8bit图像
|
* \param [in] hCam 相机句柄
|
* \param [in] pSrcImage 彩色BGR三通道24bit图像指针
|
* \param [out] pDstImage 灰度单通道8bit图像指针。宽度高度必须和源图相同
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVImageBGRToGray(IntPtr hCam, ref MVImage pSrcImage, ref MVImage pDstImage);
|
|
|
|
/*!
|
* \brief 将彩色BGR三通道24bit图像转换为YUV图像
|
* \param [in] hCam 相机句柄
|
* \param [in] pSrcImage 彩色BGR三通道24bit图像指针
|
* \param [out] pDst YUV图像指针 (YUV422)
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVImageBGRToYUV(IntPtr hCam, ref MVImage pSrcImage, IntPtr pDst);
|
|
|
|
/*!
|
* \brief 将灰度单通道8bit图像转换为彩色BGR三通道24bit图像。转换后三个通道的值是相同的。
|
* \param [in] hCam 相机句柄
|
* \param [in] pSrc 灰度单通道8bit图像指针
|
* \param [out] pDst 彩色BGR三通道24bit图像指针
|
* \param [in] width 图像宽度
|
* \param [in] height 图像高度
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGrayToBGR(IntPtr hCam, IntPtr pSrc, IntPtr pDst, int width, int height);
|
|
|
|
/*!
|
* \brief 获取当前自动曝光模式
|
* \param [in] hCam 相机句柄
|
* \param [out] pExposureAuto 当前自动曝光模式
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetExposureAuto(IntPtr hCam, ref ExposureAutoEnums pExposureAuto);
|
|
|
|
/*!
|
* \brief 设置自动曝光模式
|
* \param [in] hCam 相机句柄
|
* \param [in] ExposureAuto 自动曝光模式
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetExposureAuto(IntPtr hCam, ExposureAutoEnums ExposureAuto);
|
|
|
|
/*!
|
* \brief 获取当前自动增益模式
|
* \param [in] hCam 相机句柄
|
* \param [out] pGainAuto 当前自动增益模式的
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetGainAuto(IntPtr hCam, out GainAutoEnums pGainAuto);
|
|
|
|
/*!
|
* \brief 设置当前自动增益模式
|
* \param [in] hCam 相机句柄
|
* \param [in] GainAuto 自动增益模式
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetGainAuto(IntPtr hCam, GainAutoEnums GainAuto);
|
|
|
|
/*!
|
* \brief 获取当前自动白平衡模式
|
* \param [in] hCam 相机句柄
|
* \param [out] pBalanceWhiteAuto 当前自动白平衡模式
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetBalanceWhiteAuto(IntPtr hCam, out BalanceWhiteAutoEnums pBalanceWhiteAuto);
|
|
|
|
/*!
|
* \brief 设置自动白平衡模式
|
* \param [in] hCam 相机句柄
|
* \param [in] BalanceWhiteAuto 自动白平衡模式
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetBalanceWhiteAuto(IntPtr hCam, BalanceWhiteAutoEnums BalanceWhiteAuto);
|
|
|
|
/*!
|
* \brief 获取自动调整增益时,增益调整范围的最小值
|
* \param [in] hCam 相机句柄
|
* \param [out] pAutoGainLowerLimit 增益调整范围的最小值
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetAutoGainLowerLimit(IntPtr hCam, out double pAutoGainLowerLimit);
|
|
|
|
/*!
|
* \brief 设置自动调整增益时,增益调整范围的最小值
|
* \param [in] hCam 相机句柄
|
* \param [in] fAutoGainLowerLimit 增益调整范围的最小值
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetAutoGainLowerLimit(IntPtr hCam, double fAutoGainLowerLimit);
|
|
|
|
/*!
|
* \brief 获取自动调整增益时,增益调整范围的最大值
|
* \param [in] hCam 相机句柄
|
* \param [out] pAutoGainUpperLimit 增益调整范围的最大值
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetAutoGainUpperLimit(IntPtr hCam, out double pAutoGainUpperLimit);
|
|
|
|
/*!
|
* \brief 设置自动调整增益时,增益调整范围的最大值
|
* \param [in] hCam 相机句柄
|
* \param [in] fAutoGainUpperLimit 曝光时间调整范围的最小值
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetAutoGainUpperLimit(IntPtr hCam, double fAutoGainUpperLimit);
|
|
|
|
/*!
|
* \brief 获取自动调整曝光时间时,曝光时间调整范围的最小值
|
* \param [in] hCam 相机句柄
|
* \param [out] pAutoExposureTimeLowerLimit 曝光时间调整范围的最小值
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetAutoExposureTimeLowerLimit(IntPtr hCam, out double pAutoExposureTimeLowerLimit);
|
|
|
|
/*!
|
* \brief 设置自动调整曝光时间时,曝光时间调整范围的最小值
|
* \param [in] hCam 相机句柄
|
* \param [in] fAutoExposureTimeLowerLimit 曝光时间调整范围的最大值
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetAutoExposureTimeLowerLimit(IntPtr hCam, double fAutoExposureTimeLowerLimit);
|
|
|
|
/*!
|
* \brief 获取自动调整曝光时间时,曝光时间调整范围的最大值
|
* \param [in] hCam 相机句柄
|
* \param [out] pAutoExposureTimeUpperLimit 曝光时间调整范围的最大值
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetAutoExposureTimeUpperLimit(IntPtr hCam, out double pAutoExposureTimeUpperLimit);
|
|
|
|
/*!
|
* \brief 设置自动调整曝光时间时,曝光时间调整范围的最大值
|
* \param [in] hCam 相机句柄
|
* \param [in] fAutoExposureTimeUpperLimit
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetAutoExposureTimeUpperLimit(IntPtr hCam, double fAutoExposureTimeUpperLimit);
|
|
|
|
/*!
|
* \brief 获取自动调整亮度(曝光、增益)时,期望调整到的图像亮度
|
* \param [in] hCam 相机句柄
|
* \param [out] pAutoTargetValue 期望调整到的图像亮度
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetAutoTargetValue(IntPtr hCam, out int pAutoTargetValue);
|
|
|
|
/*!
|
* \brief 设置自动调整亮度(曝光、增益)时,期望调整到的图像亮度
|
* \param [in] hCam 相机句柄
|
* \param [in] nAutoTargetValue 期望调整到的图像亮度
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetAutoTargetValue(IntPtr hCam, int nAutoTargetValue);
|
|
|
|
/*!
|
* \brief 当自动增益和自动曝光时间都打开时,获取哪一个值优先调整
|
* \param [in] hCam 相机句柄
|
* \param [out] pAutoFunctionProfile 增益优先或曝光时间优先
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetAutoFunctionProfile(IntPtr hCam, out AutoFunctionProfileEnums pAutoFunctionProfile);
|
|
|
|
/*!
|
* \brief 当自动增益和自动曝光时间都打开时,设置哪一个值优先调整
|
* \param [in] hCam 相机句柄
|
* \param [in] AutoFunctionProfile 增益优先或曝光时间优先
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetAutoFunctionProfile(IntPtr hCam, AutoFunctionProfileEnums AutoFunctionProfile);
|
|
|
|
/*!
|
* \brief 自动增益或自动曝光时,图像亮度与目标亮度差异的容差。
|
* \param [in] hCam 相机句柄
|
* \param [out] pAutoThreshold 图像亮度与目标亮度差异的容差
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetAutoThreshold(IntPtr hCam, out int pAutoThreshold);
|
|
|
|
/*!
|
* \brief 自动增益或自动曝光时,图像亮度与目标亮度差异的容差。
|
* \param [in] hCam 相机句柄
|
* \param [in] nAutoThreshold 图像亮度与目标亮度差异的容差
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetAutoThreshold(IntPtr hCam, int nAutoThreshold);
|
|
|
|
/*!
|
* \brief 获取当前伽马值
|
* \param [in] hCam 相机句柄
|
* \param [out] pGamma 当前伽马值
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetGamma(IntPtr hCam, out double pGamma);
|
|
|
|
/*!
|
* \brief 获取伽马值可设置的范围
|
* \param [in] hCam 相机句柄
|
* \param [out] pGammaMin 伽马最小值
|
* \param [out] pGammaMax 伽马最大值
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetGammaRange(IntPtr hCam, out double pGammaMin, out double pGammaMax);
|
|
|
|
/*!
|
* \brief 设置伽马值
|
* \param [in] hCam 相机句柄
|
* \param [in] fGamma 伽马值
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetGamma(IntPtr hCam, double fGamma);
|
|
|
|
/*!
|
* \brief 设置查找表
|
* \param [in] hCam 相机句柄
|
* \param [in] pLUT 查找表数组,UInt32 pLUT[1024];
|
* \param [in] nCnt 查找表数组单元个数,必须是1024
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetLUT(IntPtr hCam, IntPtr pLUT, int nCnt);
|
|
|
|
/*!
|
* \brief 使用查找表
|
* \param [in] hCam 相机句柄
|
* \param [in] bEnable 是否允许
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetEnableLUT(IntPtr hCam, bool bEnable);
|
|
|
|
/*!
|
* \brief 获取当前是否使用查找表状态
|
* \param [in] hCam
|
* \param [out] bEnable 当前是否使用查找表状态
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetEnableLUT(IntPtr hCam, out bool bEnable);
|
|
|
|
/*!
|
* \brief 开始采集,并将采集到的图像显示到指定窗口
|
* \param [in] hCam 相机句柄
|
* \param [in] IntPtr 窗口句柄
|
* \param [in] IntPtrMsg 消息句柄,如果不为NULL,当新的图像采集完毕,会发送消息(WM_USER+0x0200)到此窗口
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVStartGrabWindow(IntPtr hCam, IntPtr IntPtr, IntPtr IntPtrMsg);
|
|
|
|
/*!
|
* \brief 停止采集到窗口
|
* \param [in] hCam 相机句柄
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVStopGrabWindow(IntPtr hCam);
|
|
|
|
/*!
|
* \brief 当采集到窗口时,暂停或继续采集。
|
* \param [in] hCam 相机句柄
|
* \param [in] bFreeze
|
* TRUE:暂停采集,暂停后可以调用GetSampleGrab函数得到当前图像。
|
* FALSE:继续采集
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVFreezeGrabWindow(IntPtr hCam, bool bFreeze);
|
|
|
|
/*!
|
* \brief 当采集到窗口时,设置图像显示的区域和比例。
|
* 将图像中(xSrc,ySrc,wSrc,hSrc)指定的区域显示到窗口中指定区域(xDest,yDest,wDest,hDest)
|
* \param [in] hCam 相机句柄
|
* \param [in] xDest 指定显示窗口中目标矩形左上角的逻辑X坐标
|
* \param [in] yDest 指定显示窗口中目标矩形左上角的逻辑Y坐标
|
* \param [in] wDest 指定显示窗口中目标矩形的宽度
|
* \param [in] hDest 指定显示窗口中目标矩形的高度
|
* \param [in] xSrc 指定图像源位图左上角的逻辑X坐标
|
* \param [in] ySrc 指定图像源位图左上角的逻辑Y坐标
|
* \param [in] wSrc 指定图像源位图宽度
|
* \param [in] hSrc 指定图像源位图高度
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetGrabWindow(IntPtr hCam, int xDest, int yDest, int wDest, int hDest, int xSrc, int ySrc, int wSrc, int hSrc);
|
|
|
|
/*!
|
* \brief 当调用MVFreezeGrabWindow(TRUE)后,调用此函数可以获取当前图像。
|
* \param [in] hCam 相机句柄
|
* \param [out] image 图像
|
* \param [out] nFrameID 图像的ID号
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetSampleGrab(IntPtr hCam, ref MVImage image, out int nFrameID, int msTimeout);
|
|
|
|
/*!
|
* \brief 当调用MVFreezeGrabWindow(TRUE)后,调用此函数可以获取当前图像。
|
* \param [in] hCam 相机句柄
|
* \param [out] pImgBuf 图像指针
|
* \param [in] szBuf 图像指针内存大小
|
* \param [out] nFrameID 图像的ID号
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetSampleGrabBuf(IntPtr hCam, IntPtr pImgBuf, UInt32 szBuf, out int pFrameID, int msTimeout);
|
|
|
|
/*!
|
* \brief 当计算机收到新的图像,而上一帧的Callback函数还没有执行完,SDK中会扔掉新的一帧图像。此函数可以获取扔掉的帧数。
|
* \param [in] hCam 相机句柄
|
* \param [out] pDroppedFrames 扔掉的帧数
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetDroppedFrame(IntPtr hCam, out UInt32 pDroppedFrames);
|
|
|
|
/*!
|
* \brief 获取设备厂商名称
|
* \param [in] hCam 相机句柄
|
* \param [out] pBuf 用于保存名称的缓冲区,大于等于32字节
|
* \param [in,out] szBuf 缓冲区大小
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetDeviceVendorName(IntPtr hCam, IntPtr pBuf, out int szBuf);
|
|
|
|
/*!
|
* \brief 获取设备的型号
|
* \param [in] hCam 相机句柄
|
* \param [out] pBuf 用于保存型号的缓冲区,大于等于32字节
|
* \param [in,out] szBuf 缓冲区大小
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetDeviceModelName(IntPtr hCam, IntPtr pBuf, out int szBuf);
|
|
|
|
/*!
|
* \brief 获取设备的ID号,即序列号
|
* \param [in] hCam 相机句柄
|
* \param [out] pBuf 用于保存序列号的缓冲区,大于等于16字节
|
* \param [in,out] szBuf 缓冲区大小
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetDeviceDeviceID(IntPtr hCam, IntPtr pBuf, out int szBuf);
|
|
|
|
/*!
|
* \brief 相机是否正在采集图像
|
* \param [in] hCam 相机句柄
|
* \retval 正在采集图像返回TRUE,否则返回FALSE
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVIsRunning(IntPtr hCam);
|
|
|
|
/*!
|
* \brief 图像格式转换
|
* \param [in] hCam 相机句柄
|
* \param [in] pImageSrc 源图像指针
|
* \param [out] pImageDst 目标图像指针
|
* \retval
|
* \note 目前仅支持源图像和目标图像的宽高相同,从16Bit转为8Bit, 从48Bit转为24Bit
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVConvertImage(IntPtr hCam, ref MVImage pImageSrc, ref MVImage pImageDst);
|
|
|
|
/*!
|
* \brief 直接从回调函数传回的图像信息中裁剪出图像的一部分,当相机不支持硬件ROI时,可以用此函数实现软件ROI。
|
* \param [in] hCam 相机句柄
|
* \param [in] pInfoSrc 源图像指针,一般是回调函数传回的图像信息指针
|
* \param [out] pInfoDst 目标图像指针,nPixelType要和源图像的相同,需要提前分配好内存。并且宽度和高度要和roi的宽高相同。
|
* \param [in] roi 感兴趣的区域,roi的left,right,top,bottom均须是2的整倍数
|
* \retval
|
* \note 目前仅支持源图像和目标图像的宽高相同,从16Bit转为8Bit, 从48Bit转为24Bit
|
*/
|
//[DllImport("MVGigE.dll")]
|
//public static extern MVSTATUS_CODES MVCopyImageInfoROI(IntPtr hCam, ref IMAGE_INFO pInfoSrc, ref IMAGE_INFO pInfoDst, RECT roi);
|
|
|
|
/*!
|
* \brief 自适应中值滤波,用于去除长时间曝光暗电流造成的图像中亮点,目前仅适用于8Bit黑白图像
|
* \param [in] hCam 相机句柄
|
* \param [in/out] pImage 图像
|
* \param [in] th 阈值,和周围差异大于此阈值的被认为是噪点
|
* \retval MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVFilterAdaptiveMedian(IntPtr hCam, ref MVImage pImage, int th);
|
|
|
|
/*!
|
* \brief 调节饱和度
|
* \param [in] hCam 相机句柄
|
* \param [in] nSaturation 饱和度,范围-100到100, -100为黑白,0为原图,100为最鲜艳
|
* \retval
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetSaturation(IntPtr hCam, int nSaturation);
|
|
|
|
/*!
|
* \brief 获取当前饱和度
|
* \param [in] hCam 相机句柄
|
* \param [out] nSaturation 饱和度指针
|
* \retval
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetSaturation(IntPtr hCam, out int nSaturation);
|
|
|
|
/*!
|
* \brief 颜色校正
|
* \param [in] hCam 相机句柄
|
* \param [in] nColorCorrect, 颜色校正模式,目前仅支持0和1,0为不校正,1为校正
|
* \retval
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetColorCorrect(IntPtr hCam, int nColorCorrect);
|
|
|
|
/*!
|
* \brief 获取当前颜色校正模式
|
* \param [in] hCam 相机句柄
|
* \param [out] nColorCorrect 颜色校正模式指针
|
* \retval
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetColorCorrect(IntPtr hCam, out int nColorCorrect);
|
|
|
|
/*!
|
* \brief 注册用于接收消息的窗口句柄和消息值。当相机断开或重新连上时会发送消息到该窗口。
|
* \param [in] hCam 相机句柄
|
* \param [in] IntPtr 用于接收消息的窗口句柄
|
* \param [in] nMsg 消息值
|
* \retval
|
* \sa MVEnableMessage
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVRegisterMessage(IntPtr hCam, IntPtr IntPtr, UInt32 nMsg);
|
|
|
|
/*!
|
* \brief 是否允许发送某个消息
|
* \param [in] hCam 相机句柄
|
* \param [in] nMessageType 消息类型, MSG_ID_LOST,MSG_ID_RECONNECT
|
* \param [in] bEnable 如果为TRUE,则发送该消息,为FALSE则不发送该消息
|
* \retval
|
* \sa MVRegisterMessage
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVEnableMessage(IntPtr hCam, int nMessageType, bool bEnable);
|
|
|
|
/*!
|
* \brief 获取自定义名称
|
* \param [in] hCam 相机句柄
|
* \param [out] pBuf 相机名称缓冲区
|
* \param [in/out] szBuf 相机名称缓冲区长度指针
|
* \retval
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetUserDefinedName(IntPtr hCam, StringBuilder pBuf, out int szBuf);
|
|
|
|
/*!
|
* \brief 设置自定义名称
|
* \param [in] hCam 相机句柄
|
* \param [out] pBuf 相机名称缓冲区
|
* \param [in] szBuf 相机名称缓冲区长度指针
|
* \retval
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetUserDefinedName(IntPtr hCam, string pBuf, int szBuf);
|
|
|
|
/*!
|
* \brief 以只读方式打开相机
|
* \param [in] idx idx从0开始,按照相机的IP地址排序,地址小的排在前面。
|
* \param [out] hCam 如果成功,返回的相机句柄
|
* \retval MVST_INVALID_PARAMETER : idx取值不对
|
* MVST_ACCESS_DENIED : 相机无法访问,可能正被别的软件控制
|
* MVST_ERROR : 其他错误
|
* MVST_SUCCESS : 成功
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVOpenCamByIndexReadOnly(byte idx, IntPtr hCam);
|
|
|
|
/*!
|
* \brief 搜索相机,包含不在同一网段的相机
|
* \param [out] pDevCnt 相机数量指针
|
* \retval
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVEnumerateAllDevices(out int pDevCnt);
|
|
|
|
/*!
|
* \brief 为相机设置ip地址
|
* \param [in] pMacAddress 待设置ip相机的MAC地址
|
* \param [in] pIpAddress 设置给相机的IP地址
|
* \param [in] pSubnetMask 设置给相机的子网掩码
|
* \param [in] pDefaultGateway 设置给相机的默认网关
|
* \retval
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVForceIp( string pMacAddress, string pIpAddress, string pSubnetMask, string pDefaultGateway);
|
|
|
|
/*!
|
* \brief 获取MVEnumerateAllDevices搜索到的相机的信息
|
* \param [in] idx 相机序号
|
* \param [out] pCamInfo 相机信息
|
* \retval
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetDevInfo(byte idx, out MVCamInfo pCamInfo);
|
|
|
|
/*!
|
* \brief 设置静态IP地址
|
* \param [in] hCam
|
* \param [in] pIpAddress 192.168.0.9
|
* \param [in] pSubnetMask 255.255.255.0
|
* \param [in] pDefaultGateway 0.0.0.0
|
* \retval
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetPersistentIpAddress(IntPtr hCam, string pIpAddress, string pSubnetMask, string pDefaultGateway);
|
|
|
|
/*!
|
* \brief 获取相机的静态IP设置
|
* \param [in] hCam
|
* \param [out] pIpAddress
|
* \param [out] pIpAddressLen pIpAddress缓冲区长度
|
* \param [out] pSubnetMask
|
* \param [out] pSubnetMaskLen pSubnetMask缓冲区长度
|
* \param [out] pDefaultGateway
|
* \param [out] pDefaultGatewayLen pDefaultGateway缓冲区长度
|
* \retval
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetPersistentIpAddress(IntPtr hCam, string pIpAddress, out int pIpAddressLen, string pSubnetMask, out int pSubnetMaskLen, string pDefaultGateway, out int pDefaultGatewayLen);
|
|
|
/*!
|
* \brief
|
* \param [in] hCam 相机句柄
|
* \param [in] fBlackLevel 偏置
|
* \param [in] nTap 通道
|
* \retval
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetBlackLevelTaps(IntPtr hCam, double fBlackLevel, int nTap);
|
|
|
|
/*!
|
* \brief
|
* \param [in] hCam 相机句柄
|
* \param [out] pBlackLevel 偏置
|
* \param [in] nTap 通道
|
* \retval
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetBlackLevelTaps(IntPtr hCam, out double pBlackLevel, int nTap);
|
|
|
|
/*!
|
* \brief 设置偏置
|
* \param [in] hCam 相机句柄
|
* \param [in] fBlackLevel 偏置
|
* \retval
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetBlackLevel(IntPtr hCam, double fBlackLevel);
|
|
|
|
/*!
|
* \brief 读取偏置
|
* \param [in] hCam 相机句柄
|
* \param [out] pBlackLevel 偏置
|
* \retval
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVGetBlackLevel(IntPtr hCam, out double pBlackLevel);
|
|
|
|
/*!
|
* \brief 设置测试图
|
* \param [in] hCam 相机句柄
|
* \param [in] testImage 测试图
|
* \sa TestImageEnums
|
* TestImage_Off : 关闭测试图
|
* TestImage_GreyRamp : 灰度图
|
*
|
*/
|
[DllImport("MVGigE.dll")]
|
public static extern MVSTATUS_CODES MVSetTestImage(IntPtr hCam, TestImageEnums testImage);
|
|
|
|
[DllImport("kernel32.dll", EntryPoint = "CopyMemory", SetLastError = false)]
|
public static extern void CopyMemory(IntPtr dest, IntPtr src, uint count);
|
|
#endregion
|
}
|
class MVImage
|
{
|
#region"function"
|
[DllImport("MVGigE.dll")]
|
public static extern IntPtr MVImageCreate(int nWidth, int nHeight, int nBPP);
|
[DllImport("MVGigE.dll")]
|
public static extern bool MVImageIsNull(IntPtr hImage);
|
[DllImport("MVGigE.dll")]
|
public static extern int MVImageGetWidth(IntPtr hImage);
|
[DllImport("MVGigE.dll")]
|
public static extern int MVImageGetHeight(IntPtr hImage);
|
[DllImport("MVGigE.dll")]
|
public static extern IntPtr MVImageGetBits(IntPtr hImage);
|
[DllImport("MVGigE.dll")]
|
public static extern int MVImageGetPitch(IntPtr hImage);
|
[DllImport("MVGigE.dll")]
|
public static extern int MVImageGetBPP(IntPtr hImage);
|
[DllImport("MVGigE.dll")]
|
public static extern bool MVImageDraw(IntPtr hImage, IntPtr hDestDC, int xDest, int yDest);
|
[DllImport("MVGigE.dll")]
|
public static extern bool MVImageDrawEx(IntPtr hImage, IntPtr hDestDC, int xDest, int yDest, int nDestWidth, int nDestHeight, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight);
|
[DllImport("MVGigE.dll")]
|
public static extern bool MVImageDrawIntPtr(IntPtr hImage, IntPtr IntPtr, int xDest, int yDest);
|
[DllImport("MVGigE.dll")]
|
public static extern bool MVImageDrawIntPtrEx(IntPtr hImage, IntPtr IntPtr, int xDest, int yDest, int nDestWidth, int nDestHeight, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight);
|
[DllImport("MVGigE.dll")]
|
public static extern bool MVImageDrawHwnd(IntPtr hImage, IntPtr hWnd, int xDest, int yDest);
|
[DllImport("MVGigE.dll")]
|
public static extern bool MVImageDrawHwndEx(IntPtr hImage, IntPtr hWnd, int xDest, int yDest, int nDestWidth, int nDestHeight, int xSrc, int ySrc, int nSrcWidth, int nSrcHeight);
|
[DllImport("MVGigE.dll")]
|
public static extern IntPtr MVImageGetDC(IntPtr hImage);
|
[DllImport("MVGigE.dll")]
|
public static extern IntPtr MVImageReleaseDC(IntPtr hImage);
|
[DllImport("MVGigE.dll")]
|
public static extern void MVImageSave(IntPtr hImage, string strFileName);
|
[DllImport("MVGigE.dll")]
|
public static extern void MVImageDestroy(IntPtr hImage);
|
[DllImport("MVGigE.dll")]
|
public static extern void MVImageRelease(IntPtr hImage);
|
#endregion
|
}
|
class MVCamProptySheet
|
{
|
public const UInt16 PAGE_NONE = 0x0000;
|
public const UInt16 PAGE_ALL = 0xffff;
|
public const UInt16 PAGE_ACQUISITION = 0x0001;
|
public const UInt16 PAGE_WHITE_BALANCE = 0x0002;
|
public const UInt16 PAGE_TRANS_LAYER = 0x0004;
|
public const UInt16 PAGE_TRIGGER = 0x0008;
|
public const UInt16 PAGE_CAMERA_INFO = 0x0010;
|
public const UInt16 PAGE_IMAGE_FORMAT = 0x0020;
|
public const UInt16 PAGE_AUTOGE_CONTROL = 0x0040;
|
public const UInt16 PAGE_USERSET = 0x0080;
|
#region"function"
|
/*!
|
* \brief 创建相机属性页
|
* \param [out] phProptySheet 返回相机属性页句柄
|
* \param [in] hCam 相机句柄
|
* \param [in] pParentWnd 父窗口句柄
|
* \param [in] lpszText 相机属性页标题栏文字
|
* \retval
|
*/
|
[DllImport("MVCamProptySheet.dll")]
|
public static extern MVSTATUS_CODES MVCamProptySheetCreateEx(out IntPtr phProPerty, IntPtr hCam, IntPtr pParentWnd, string lpszText, UInt16 nPageDisplay);
|
/*!
|
* \brief 销毁相机属性页
|
* \param [in] hProptySheet 相机属性页句柄
|
* \retval
|
*/
|
[DllImport("MVCamProptySheet.dll")]
|
public static extern MVSTATUS_CODES MVCamProptySheetDestroy(IntPtr hProPerty);
|
/*!
|
* \brief 设置相机属性页标题栏文字
|
* \param [in] hProptySheet 相机属性页句柄
|
* \param [in] lpszText 相机属性页标题栏文字
|
|
* \retval
|
*/
|
[DllImport("MVCamProptySheet.dll")]
|
public static extern MVSTATUS_CODES MVCamProptySheetSetTitle(IntPtr hProPerty, string lpszText);
|
/*!
|
* \brief 设置相机属性页对应的相机。
|
* \param [in] hProptySheet 相机属性页句柄
|
* \param [in] hCam 相机句柄
|
* \retval
|
*/
|
[DllImport("MVCamProptySheet.dll")]
|
public static extern MVSTATUS_CODES MVCamProptySheetSetCamera(IntPtr hProPerty, IntPtr hCam);
|
/*!
|
* \brief 获取相机属性页当前对应的相机。
|
* \param [in] hProptySheet 相机属性页句柄
|
* \param [out] phCam 相机句柄
|
* \retval
|
*/
|
[DllImport("MVCamProptySheet.dll")]
|
public static extern MVSTATUS_CODES MVCamProptySheetGetCamera(IntPtr hProPerty, out IntPtr hCam);
|
/*!
|
* \brief 设置相机现在是否正工作在采集模式。
|
* \param [in] hProptySheet 相机属性页句柄
|
* \param [in] Run 如果相机正工作在采集模式下,设置为TRUE,否则设置为FALSE
|
* \note 如果正工作在采集模式,属性页中将禁用一些采集状态下不允许改变的相机属性,如图像大小等。
|
* \retval
|
*/
|
[DllImport("MVCamProptySheet.dll")]
|
public static extern MVSTATUS_CODES MVCamProptySheetCameraRun(IntPtr hProPerty, MVCameraRunEnums Run);
|
/*!
|
* \brief 以非模式框方式显示或关闭相机属性页
|
* \param [in] hProptySheet 相机属性页句柄
|
* \param [in] nCmdShow SW_SHOW:显示, SW_HIDE:关闭
|
* \retval
|
*/
|
[DllImport("MVCamProptySheet.dll")]
|
public static extern MVSTATUS_CODES MVCamProptySheetShow(IntPtr hProPerty, MVShowWindowEnums nCmdShow);
|
#endregion
|
|
[DllImport("MVCamProptySheet.dll")]
|
public static extern MVSTATUS_CODES MVCamProptySheetInsertPage(IntPtr hProptySheet, UInt16 nPageInsert);
|
|
[DllImport("MVCamProptySheet.dll")]
|
public static extern MVSTATUS_CODES MVCamProptySheetDeletePage(IntPtr hProptySheet, UInt16 nPageDelete);
|
}
|
class MVSequenceDlg
|
{
|
#region"function"
|
/*!
|
* \brief 创建序列帧计时器对话框
|
* \param [out] phSeqDlg 返回序列帧计时器对话框句柄
|
* \param [in] pParentWnd 父窗口句柄
|
* \retval
|
*/
|
[DllImport("MVTickDlg")]
|
public static extern bool MVSequenceDlgCreateEx(out IntPtr phSeqDlg, IntPtr pParentWnd);
|
/*!
|
* \brief 销毁序列帧计时器对话框
|
* \param [in] hSeqDlg 序列帧计时器对话框句柄
|
* \retval
|
*/
|
[DllImport("MVTickDlg")]
|
public static extern bool MVSequenceDlgDestroy(IntPtr hSeqDlg);
|
/*!
|
* \brief 设置相机现在是否正工作在采集模式。
|
* \param [in] hSeqDlg 序列帧计时器对话框句柄
|
* \param [in] bRun 如果相机正工作在采集模式下,设置为TRUE,否则设置为FALSE
|
* \note 如果正工作在采集模式,属性页中将禁用一些采集状态下不允许改变的相机属性,如图像大小等。
|
* \retval
|
*/
|
[DllImport("MVTickDlg")]
|
public static extern void MVSequenceDlgCamRun(IntPtr hSeqDlg, bool bRun);
|
/*!
|
* \brief 以非模式框方式显示或关闭序列帧计时器对话框
|
* \param [in] hSeqDlg 序列帧计时器对话框句柄
|
* \param [in] nCmdShow SW_SHOW:显示, SW_HIDE:关闭
|
* \retval
|
*/
|
[DllImport("MVTickDlg")]
|
public static extern bool MVSequenceDlgShow(IntPtr hSeqDlg, MVShowWindowEnums nCmdShow);
|
/*!
|
* \brief 获得即将进入队列的文件名,及当前图片是否需要保存
|
* \param [in] hSeqDlg 序列帧计时器对话框句柄
|
* \param [out] fname 返回文件名
|
* \param [in] szBuf 文件名长度
|
* \retval 0:保存 -1:不保存 -2:获取文件名出错
|
*/
|
[DllImport("MVTickDlg")]
|
public static extern int MVSequenceDlgGetFileName(IntPtr hSeqDlg, StringBuilder fname, Int32 szBuf);
|
#endregion
|
}
|
class MVRecordDlg
|
{
|
#region"function"
|
/*!
|
* \brief 创建录像计时器对话框
|
* \param [out] phRecDlg 返回录像计时器对话框句柄
|
* \param [in] hCam 相机句柄
|
* \param [in] pParentWnd 父窗口句柄
|
* \retval
|
*/
|
[DllImport("MVTickDlg")]
|
public static extern bool MVRecordDlgCreateEx(out IntPtr phRecDlg, IntPtr hCam, IntPtr pParentWnd);
|
/*!
|
* \brief 销毁录像计时器对话框
|
* \param [in] hRecDlg 录像计时器对话框句柄
|
* \retval
|
*/
|
[DllImport("MVTickDlg")]
|
public static extern bool MVRecordDlgDestroy(IntPtr hRecDlg);
|
/*!
|
* \brief 设置相机现在是否正工作在采集模式。
|
* \param [in] hRecDlg 录像计时器对话框句柄
|
* \param [in] bRun 如果相机正工作在采集模式下,设置为TRUE,否则设置为FALSE
|
* \note 如果正工作在采集模式,属性页中将禁用一些采集状态下不允许改变的相机属性,如图像大小等。
|
* \retval
|
*/
|
[DllImport("MVTickDlg")]
|
public static extern void MVRecordDlgCamRun(IntPtr hRecDlg, bool bRun);
|
/*!
|
* \brief 以非模式框方式显示或关闭录像计时器对话框
|
* \param [in] hRecDlg 录像计时器对话框句柄
|
* \param [in] nCmdShow SW_SHOW:显示, SW_HIDE:关闭
|
* \retval
|
*/
|
[DllImport("MVTickDlg")]
|
public static extern bool MVRecordDlgShow(IntPtr hSeqDlg, MVShowWindowEnums nCmdShow);
|
/*!
|
* \brief 向录像中插入帧
|
* \param [in] hRecDlg 录像计时器对话框句柄
|
* \param [in] pImageBuffer 图像指针
|
* \param [in] nWidth 图像宽度
|
* \param [in] nHeight 图像高度
|
* \param [in] nBpp 单个像素点位数
|
* \param [in] nBlockId 帧号,从开始采集开始计数,计时器根据帧号确定该帧是否插入录像
|
* \retval 0:插入成功 -1:不需插入 -2:插入失败 -3:文件指针为空 1:插入成,并且计时停止
|
*/
|
[DllImport("MVTickDlg")]
|
public static extern int MVRecordDlgRecord(IntPtr hRecDlg, IntPtr hIamge, ushort nBlockId);
|
#endregion
|
}
|
}
|