Skip to content
Snippets Groups Projects
Commit b39f66ce authored by Aylen Ricca's avatar Aylen Ricca
Browse files

save image to file

parent 3f0f0006
Branches backup
No related tags found
No related merge requests found
......@@ -40,6 +40,7 @@
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
......
......@@ -194,6 +194,7 @@ public class ChessTrackActivity extends Activity implements
case CALIBRAR:
Log.i(TAG, "calibrando...");
if (_manager.calibrar(inputFrame)) {
_manager.iniciarJuego();
_estado = JUGAR;
} else {
_estado = IDLE;
......
package uy.edu.fing.chesstrack.modulovision;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.highgui.Highgui;
import org.opencv.imgproc.Imgproc;
import uy.edu.fing.chesstrack.ajedrez.Logica;
import uy.edu.fing.chesstrack.communication.Client;
import uy.edu.fing.chesstrack.modulomodelador.Modelador;
import android.media.AudioManager;
import android.media.ToneGenerator;
import android.os.Environment;
import android.util.Log;
public class Manager {
......@@ -124,12 +131,13 @@ public class Manager {
break;
case JUGANDO:
Log.i(TAG, "Jugando");
if (_detectorOclusion.hayNuevoTableroValido(region)) {
//if (_detectorOclusion.hayNuevoTableroValido(region)) {
Log.i(TAG, "Tablero Valido");
// llamar al modelador
Mat aux = _modelador.getMatrizFichas(region);
// Log.i(TAG, "MATRIZ=" + aux.dump());
// region = _modelador.dibujarEscaquesSobel(2);
region = _modelador.dibujarEscaquesSobel(1);
SaveImage(region);
if (_logica.validarNuevoTablero(aux)) {
if (_salida == OK) {
......@@ -139,7 +147,7 @@ public class Manager {
_client.SendData(" ".concat(aux.dump().concat("\n")));
}
}
}
//}
break;
}
......@@ -158,4 +166,22 @@ public class Manager {
_client.Stop();
}
}
public void SaveImage (Mat mat) {
Mat mIntermediateMat = new Mat();
Imgproc.cvtColor(mat, mIntermediateMat, Imgproc.COLOR_RGBA2BGR, 3);
File path = new File(Environment.getExternalStorageDirectory() + "/DCIM/");
path.mkdirs();
String timeStamp = Integer.toString(_cantJugada++);
File file = new File(path, "image".concat(timeStamp).concat(".png"));
String filename = file.toString();
Boolean bool = Highgui.imwrite(filename, mIntermediateMat);
if (bool)
Log.i(TAG, "SUCCESS writing image to external storage");
else
Log.i(TAG, "Fail writing image to external storage");
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment