C # What is the problem during the secondary development of the sdk3000 OCX component ?? Solution
This is the trigger condition for dynamic detection.
Private void btnstarttest_click (Object sender, eventargs E)
{
Byte [] bytes = new byte [] {, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 25, 25, 25, 25, 25, 25, 25 };
String mapsize = encoding. ASCII. getstring (bytes );
Int32 imotiondetect = sdk3000apiclass. getmotiondetectdelegate ();
Axsdk3000.enablemotiondetect (mapsize, bytes. length, 10, imotiondetect );
}
Sdk3000apiclass. getmotiondetectdelegate (); this is the result of the obtained pointer:
Public static int32 getmotiondetectdelegate ()
{
Vcaprccbmotiondetectinvoke icpic = new vcaprccbmotiondetectinvoke (vcaprccbmotiondetect );
Return marshal. getfunctionpointerfordelegate (icpic). toint32 ();
}
Here is the delegate statement
Public Delegate void vcaprccbmotiondetectinvoke (INT dwcard, bool bmove, ref int lpcontext );
The following is a delegated instance. Every call always says that the referenced memory is written/read, and then it crashes and pulls
I don't know if there is a problem with my parameters, or the method used to delegate the pointer is incorrect. Please help me to see,
At the end of the month to submit projects, urgent ah, my QQ: 379446670, mail: 520philip@163.com
Please help me see
/// <Summary>
/// Dynamic detection callback
/// </Summary>
/// <Param name = "dwcard"> </param>
/// <Param name = "bmove"> </param>
/// <Param name = "lpcontext"> </param>
Public static void vcaprccbmotiondetect (INT dwcard, bool bmove, ref int lpcontext)
{
MessageBox. Show ("messageboxshow! ");
}
**************************************** **************************************** ***********
Below is how to use DLL
**************************************** **************************************** ***********
If the com method does not work, I will use the method called by C ++ DLL, but the result is still problematic.
Public static int motiondetecti (INT ncards, bool benadetect, byte [] pareamap, long nsizeofmap, long npersisttime, ref string lpcontext)
{
Vcaprccbmotiondetectinvoke icpic = new vcaprccbmotiondetectinvoke (vcaprccbmotiondetect );
Return vcaenablemotiondetect (ncards, benadetect, ref pareamap,
Nsizeofmap, npersisttime, ref lpcontext, icpic );
}
[Dllimport ("sdk3000_7130.dll")]
Public static extern int vcaenablemotiondetect (INT ncards, bool benadetect, ref byte [] pareamap, long nsizeofmap, long npersisttime, ref string lpcontext, vcaprccbmotiondetectinvoke TP );
Public Delegate void vcaprccbmotiondetectinvoke (INT dwcard, bool bmove, ref int lpcontext );
/// <Summary>
/// Dynamic detection callback
/// </Summary>
/// <Param name = "dwcard"> </param>
/// <Param name = "bmove"> </param>
/// <Param name = "lpcontext"> </param>
Public static void vcaprccbmotiondetect (INT dwcard, bool bmove, ref int lpcontext)
{
MessageBox. Show ("messageboxshow! ");
}
There is always a problem with callback ???
I hope you can help me. it's too difficult to pull it for two weeks. I don't know how it looks. The end of the month is full.