for (Point point : landmarks)
{
for (int i = 48; i <= 66; i++)
{
point = landmarks.get(i);
//Log.d(TAG,"landmarks (" + landmarks.get(i) +")");
int pointX = (int) (point.x * resizeRatio);
int pointY = (int) (point.y * resizeRatio);
Log.d(TAG,"My points:(" + pointX +","+ pointY +")");
point=landmarks.get(i+1);
int pointXX = (int) (point.x * resizeRatio);
int pointYY = (int) (point.y * resizeRatio);
canvas.drawLine(pointX, pointY, pointXX, pointYY, mFaceLandmardkPaint);
}
}
从上面的代码我必须访问变量,pointX和pointY中的整数值。如何将这些值存储到文件中???
答案 0 :(得分:0)
尝试
try{
PrintWriter writer = new PrintWriter("the-file-name.txt", "UTF-8");
for (int i = 48; i <= 66; i++)
{
point = landmarks.get(i);
//Log.d(TAG,"landmarks (" + landmarks.get(i) +")");
int pointX = (int) (point.x * resizeRatio);
int pointY = (int) (point.y * resizeRatio);
Log.d(TAG,"My points:(" + pointX +","+ pointY +")");
point=landmarks.get(i+1);
int pointXX = (int) (point.x * resizeRatio);
int pointYY = (int) (point.y * resizeRatio);
canvas.drawLine(pointX, pointY, pointXX, pointYY, mFaceLandmardkPaint);
writer.println(pointX + ",+ pointY + ","+pointXX+","+pointYY);
}
writer.close();
} catch (IOException e) {
// do something
}