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

fin merge

parents 9984770b 9b8cf2b2
Branches communication
No related tags found
No related merge requests found
......@@ -38,6 +38,7 @@ public class ChessTrackActivity extends Activity implements CvCameraViewListener
+ " Aylen Ricca - Nicolas Furquez\n"
+ "--------------------------------------------------------------------------\n";
// private CameraBridgeViewBase mOpenCvCameraView;
private CameraBridgeViewBase mOpenCvCameraView;
private Adquisicion adq;
......@@ -84,6 +85,7 @@ public class ChessTrackActivity extends Activity implements CvCameraViewListener
mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.chess_track_layout);
mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
mOpenCvCameraView.setCvCameraViewListener(this);
Modelador.getInstance();
try {
isUsed = false;
......@@ -150,9 +152,9 @@ public class ChessTrackActivity extends Activity implements CvCameraViewListener
int port = Integer.parseInt(value.toString());
Log.i(TAG,"PORT=" + port);
ClientCommunication = Client.getInstance();
ClientCommunication.EstablishConnection(ip, port);
ClientCommunication.SendData(welcomeMSG);
//ClientCommunication = Client.getInstance();
//ClientCommunication.EstablishConnection(ip, port);
//ClientCommunication.SendData(welcomeMSG);
}
}
});
......
......@@ -25,10 +25,10 @@ public class Adquisicion {
Log.i(TAG, "Cargado....");
listProc = new ArrayList<ImgProcInterface>();
//listProc.add( new Homografia());
listProc.add( new Homografia());
//listProc.add( new EcualizarImagen());
//listProc.add( new SustraccionDeFondo());
listProc.add( new BackgroundSupress());
//listProc.add( new BackgroundSupress());
}
......
......@@ -9,6 +9,7 @@ import org.opencv.core.Size;
import org.opencv.imgproc.Imgproc;
import uy.edu.fing.chesstrack.modulovision.Calibracion;
import android.util.Log;
public class Homografia implements ImgProcInterface {
......@@ -23,42 +24,26 @@ public class Homografia implements ImgProcInterface {
if (vertices != null){
Mat src = new Mat(4,1,CvType.CV_32FC2);
Mat dst = new Mat(4,1,CvType.CV_32FC2);
Point p1,p2,p3,p4;
p1 = vertices.toList().get(0);
p2 = vertices.toList().get(6);
p3 = vertices.toList().get(42);
p4 = vertices.toList().get(48);
offset = (media/7);
Point p1, p2, p3, p4;
Point[] ret = getBestPoints(vertices, Calibracion.getInstance().getImagenCalibrada().size());
Log.i(TAG, "coso= " + ret);
p1 = ret[0];
p2 = ret[1];
p3 = ret[2];
p4 = ret[3];
double d17 = Math.sqrt(Math.pow((p1.x- p2.x),2) + Math.pow((p1.y- p2.y),2));
double d749 = Math.sqrt(Math.pow((p2.x- p4.x),2) + Math.pow((p2.y- p4.y),2));
double d143 = Math.sqrt(Math.pow((p1.x- p3.x),2) + Math.pow((p1.y- p3.y),2));
double d4349 = Math.sqrt(Math.pow((p3.x- p4.x),2) + Math.pow((p3.y- p4.y),2));
double d749 = Math.sqrt(Math.pow((p2.x- p3.x),2) + Math.pow((p2.y- p3.y),2));
double d143 = Math.sqrt(Math.pow((p3.x- p4.x),2) + Math.pow((p3.y- p4.y),2));
double d4349 = Math.sqrt(Math.pow((p4.x- p1.x),2) + Math.pow((p4.y- p1.y),2));
media = (int) Math.floor( Math.round((d17+d749+d143+d4349)/4));
offset = 2*(media/7);
// offset = (media/7);
// Point p1, p2, p3, p4;
// Point[] ret = getBestPoints(vertices, Calibracion.getInstance().getImagenCalibrada().size());
// Log.i(TAG, "coso= " + ret);
// p1 = ret[0];
// p2 = ret[1];
// p3 = ret[2];
// p4 = ret[3];
//
// double corner_width = Math.abs(Math.sqrt(Math.pow((p1.x- p2.x),2) + Math.pow((p1.y- p2.y),2))/7);
// double corner_height = corner_width;
//
// double real_left_x = 0 + corner_width;
// double real_right_x = 0 + 9 * corner_width;
// double real_top_y = 0 + corner_height;
// double real_bottom_y = 0 + 9 * corner_height;
src.put(0,0 ,(int)p1.x,(int)p1.y, (int)p2.x,(int)p2.y, (int)p3.x,(int)p3.y, (int)p4.x,(int)p4.y);
// dst.put(0,0, real_left_x ,real_top_y ,real_right_x ,real_top_y, real_right_x,real_bottom_y, real_left_x,real_bottom_y );
dst.put(0,0, offset,offset ,offset+media,offset , offset,offset+media , offset+media,offset+media );
// Log.i(TAG, "corner_width= " + corner_width);
// Log.i(TAG, "corner_height = " + corner_height);
dst.put(0,0, offset,offset ,offset+media,offset , offset+media,offset+media, offset,offset+media );
// EL offset es casi el tamaño de una celda
//rectPOI = new Rect(new Point(0,0), new Point(9*corner_width,9*corner_height) );
rectPOI = new Rect(new Point(0,0), new Point(2*offset+media,2*offset+media) );
Calibracion.getInstance().setRectPOI(rectPOI);
matrizTransformada = Imgproc.getPerspectiveTransform(src,dst);
......@@ -72,16 +57,14 @@ public class Homografia implements ImgProcInterface {
@Override
public Mat procesarImagen(Mat inputFrame) {
Imgproc.warpPerspective(inputFrame,inputFrame, matrizTransformada, inputFrame.size(),(Imgproc.INTER_LINEAR | Imgproc.CV_WARP_FILL_OUTLIERS));
Log.i(TAG, "before");
Imgproc.warpPerspective(inputFrame,inputFrame, matrizTransformada, inputFrame.size());
Mat subMat = inputFrame.submat(rectPOI);
Mat tmp = Mat.zeros(inputFrame.size(), CvType.CV_8UC4);
Mat matTMP = tmp.submat(rectPOI);
subMat.copyTo(matTMP);
Log.i(TAG, "after");
return tmp;
//Core.circle(inputFrame, new Point(offset,offset), offset, new Scalar(0,0 , 255, 255));
//Core.circle(inputFrame, new Point(offset,offset), 5, new Scalar(0,255, 0, 255));
// return inputFrame;
}
private Point[] getBestPoints(MatOfPoint2f vertices, Size tamanio){
......@@ -91,9 +74,7 @@ public class Homografia implements ImgProcInterface {
double betst_dist = Double.MAX_VALUE;
Point aux = new Point(0,0);
for(Point pt : vertices.toList()){
// dx = pt.x-aux.x;
// dy= pt.y -aux.y;
// d = dx*dx + dy*dy;
d = Math.sqrt(Math.pow((pt.x- aux.x),2) + Math.pow((pt.y- aux.y),2));
if (d < betst_dist){
betst_dist = d;
......@@ -104,9 +85,6 @@ public class Homografia implements ImgProcInterface {
betst_dist = Double.MAX_VALUE;
aux = new Point(tamanio.width,0);
for(Point pt : vertices.toList()){
// dx = pt.x - aux.x;
// dy= pt.y -aux.y;
// d = dx*dx + dy*dy;
d = Math.sqrt(Math.pow((pt.x- aux.x),2) + Math.pow((pt.y- aux.y),2));
if (d < betst_dist){
betst_dist = d;
......@@ -117,9 +95,6 @@ public class Homografia implements ImgProcInterface {
betst_dist = Double.MAX_VALUE;
aux = new Point(tamanio.width,tamanio.height);
for(Point pt : vertices.toList()){
// dx = pt.x-aux.x;
// dy= pt.y -aux.y;
// d = dx*dx + dy*dy;
d = Math.sqrt(Math.pow((pt.x- aux.x),2) + Math.pow((pt.y- aux.y),2));
if (d < betst_dist){
betst_dist = d;
......@@ -130,9 +105,6 @@ public class Homografia implements ImgProcInterface {
betst_dist = Double.MAX_VALUE;
aux = new Point(0,tamanio.height);
for(Point pt : vertices.toList()){
// dx = pt.x-aux.x;
// dy= pt.y -aux.y;
// d = dx*dx + dy*dy;
d = Math.sqrt(Math.pow((pt.x- aux.x),2) + Math.pow((pt.y- aux.y),2));
if (d < betst_dist){
betst_dist = d;
......
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