//获取DLL函数返参
void DataGet()
{
if (initTime < 32f)
{
initTime++;
return;
}
else
{
initTime = 33f;
}
//人脸数量初始化
wbFaceNum = 0;
Color32[] pixels = webcamTexture.GetPixels32();
pixelsHandle = GCHandle.Alloc(pixels, GCHandleType.Pinned);
//System.Array.Reverse(pixels);
//destTex = new Texture2D(webcamTexture.width, webcamTexture.height);
//destTex.SetPixels32(pixels);
//destTex.Apply();
//go.renderer.material.mainTexture = destTex;
//人脸返回数据初始化
for (int i = 0; i < maxDetectNum; ++i)
{
wbArea[i].x = 0;
wbArea[i].y = 0;
wbArea[i].width = 0;
wbArea[i].height = 0;
}
/******************************************************行人检测***************************************************************/
//wc
if (!wfFaceDetect)
{
bool wfObjectDetect = wcBackgroundDifference(pixelsHandle.AddrOfPinnedObject(), webcamTexture.width, webcamTexture.height, scaling, 4, profileThreshold, ref wbPosX, ref wbPosY);
if (wfObjectDetect)
{
wfFaceDetect = true;
if (!wfInPerson)
{
AllManager.GetInstance().FadeInPerson();
wfInPerson = true;
wfNoPerson = false;
}
}
else
{
pixelsHandle.Free();
wbMotionDetectContinueNum++;
if (wbMotionDetectContinueNum >= 60)
{
wbMotionDetectContinueNum = 0;
if (!wfNoPerson)
{
AllManager.GetInstance().FadeOutPerson();
wfNoPerson = true;
wfInPerson = false;
}
}
return;
}
}
/***************************************************人脸检测******************************************************************/
//wc
bool wfDf = wcDetectFace(pixelsHandle.AddrOfPinnedObject(), wbArea, ref wbFaceNum, webcamTexture.width, webcamTexture.height, 4, seekScale, zoom, waveNum, capture, waveBrighte);
if (!wfDf)
{
pixelsHandle.Free();
wbMotionDetectContinueNum++;
if (wbMotionDetectContinueNum >= 100)
{
wbMotionDetectContinueNum = 0;
wfFaceDetect = false;
wbMotionDetectContinueNum = 0;
return;
}
}
else
pixelsHandle.Free();
/*********************************************************************************/
}
void DataGet()
{
if (initTime < 32f)
{
initTime++;
return;
}
else
{
initTime = 33f;
}
//人脸数量初始化
wbFaceNum = 0;
Color32[] pixels = webcamTexture.GetPixels32();
pixelsHandle = GCHandle.Alloc(pixels, GCHandleType.Pinned);
//System.Array.Reverse(pixels);
//destTex = new Texture2D(webcamTexture.width, webcamTexture.height);
//destTex.SetPixels32(pixels);
//destTex.Apply();
//go.renderer.material.mainTexture = destTex;
//人脸返回数据初始化
for (int i = 0; i < maxDetectNum; ++i)
{
wbArea[i].x = 0;
wbArea[i].y = 0;
wbArea[i].width = 0;
wbArea[i].height = 0;
}
/******************************************************行人检测***************************************************************/
//wc
if (!wfFaceDetect)
{
bool wfObjectDetect = wcBackgroundDifference(pixelsHandle.AddrOfPinnedObject(), webcamTexture.width, webcamTexture.height, scaling, 4, profileThreshold, ref wbPosX, ref wbPosY);
if (wfObjectDetect)
{
wfFaceDetect = true;
if (!wfInPerson)
{
AllManager.GetInstance().FadeInPerson();
wfInPerson = true;
wfNoPerson = false;
}
}
else
{
pixelsHandle.Free();
wbMotionDetectContinueNum++;
if (wbMotionDetectContinueNum >= 60)
{
wbMotionDetectContinueNum = 0;
if (!wfNoPerson)
{
AllManager.GetInstance().FadeOutPerson();
wfNoPerson = true;
wfInPerson = false;
}
}
return;
}
}
/***************************************************人脸检测******************************************************************/
//wc
bool wfDf = wcDetectFace(pixelsHandle.AddrOfPinnedObject(), wbArea, ref wbFaceNum, webcamTexture.width, webcamTexture.height, 4, seekScale, zoom, waveNum, capture, waveBrighte);
if (!wfDf)
{
pixelsHandle.Free();
wbMotionDetectContinueNum++;
if (wbMotionDetectContinueNum >= 100)
{
wbMotionDetectContinueNum = 0;
wfFaceDetect = false;
wbMotionDetectContinueNum = 0;
return;
}
}
else
pixelsHandle.Free();
/*********************************************************************************/
}