HiVector DriftCorrect::Solve(const HiVector &d) { ostringstream hist; _data = d; if ( _skipFit || (!gotGoodLines(d))) { _b2 = _data; _coefs = HiVector(4, 0.0); _uncert = _coefs; _cc = HiVector(2, 0.0); _chisq = 0.0; if ( !gotGoodLines(d) ) { hist << "NotEnoughLines(GoodLines[" << goodLines(d) << "],MinimumLines[" << _minLines << "]);"; } hist << "SkipFit(TRUE: Not using LMFit)"; _history.add(hist.str()); } else { hist << "Fit("; _b2 = HiVector(goodLines(_data)); if ( success(curvefit()) ) { _coefs = coefs(); _uncert = uncert(); hist << "Solved,#Iters[" << nIterations() << "],ChiSq[" << Chisq() << "],DoF[" << DoF() << "])"; _history.add(hist.str()); _history.add("a0("+ToString(_coefs[0])+"+-"+ToString(_uncert[0])+")"); _history.add("a1("+ToString(_coefs[1])+"+-"+ToString(_uncert[1])+")"); _history.add("a2("+ToString(_coefs[2])+"+-"+ToString(_uncert[2])+")"); _history.add("a3("+ToString(_coefs[3])+"+-"+ToString(_uncert[3])+")"); } else { // Punt, fit a straight line to the data _cc = poly_fit(d); HiVector a(4); a[0] = _cc[0]; a[1] = _cc[1]; a[2] = 0.0; a[3] = 0.0; _coefs = a; hist << "Failed::Reason("<< statusstr() << "),#Iters[" << nIterations() << "])"; _history.add(hist.str()); _history.add("a0("+ToString(_coefs[0])+")"); _history.add("a1("+ToString(_coefs[1])+")"); _history.add("a2("+ToString(_coefs[2])+")"); _history.add("a3("+ToString(_coefs[3])+")"); if ( _useLinFit ) { _history.add("OnFailureUse(LinearFit(Zf))"); } else { _skipFit = true; _history.add("OnFailureUse(ZfBuffer)"); } } } return (Yfit()); }
void DoDES8(A8 *InOut, A8 CharKey, int Encrypt) { A64 Temp64, Temp64_2; A32 L_1, R_1, L, R; int i, j; TKeys Key; GenKeys(CharKey, &Key); /* 生成16个子密钥*/ SeparateBits(*InOut, &Temp64); /* 将输入的8个字节各位全部取出,存放在Temp64中*/ DoIP(Temp64, &Temp64_2); /* IP置换, Temp64->Temp64_2*/ for (i = 0; i < 32; i++) /* L, R初始值为Temp64_2的高32位和低32位*/ { L_1[i] = Temp64_2[i]; R_1[i] = Temp64_2[i + 32]; } for (i = 0; i < 16; i++) /* 16次迭代*/ { if (Encrypt) DoF(R_1, &R, Key, i); /* F变换*/ else DoF(R_1, &R, Key, 15 - i); /* F变换*/ for (j = 0; j < 32; j++) { R[j] = R[j] ^ L_1[j]; L[j] = R_1[j]; L_1[j] = L[j]; R_1[j] = R[j]; } } for (i = 0; i < 32; i++) { Temp64[i] = R[i]; Temp64[i + 32] = L[i]; } DoIP_1(Temp64, &Temp64_2); /* IP-1置换*/ CombineBits(Temp64_2, InOut); /* 将64位的数据重新组合位8字节*/ }
void LoadHandParams(HandParams ¶m, char *strName) { FILE *pFile = fopen(strName, "r"); // write the hand region cv::Rect rtOBB; fscanf(pFile, "%d, %d, %d, %d\n", &rtOBB.x, &rtOBB.y, &rtOBB.width, &rtOBB.height); param.OBB = rtOBB; // write the pose parameters int nDofNum; fscanf(pFile, "%d\n", &nDofNum); std::vector<DoF> vecDofSet; for (int i = 0; i < nDofNum; i++) { char strDofName[255]; int nType; double fValue; fscanf(pFile, "%s %d %lf\n", strDofName, &nType, &fValue); vecDofSet.push_back(DoF(strDofName, (DofType)nType, fValue)); } param.DofSet = vecDofSet; // write the projected palm center and the fingertips int m, n; double x, y, z; fscanf(pFile, "%d, %d, %lf, %lf, %lf\n", &m, &n, &x, &y, &z); param.PalmCenter2D = cv::Point(m, n); param.PalmCenter3D = cv::Vec3f(x, y, z); for (int i = 0; i < 5; i++) { fscanf(pFile, "%d, %d, %lf, %lf, %lf\n", &m, &n, &x, &y, &z); param.Fingertips2D[i] = cv::Point(m, n); param.Fingertips3D[i] = cv::Vec3f(x, y, z); } fclose(pFile); }
/*********************************************************** ****************对16字节的密文进行解密********************** ***In 输入(16字节) CharKey 密匙(8字节) Out(8字节)***** ************************************************************/ void DoDecDES16(A16 *In, A8 CharKey,A8 *Out) /*void DoDecDES16(A16 In, A8 CharKey,A8 Out)*/ { A64 Temp64, Temp64_2,Temp64_3; A32 L_1, R_1, L, R; A16 Temp16; int i, j; TKeys Key; GenKeys(CharKey, &Key); /* 生成16个子密钥*/ SeparateBits16(*In, &Temp64); /* 将输入的16个字节各位全部取出,存放在Temp64中*/ /*SeparateBits16(In, &Temp64); */ DoIP(Temp64, &Temp64_2); /* IP置换, Temp64->Temp64_2*/ for (i = 0; i < 32; i++) /* L, R初始值为Temp64_2的高32位和低32位*/ { L_1[i] = Temp64_2[i]; R_1[i] = Temp64_2[i + 32]; } for (i = 0; i < 16; i++) /* 16次迭代*/ { DoF(R_1, &R, Key, 15-i); /* F变换*/ for (j = 0; j < 32; j++) { R[j] = R[j] ^ L_1[j]; L[j] = R_1[j]; L_1[j] = L[j]; R_1[j] = R[j]; } } for (i = 0; i < 32; i++) { Temp64[i] = R[i]; Temp64[i + 32] = L[i]; } DoIP_1(Temp64, &Temp64_2); /* IP-1置换*/ CombineBits(Temp64_2, Out); /* 将64位的数据重新组合位8字节*/ }