//==========================================================================//
// //
// C# - Interfaceclass for uEye_tools //
// //
// Copyright (C) 2005 -2010 //
// IDS - Imaging Development Systems GmbH //
// Dimbacherstr. 6-8 //
// D-74182 Obersulm-Willsbach //
// //
// The information in this document is subject to change without //
// notice and should not be construed as a commitment by IDS Imaging GmbH. //
// IDS Imaging GmbH does not assume any responsibility for any errors //
// that may appear in this document. //
// //
// This document, or source code, is provided solely as an example //
// of how to utilize IDS software libraries in a sample application. //
// IDS Imaging GmbH does not assume any responsibility for the use or //
// reliability of any portion of this document or the described software. //
// //
// General permission to copy or modify, but not for profit, is hereby //
// granted, provided that the above copyright notice is included and //
// included and reference made to the fact that reproduction privileges //
// were granted by IDS Imaging GmbH. //
// //
// IDS cannot assume any responsibility for the use, or misuse, of any //
// portion or misuse, of any portion of this software for other than its //
// intended diagnostic purpose in calibrating and testing IDS manufactured //
// image processing boards and software. //
// //
//==========================================================================//
using System;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Text;
///
/// Zusammenfassung für uEye_tools.
///
public class uEye_tools
{
// ----------------------------------------Driver name-----------------------------------------
//
public const string DRIVER_DLL_NAME = "ueye_tools.dll";
// ----------------------------------------Color modes-----------------------------------------
//
public const Int32 IS_AVI_CM_RGB32 = 0; // RGB32
public const Int32 IS_AVI_CM_RGB24 = 1; // RGB24
public const Int32 IS_AVI_CM_Y8 = 6; // Y8
public const Int32 IS_AVI_CM_BAYER = 11; // Bayer
// ----------------------------------------Events-----------------------------------------
//
public const Int32 IS_AVI_SET_EVENT_FRAME_SAVED = 1;
// **********************************************
// return values/error codes
// **********************************************
public const Int32 IS_AVI_NO_ERR = 0 ;
public const Int32 IS_AVI_ERR_INVALID_FILE = 301 ;
public const Int32 IS_AVI_ERR_NEW_FAILED = 302 ;
public const Int32 IS_AVI_ERR_CREATESTREAM = 303 ;
public const Int32 IS_AVI_ERR_PARAMETER = 304 ;
public const Int32 IS_AVI_ERR_NO_CODEC_AVAIL = 305 ;
public const Int32 IS_AVI_ERR_INVALID_ID = 306 ;
public const Int32 IS_AVI_ERR_COMPRESS = 307 ;
public const Int32 IS_AVI_ERR_DECOMPRESS = 308 ;
public const Int32 IS_AVI_ERR_CAPTURE_RUNNING = 309 ;
public const Int32 IS_AVI_ERR_CAPTURE_NOT_RUNNING = 310 ;
public const Int32 IS_AVI_ERR_PLAY_RUNNING = 311 ;
public const Int32 IS_AVI_ERR_PLAY_NOT_RUNNING = 312 ;
public const Int32 IS_AVI_ERR_WRITE_INFO = 313 ;
public const Int32 IS_AVI_ERR_INVALID_VALUE = 314 ;
public const Int32 IS_AVI_ERR_ALLOC_MEMORY = 315 ;
public const Int32 IS_AVI_ERR_INVALID_CM = 316 ;
public const Int32 IS_AVI_ERR_COMPRESSION_RUN = 317 ;
public const Int32 IS_AVI_ERR_INVALID_SIZE = 318 ;
public const Int32 IS_AVI_ERR_INVALID_POSITION = 319 ;
public const Int32 IS_AVI_ERR_INVALID_UEYE = 320 ;
public const Int32 IS_AVI_ERR_EVENT_FAILED = 321 ;
// ***********************************************
// exports from uEye_tools.dll
// ***********************************************
[DllImport(DRIVER_DLL_NAME ,EntryPoint="isavi_InitAVI",CallingConvention=CallingConvention.StdCall)] // isavi_InitAVI) (INT* pnAviID,HANDLE hf);
private static extern Int32 isavi_InitAVI(ref Int32 pnAviID,Int32 hu);
[DllImport(DRIVER_DLL_NAME ,EntryPoint="isavi_ExitAVI",CallingConvention=CallingConvention.StdCall)] //isavi_ExitAVI) (INT nAviID);
private static extern Int32 isavi_ExitAVI (Int32 nAviID);
[DllImport(DRIVER_DLL_NAME ,EntryPoint="isavi_OpenAVI",CallingConvention=CallingConvention.StdCall)] //isavi_OpenAVI) (INT nAviID, const char* strFileName);
private static extern Int32 isavi_OpenAVI (Int32 nAviID, byte[] strFileName);
[DllImport(DRIVER_DLL_NAME ,EntryPoint="isavi_StartAVI",CallingConvention=CallingConvention.StdCall)] // isavi_StartAVI) (INT nAviID);
private static extern Int32 isavi_StartAVI (Int32 nAviID);
[DllImport(DRIVER_DLL_NAME ,EntryPoint="isavi_StopAVI",CallingConvention=CallingConvention.StdCall)] // isavi_StopAVI) (INT nAviID);
private static extern Int32 isavi_StopAVI (Int32 nAviID);
[DllImport(DRIVER_DLL_NAME ,EntryPoint="isavi_AddFrame",CallingConvention=CallingConvention.StdCall)] // isavi_AddFrame (INT nAviID,char *pcImageMem);
private static extern Int32 isavi_AddFrame (Int32 nAviID, IntPtr pcImageMem);
[DllImport(DRIVER_DLL_NAME ,EntryPoint="isavi_SetFrameRate",CallingConvention=CallingConvention.StdCall)] // isavi_SetFrameRate (INT nAviID,double fr);
private static extern Int32 isavi_SetFrameRate (Int32 nAviID,double fr);
[DllImport(DRIVER_DLL_NAME ,EntryPoint="isavi_SetImageQuality",CallingConvention=CallingConvention.StdCall)] // isavi_SetImageQuality (INT nAviID,Int32 q);
private static extern Int32 isavi_SetImageQuality (Int32 nAviID,Int32 q);
[DllImport(DRIVER_DLL_NAME ,EntryPoint="isavi_GetAVISize",CallingConvention=CallingConvention.StdCall)] // isavi_GetAVISize (INT nAviID,Single *size);
private static extern Int32 isavi_GetAVISize(Int32 nAviID,ref Single size);
[DllImport(DRIVER_DLL_NAME ,EntryPoint="isavi_GetAVIFileName",CallingConvention=CallingConvention.StdCall)] // isavi_GetAVIFileName (INT nAviID, char* strName);
private static extern Int32 isavi_GetAVIFileName (Int32 nAviID, byte[] strName);
[DllImport(DRIVER_DLL_NAME ,EntryPoint="isavi_SetImageSize",CallingConvention=CallingConvention.StdCall)] // isavi_SetImageSize) (INT nAviID,INT cMode, Int32 Width, Int32 Height, Int32 PosX, Int32 PosY, Int32 LineOffset);
private static extern Int32 isavi_SetImageSize (Int32 nAviID,Int32 cMode, Int32 Width, Int32 Height, Int32 PosX, Int32 PosY, Int32 LineOffset);
[DllImport(DRIVER_DLL_NAME ,EntryPoint="isavi_GetnCompressedFrames",CallingConvention=CallingConvention.StdCall)] // isavi_GetnCompressedFrames (INT nAviID,unsigned Int32 *nFrames);
private static extern Int32 isavi_GetnCompressedFrames (Int32 nAviID,ref UInt32 nFrames);
[DllImport(DRIVER_DLL_NAME ,EntryPoint="isavi_GetnLostFrames",CallingConvention=CallingConvention.StdCall)] // isavi_GetnLostFrames (INT nAviID,unsigned Int32 *nLostFrames);
private static extern Int32 isavi_GetnLostFrames (Int32 nAviID,ref UInt32 nLostFrames);
[DllImport(DRIVER_DLL_NAME ,EntryPoint="isavi_ResetFrameCounters",CallingConvention=CallingConvention.StdCall)] // isavi_ResetFrameCounters (INT nAviID);
private static extern Int32 isavi_ResetFrameCounters (Int32 nAviID);
[DllImport(DRIVER_DLL_NAME ,EntryPoint="isavi_CloseAVI",CallingConvention=CallingConvention.StdCall)] // isavi_CloseAVI (INT nAviID);
private static extern Int32 isavi_CloseAVI (Int32 nAviID);
[DllImport(DRIVER_DLL_NAME ,EntryPoint="isavi_InitEvent",CallingConvention=CallingConvention.StdCall)] // isavi_InitEvent (INT nAviID, HANDLE hEv, INT which);
private static extern Int32 isavi_InitEvent (Int32 nAviID, Int32 hEv, Int32 which);
[DllImport(DRIVER_DLL_NAME ,EntryPoint="isavi_EnableEvent",CallingConvention=CallingConvention.StdCall)] // isavi_EnableEvent (INT nAviID, INT which);
private static extern Int32 isavi_EnableEvent (Int32 nAviID, Int32 which);
[DllImport(DRIVER_DLL_NAME ,EntryPoint="isavi_DisableEvent",CallingConvention=CallingConvention.StdCall)] // isavi_DisableEvent (INT nAviID, INT which);
private static extern Int32 isavi_DisableEvent (Int32 nAviID, Int32 which);
[DllImport(DRIVER_DLL_NAME ,EntryPoint="isavi_ExitEvent",CallingConvention=CallingConvention.StdCall)] // isavi_ExitEvent (INT nAviID, INT which);
private static extern Int32 isavi_ExitEvent (Int32 nAviID, Int32 which);
// internal variables
private Int32 m_hAvi; // internal avi container handle
// constructor
public uEye_tools()
{
m_hAvi = 0;
}
//********************************************************************************************
// Helper functions
//********************************************************************************************
// ------------------------------ GetStringFromByte --------------------------
//
private string GetStringFromByte(byte[] pByte, Int32 nStart, Int32 nLength )
{
Int32 i=0;
char[] pChars = new char[nLength];
for ( i=0; i