SdkMyCode.cs
9.14 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
using System;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using static OS.Spin.Modle.Sdk.StructInfos;
namespace OS.Spin.SdkLayer
{
public class SdkMyCode
{
private const string SdkDll = @"MyCodeExport.dll";
/*************************************************************************
* FUNCTION: Flaw_ReadImg
* PURPOSE: 读图
* PARAM:
[in] path - 图片路径
[out] image_out - 图像指针,预先分配内存
* RETURN: 成功(0)
* NOTES:
*************************************************************************/
[HandleProcessCorruptedStateExceptions]
[DllImport(SdkDll, EntryPoint = "Flaw_ReadImg", CallingConvention = CallingConvention.Cdecl)]
public static extern int Flaw_ReadImg(string path, byte[] image_out);
/*************************************************************************
* FUNCTION: Flaw_Detection_Init
* PURPOSE: 初始化
* PARAM:
[in/out] handle - 句柄
[in] params - 参数
* RETURN: 成功(0)或者错误代码(<0)
* NOTES:
*************************************************************************/
[HandleProcessCorruptedStateExceptions]
[DllImport(SdkDll, EntryPoint = "Flaw_DetecInit", CallingConvention = CallingConvention.Cdecl)]
public static extern int Flaw_DetecInit(ref IntPtr handle, DETC_PARAM para);
//已删除
///// <summary>
///// 更新词典
///// </summary>
///// <param name="handle">检测句柄</param>
///// <param name="cloths_kind">布种类</param>
///// <returns></returns>
///// [HandleProcessCorruptedStateExceptions]
//[DllImport(SdkDll, EntryPoint = "Flaw_UpdateDict", CallingConvention = CallingConvention.Cdecl)]
//public static extern int Flaw_UpdateDict(IntPtr handle, int cloths_kind);
/// <summary>
///
/// </summary>
/// <param name="handle"></param>
/// <param name="image_in"></param>
/// <param name="image_disp"></param>
/// <param name="image_rawproc"></param>
/// <param name="cloths_kind"></param>
/// <param name="param"></param>
/// <param name="VFore_SingleImg"></param>
/// <param name="batch_size"></param>
/// <param name="fabric_width"></param>
/// <returns></returns>
[HandleProcessCorruptedStateExceptions]
[DllImport(SdkDll, EntryPoint = "Flaw_Detection", CallingConvention = CallingConvention.Cdecl)]
public static extern int Flaw_Detection(IntPtr handle, DETC_PARAM para, IntPtr image_in, int img_c, IntPtr image_disp, IntPtr image_rawproc, IntPtr VFore_SingleImg, ref int foreNums);
[HandleProcessCorruptedStateExceptions]
[DllImport(SdkDll, EntryPoint = "Flaw_ClothsWidth", CallingConvention = CallingConvention.Cdecl)]
public static extern int Flaw_ClothsWidth(IntPtr handle,ref int clothWidth);
//ADETECT_API int Flaw_ClothsWidth(void* &handle, int& clothsWidth);
[HandleProcessCorruptedStateExceptions]
[DllImport(SdkDll, EntryPoint = "Flaw_ClassifyInit", CallingConvention = CallingConvention.Cdecl)]
public static extern int Flaw_ClassifyInit(ref IntPtr handle_h, ref IntPtr handle_v, ref IntPtr handle_proc);
[HandleProcessCorruptedStateExceptions]
[DllImport(SdkDll, EntryPoint = "Flaw_ClothsWidth", CallingConvention = CallingConvention.Cdecl)]
public static extern int Flaw_ClothsWidth(ref IntPtr handle, int clothWidth);
/// <summary>
///
/// </summary>
/// <param name="image_cam1"></param>
/// <param name="image_cam2"></param>
/// <param name="image_cam3"></param>
/// <param name="image_cam4"></param>
/// <param name="VFore_SingleImg"></param>
/// <param name="batch_size"></param>
/// <param name="cloths_kind"></param>
/// <param name="m_gain"></param>
/// <param name="handle_x"></param>
/// <param name="handle_c"></param>
/// <param name="handle_v"></param>
/// <returns></returns>
[HandleProcessCorruptedStateExceptions]
[DllImport(SdkDll, EntryPoint = "Flaw_Classification", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
public static extern int Flaw_Classification(IntPtr img_raw1, IntPtr img_raw2, IntPtr img_raw3,Fore_Result[] FvFore_Result, int batch_size, IntPtr final_Result, ref int final_sizi,ref CLAS_PARAM clas_para, IntPtr handle_x, IntPtr handle_c, IntPtr handle_v);
//ADETECT_API int Flaw_Classification(unsigned char* img_raw1, unsigned char* img_raw2, unsigned char* img_raw3, Fore_Result* VFore_AllImgs, int batch_size, Fore_Result* final_results, int& final_size, CLAS_PARAM*params, void* handle_h, void* handle_v, void* &handle_proc);
// F
//已删除
/*************************************************************************
* FUNCTION: Detc_Postprocess
* PURPOSE: 后处理
* PARAM:
[in] VFore_SingleImg - 前景数组
[in] batch_size - 前景个数
[in] label_poolarray - 历史瑕疵缓存
[in/out] pool_size - 当前瑕疵缓存数量
[out] final_labelout - 最终定性的瑕疵类别
[out] final_labelsize - 最终定性的瑕疵类别数目
[in] current_meter - 当前纬向位置
* RETURN: 成功(0)
* NOTES:可以根据final_labelout的类别去VFore_SingleImg找到对应前景区域,要加个VFore_SingleImg[X].is_valid == 1的限制
*************************************************************************/
//[HandleProcessCorruptedStateExceptions]
//[DllImport(SdkDll, EntryPoint = "Detc_Postprocess", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
//public static extern int Detc_Postprocess([In] Modle.Sdk.StructInfos.Fore_Result[] VFore_SingleImg, int batch_size, [In, Out] Modle.Sdk.StructInfos.FinalResults[] label_poolarray, ref int pool_size, [In, Out] Modle.Sdk.StructInfos.FinalResults[] final_labelout, ref int final_labelsize, int current_meter);
/*************************************************************************
* FUNCTION: Flaw_DetecRelease
* PURPOSE: 资源释放
* PARAM:
[in/out] handle - 句柄
* RETURN: 成功(0)
* NOTES:
*************************************************************************/
[HandleProcessCorruptedStateExceptions]
[DllImport(SdkDll, EntryPoint = "Flaw_DetecRelease", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
public static extern void Flaw_DetecRelease(ref IntPtr handle);
/*************************************************************************
* FUNCTION: Flaw_ClassifyRelease
* PURPOSE: 资源释放
* PARAM:
[in/out] handle - 句柄
* RETURN: 成功(0)
* NOTES:
*************************************************************************/
[DllImport(SdkDll, EntryPoint = "Flaw_ClassifyRelease", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
public static extern void Flaw_ClassifyRelease(ref IntPtr handle_x, ref IntPtr handle_c, ref IntPtr handle_v);
/*************************************************************************
* FUNCTION: Flaw_DetecRelease
* PURPOSE: 资源释放
* PARAM:
[in/out] handle - 句柄
* RETURN: 成功(0)
* NOTES:
*************************************************************************/
[HandleProcessCorruptedStateExceptions]
[DllImport(SdkDll, EntryPoint = "Flaw_DetecRelease", CallingConvention = CallingConvention.Cdecl)]
public static extern void Flaw_DetecRelease(IntPtr handle);
//已删除
/*************************************************************************
* FUNCTION: Detc_Init
* PURPOSE: 初始化
[in/out] handle - 句柄
* RETURN: 成功(0)或者错误代码(<0)
* NOTES:
*************************************************************************/
//[HandleProcessCorruptedStateExceptions]
//[DllImport(SdkDll, EntryPoint = "Detc_Post_Init", CallingConvention = CallingConvention.Cdecl)]
//public static extern int Detc_Post_Init(ref IntPtr handle, int camera);
//已删除
//[HandleProcessCorruptedStateExceptions]
//[DllImport(SdkDll, EntryPoint = "Detc_Postprocess", CallingConvention = CallingConvention.Cdecl)]
//public static extern int Detc_Postprocess(IntPtr handle, Modle.Sdk.StructInfos.Fore_Result[] fores, int count, ref IntPtr foresall, ref int foreCount, ref IntPtr finalresult, int currentMeter, ref byte stop);
//已删除
//[HandleProcessCorruptedStateExceptions]
//[DllImport(SdkDll, EntryPoint = "DP_Clear", CallingConvention = CallingConvention.Cdecl)]
//public static extern int DP_Clear(IntPtr handle);
}
}