public FARResult Recognize(GroupOfFingers[][] arrGOF, int[][][] Prev, int n, int currentIdx, int fingerIndx, int nthGroup) { FARResult rsl = new FARResult(); rsl.Name = "NULL"; if (n < MIN_FRAME) return rsl; int prevIdx = currentIdx - 1; if (prevIdx < 0) prevIdx = arrGOF.Length - 1; if (Prev[currentIdx][nthGroup][fingerIndx] != -1) { // 2 frame lien tuc deu cham. mat. ban` if (arrGOF[currentIdx][nthGroup].Fingertips[fingerIndx].Status == true && arrGOF[prevIdx][nthGroup].Fingertips[Prev[currentIdx][nthGroup][fingerIndx]].Status == true) { rsl.Name = GetName(); rsl.Params = new object[2]; rsl.Params[0] = arrGOF[currentIdx][nthGroup].Fingertips[fingerIndx].Point2D1.X; //- arrGOF[prevIdx][nthGroup].Fingertips[Prev[currentIdx][nthGroup][fingerIndx]].Point2D1.X; rsl.Params[1] = arrGOF[currentIdx][nthGroup].Fingertips[fingerIndx].Point2D1.Y; //- arrGOF[prevIdx][nthGroup].Fingertips[Prev[currentIdx][nthGroup][fingerIndx]].Point2D1.Y; } } return rsl; }
public ARResult Recognize(FARResult[][][][] FingersStatus, int currStep, int[][][] Prev, int nGOF, int nFARPlugin) { ARResult rsl = new ARResult(); rsl.Name = "NULL"; for (int i = 0; i < nGOF; i++) { if (FingersStatus[currStep][i].Length < MIN_DETECTED_FINGER_NUM) continue; for (int j = 0; j < nFARPlugin; j++) { if (FingersStatus[currStep][i][KEY_FINGER][j].Name == "MOVE FINGER") { double x = Double.Parse(FingersStatus[currStep][i][KEY_FINGER][j].Params[0].ToString()); double y = Double.Parse(FingersStatus[currStep][i][KEY_FINGER][j].Params[1].ToString()); DEVMODE vDevMode = new DEVMODE(); EnumDisplaySettings(null, -1, ref vDevMode); double swidth = vDevMode.dmPelsWidth; double sheight = vDevMode.dmPelsHeight; double newx, newy; newx = x/320*swidth; newy = y/240*sheight; rsl.Name = GetName(); rsl.Params = new object[2]; rsl.Params[0] = (int)newx; rsl.Params[1] = (int)newy; } } } return rsl; }
public FARResult Recognize(GroupOfFingers[][] arrGOF, int[][][] Prev, int n, int currentIdx, int fingerIndx, int nthGroup) { // kiem tra hanh dong cho ngon tay fingerIndx FARResult rsl = new FARResult(); rsl.Name = "NULL"; if (n < MIN_FRAME) return rsl; int prevIdx = currentIdx - 1; if (prevIdx < 0) prevIdx = arrGOF.Length - 1; if (Prev[currentIdx][nthGroup][fingerIndx] != -1) { if (arrGOF[currentIdx][nthGroup].Fingertips[fingerIndx].Status == true && arrGOF[prevIdx][nthGroup].Fingertips[Prev[currentIdx][nthGroup][fingerIndx]].Status == false) // neu vua cham mat ban { // kiem tra xem o tren khong du lau chua int i = prevIdx; int curr = currentIdx; int currFingerIndx = fingerIndx; int cnt = 0; bool isOK = false; while (i != currentIdx) { if (arrGOF[i][nthGroup].Fingertips[Prev[curr][nthGroup][currFingerIndx]].Status == true) { isOK = true; break; } currFingerIndx = Prev[curr][nthGroup][currFingerIndx]; curr = i; // giam i i--; if (i < 0) i = arrGOF.Length - 1; cnt++; if (cnt > n || Prev[curr][nthGroup][currFingerIndx] < 0) { isOK = false; break; } } if (isOK && cnt > MIN_FRAME_UNTOUCH && cnt <= n) { rsl.Name = GetName(); rsl.Params = new object[2]; rsl.Params[0] = 100; rsl.Params[1] = 200; } } } return rsl; }
/// <summary> /// Recognize action for fingers /// </summary> public void RecognizeActionForEachFinger() { // duyet danh sach tung GOF _arrFingersAction[CurrentIdx] = new FARResult[_arrGOF[CurrentIdx].Length][][]; for (int k = 0; k < _arrGOF[CurrentIdx].Length; k++) { _arrFingersAction[CurrentIdx][k] = new FARResult[_arrGOF[CurrentIdx][k].N][]; int cnt = 0; for (int i = 0; i < _arrGOF[CurrentIdx][k].N; i++) { _arrFingersAction[CurrentIdx][k][i] = new FARResult[_N_FAR_Plugin]; cnt = 0; foreach (IFingerActionRecognizer Plugin in _FAR_Plugins) { _arrFingersAction[CurrentIdx][k][i][cnt] = Plugin.Recognize(_arrGOF, _Prev, Count, CurrentIdx, i, k); cnt++; } } } }
public ARResult Recognize(FARResult[][][][] FingersStatus, int currStep, int[][][] Prev, int nGOF, int nFARPlugin) { ARResult rsl = new ARResult(); rsl.Name = "NULL"; if (nGOF != 2) return rsl; double deltax1 = 0; double deltay1 = 0; double deltax2 = 0; double deltay2 = 0; double[] p2D1x = new double[100]; double[] p2D1y = new double[100]; double[] p2D2x = new double[100]; double[] p2D2y = new double[100]; double dist; //FingersStatus[currStep][group][j][loai finger action] for (int i = 0; i < nFARPlugin; i++) { if (FingersStatus[currStep][0].Length == 1 && FingersStatus[currStep][1].Length == 1) { bool b1 = checkMovement(FingersStatus, currStep, Prev, 0, i, ref deltax1, ref deltay1, ref p2D1x, ref p2D1y); bool b2 = checkMovement(FingersStatus, currStep, Prev, 1, i, ref deltax2, ref deltay2, ref p2D2x, ref p2D2y); if (b1 && !b2) { double vx1, vy1; double vx2, vy2; vx1 = p2D1x[0] - p2D2x[0]; vy1 = p2D1y[0] - p2D2y[0]; vx2 = p2D1x[MIN_FRAME - 1] - p2D2x[0]; vy2 = p2D1y[MIN_FRAME - 1] - p2D2y[0]; double g = goc(vx1, vy1, vx2, vy2); rsl.Name = GetName(); rsl.Params = new object[1]; rsl.Params[0] = g; return rsl; } else if (b2 && !b1) { double vx1, vy1; double vx2, vy2; vx1 = p2D2x[0] - p2D1x[0]; vy1 = p2D2y[0] - p2D1y[0]; vx2 = p2D2x[MIN_FRAME - 1] - p2D1x[0]; vy2 = p2D2y[MIN_FRAME - 1] - p2D1y[0]; double g = goc(vx1, vy1, vx2, vy2); rsl.Name = GetName(); rsl.Params = new object[1]; rsl.Params[0] = g; return rsl; } } } return rsl; }
public ARResult Recognize(FARResult[][][][] FingersStatus, int currStep, int[][][] Prev, int nGOF, int nFARPlugin) { ARResult rsl = new ARResult(); rsl.Name = "NULL"; //if (nGOF != 1) //return rsl; int cnt = 0; for (int i = 0; i < nGOF; i++) { for (int k = 0; k < (FingersStatus[currStep][i].Length); k++) { for (int j = 0; j < nFARPlugin; j++) { if (FingersStatus[currStep][i][k][j].Name == "MOVE FINGER") { cnt++; } } } } if (cnt > 0) { rsl.Name = GetName(); rsl.Params = new object[2*cnt +1]; rsl.Params[0] = cnt; cnt = 0; for (int i = 0; i < nGOF; i++) { for (int k = 0; k < (FingersStatus[currStep][i].Length); k++) { for (int j = 0; j < nFARPlugin; j++) { if (FingersStatus[currStep][i][k][j].Name == "MOVE FINGER") { cnt++; rsl.Params[cnt] = FingersStatus[currStep][i][k][j].Params[0]; cnt++; rsl.Params[cnt] = FingersStatus[currStep][i][k][j].Params[1]; } } } } return rsl; } //for (int i = 0; i < nGOF; i++) //{ // if (FingersStatus[currStep][i].Length < MIN_DETECTED_FINGER_NUM) // continue; // for (int j = 0; j < nFARPlugin; j++) // { // if (FingersStatus[currStep][i][KEY_FINGER][j].Name == "MOVE FINGER") // { // rsl.Name = GetName(); // rsl.Params = new object[2]; // rsl.Params[0] = FingersStatus[currStep][i][KEY_FINGER][j].Params[0]; // rsl.Params[1] = FingersStatus[currStep][i][KEY_FINGER][j].Params[1]; // return rsl; // } // } //} return rsl; }