API.cs
2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Drawing.Imaging;
namespace Asa.Region
{
internal static class API
{
[DllImport(@".\EyemLib\eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
internal static extern int eyemTrackFeature(EyemImage tpRefImg, EyemImage tpNextImg, IntPtr tpArray, int iArraySize, IntPtr ipResults, out EyemImage tpDstImg);
internal static IntPtr StructArray2IntPtr<T>(T[] tpArray)
{
IntPtr ptr = Marshal.AllocHGlobal(checked(Marshal.SizeOf(typeof(T)) * tpArray.Length));
for (int index = 0; index < tpArray.Length; index++)
Marshal.StructureToPtr(tpArray[index], (IntPtr)(checked((long)ptr + index * Marshal.SizeOf(typeof(T)))), false);
return ptr;
}
[StructLayout(LayoutKind.Sequential)]
internal struct EyemImage
{
public IntPtr Handle;
public int Width;
public int Height;
public int Depth;
public int Channel;
/*
iDepth:
uint8_t 取值范围[0, 255], iDepth = 0(常用,解码图像一般为此种格式)
int8_t 取值范围[-128, 127], iDepth = 1
uint16_t 取值范围[0, 56635], iDepth = 2(常用,点料机图像一般为此种格式)
int16_t 取值范围[-32768, 32767], iDepth = 3
int32_t 取值范围[-2147483648, 2147483647], iDepth = 4
float_t 取值范围[-3.4028235E38, 3.4028235E38], iDepth = 5
double_t 取值范围[-1.7E-308, 1.7E+308], iDepth = 6
iChannels:
彩色 rgb iChannels=3 argb iChannels=4
灰度 iChannels=1
*/
}
[StructLayout(LayoutKind.Sequential)]
internal struct EyemRegion
{
public int X;
public int Y;
public int Width;
public int Height;
public double Ratio; //变化比例
}
}
}