|
|
|
@ -1,5 +1,7 @@ |
|
|
|
|
package org.opencv.samples.tutorial5; |
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.ListIterator; |
|
|
|
|
|
|
|
|
@ -9,6 +11,7 @@ import org.opencv.android.OpenCVLoader; |
|
|
|
|
import org.opencv.core.Mat; |
|
|
|
|
import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener; |
|
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint; |
|
|
|
|
import android.app.Activity; |
|
|
|
|
import android.os.Bundle; |
|
|
|
|
import android.os.Environment; |
|
|
|
@ -125,10 +128,14 @@ public class Sample5CameraControl extends Activity implements CvCameraViewListen |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@SuppressLint("SimpleDateFormat") |
|
|
|
|
@Override |
|
|
|
|
public boolean onTouch(View v, MotionEvent 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); |
|
|
|
|
Toast.makeText(this, fileName + " saved", Toast.LENGTH_SHORT).show(); |
|
|
|
|
return false; |
|
|
|
|