Date and time added to saved file name.
This commit is contained in:
parent
22484872fa
commit
d550f95347
@ -1,5 +1,7 @@
|
|||||||
package org.opencv.samples.tutorial5;
|
package org.opencv.samples.tutorial5;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
|
|
||||||
@ -9,6 +11,7 @@ import org.opencv.android.OpenCVLoader;
|
|||||||
import org.opencv.core.Mat;
|
import org.opencv.core.Mat;
|
||||||
import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener;
|
import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
@ -125,10 +128,14 @@ public class Sample5CameraControl extends Activity implements CvCameraViewListen
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SimpleDateFormat")
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
Log.i(TAG,"onTouch event");
|
Log.i(TAG,"onTouch event");
|
||||||
String fileName = Environment.getExternalStorageDirectory().getPath() + "/sample_picture.jpg";
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
|
||||||
|
String currentDateandTime = sdf.format(new Date());
|
||||||
|
String fileName = Environment.getExternalStorageDirectory().getPath() +
|
||||||
|
"/sample_picture_" + currentDateandTime + ".jpg";
|
||||||
mOpenCvCameraView.takePicture(fileName);
|
mOpenCvCameraView.takePicture(fileName);
|
||||||
Toast.makeText(this, fileName + " saved", Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, fileName + " saved", Toast.LENGTH_SHORT).show();
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user