- FaceTracker.csに書き足す
private void ScalePoints(int startIndex, int endIndex, float scale)
{
int pointNum = endIndex - startIndex + 1;
double xSum = 0;
double ySum = 0;
for (int i = startIndex; i <= endIndex; i++)
{
xSum += points[0][i].x;
ySum += points[0][i].y;
}
double xMean = xSum / pointNum;
double yMean = ySum / pointNum;
// scale from mean
for (int i = startIndex; i <= endIndex; i++)
{
double relativeX = points[0][i].x - xMean;
double relativeY = points[0][i].y - yMean;
relativeX *= scale;
relativeY *= scale;
points[0][i].x = relativeX + xMean;
points[0][i].y = relativeY + yMean;
}
}
- 平均をとってそこを中心にスケールさせる
- 片方の眉毛の領域を拡大したい時は、
- ScalePoints(15, 20, 2.2f);
- 顔は1つを想定
- ハマりポイント
- points[0][i].xと書く必要がある
- points[i]で二次元ベクトルが取れると思ったが違った
- 想定通り動くことを確認した