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);
//已删除
/////
///// 更新词典
/////
///// 检测句柄
///// 布种类
/////
///// [HandleProcessCorruptedStateExceptions]
//[DllImport(SdkDll, EntryPoint = "Flaw_UpdateDict", CallingConvention = CallingConvention.Cdecl)]
//public static extern int Flaw_UpdateDict(IntPtr handle, int cloths_kind);
///
///
///
///
///
///
///
///
///
///
///
///
///
[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);
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
[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);
}
}