Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • aricca/chessTrack
  • nicolas.furquez/chessTrack
2 results
Show changes
Commits on Source (65)
Showing
with 713 additions and 0 deletions
# generic files to ignore
*~
# Directories #
ProyectoAndroid/ChessTrack/bin/*
ProyectoAndroid/ChessTrack/gen/*
#java specific
*.class
# Package Files #
*.jar
*.war
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ChessTrack</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.source=1.6
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="uy.edu.fing.chesstrack"
android:versionCode="1"
android:versionName="1.0" >
<!-- <application -->
<!-- android:allowBackup="true" -->
<!-- android:icon="@drawable/ic_launcher" -->
<!-- android:label="@string/app_name" -->
<!-- android:theme="@style/AppTheme" > -->
<!-- </application> -->
<application
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<activity android:name="ChessTrackActivity"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:configChanges="keyboardHidden|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<supports-screens android:resizeable="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:anyDensity="true" />
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
<uses-feature android:name="android.hardware.camera.front" android:required="false"/>
<uses-feature android:name="android.hardware.camera.front.autofocus" android:required="false"/>
</manifest>
/** Automatically generated file. DO NOT MODIFY */
package uy.edu.fing.chesstrack;
public final class BuildConfig {
public final static boolean DEBUG = true;
}
\ No newline at end of file
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package uy.edu.fing.chesstrack;
public final class R {
public static final class attr {
/** <p>May be an integer value, such as "<code>100</code>".
<p>This may also be a reference to a resource (in the form
"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
theme attribute (in the form
"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
containing a value of this type.
<p>May be one of the following constant values.</p>
<table>
<colgroup align="left" />
<colgroup align="left" />
<colgroup align="left" />
<tr><th>Constant</th><th>Value</th><th>Description</th></tr>
<tr><td><code>any</code></td><td>-1</td><td></td></tr>
<tr><td><code>back</code></td><td>99</td><td></td></tr>
<tr><td><code>front</code></td><td>98</td><td></td></tr>
</table>
*/
public static final int camera_id=0x7f010001;
/** <p>Must be a boolean value, either "<code>true</code>" or "<code>false</code>".
<p>This may also be a reference to a resource (in the form
"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
theme attribute (in the form
"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
containing a value of this type.
*/
public static final int show_fps=0x7f010000;
}
public static final class drawable {
public static final int ic_launcher=0x7f020000;
}
public static final class id {
public static final int any=0x7f040000;
public static final int back=0x7f040001;
public static final int chess_track_layout=0x7f040003;
public static final int front=0x7f040002;
}
public static final class layout {
public static final int chess_track_layout=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f050000;
public static final int menu_start_new_game=0x7f050002;
public static final int menu_toggle_tile_numbers=0x7f050001;
}
public static final class style {
/**
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
*/
public static final int AppBaseTheme=0x7f060000;
/** Application theme.
All customizations that are NOT specific to a particular API-level can go here.
*/
public static final int AppTheme=0x7f060001;
}
public static final class styleable {
/** Attributes that can be used with a CameraBridgeViewBase.
<p>Includes the following attributes:</p>
<table>
<colgroup align="left" />
<colgroup align="left" />
<tr><th>Attribute</th><th>Description</th></tr>
<tr><td><code>{@link #CameraBridgeViewBase_camera_id uy.edu.fing.chesstrack:camera_id}</code></td><td></td></tr>
<tr><td><code>{@link #CameraBridgeViewBase_show_fps uy.edu.fing.chesstrack:show_fps}</code></td><td></td></tr>
</table>
@see #CameraBridgeViewBase_camera_id
@see #CameraBridgeViewBase_show_fps
*/
public static final int[] CameraBridgeViewBase = {
0x7f010000, 0x7f010001
};
/**
<p>This symbol is the offset where the {@link uy.edu.fing.chesstrack.R.attr#camera_id}
attribute's value can be found in the {@link #CameraBridgeViewBase} array.
<p>May be an integer value, such as "<code>100</code>".
<p>This may also be a reference to a resource (in the form
"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
theme attribute (in the form
"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
containing a value of this type.
<p>May be one of the following constant values.</p>
<table>
<colgroup align="left" />
<colgroup align="left" />
<colgroup align="left" />
<tr><th>Constant</th><th>Value</th><th>Description</th></tr>
<tr><td><code>any</code></td><td>-1</td><td></td></tr>
<tr><td><code>back</code></td><td>99</td><td></td></tr>
<tr><td><code>front</code></td><td>98</td><td></td></tr>
</table>
@attr name uy.edu.fing.chesstrack:camera_id
*/
public static final int CameraBridgeViewBase_camera_id = 1;
/**
<p>This symbol is the offset where the {@link uy.edu.fing.chesstrack.R.attr#show_fps}
attribute's value can be found in the {@link #CameraBridgeViewBase} array.
<p>Must be a boolean value, either "<code>true</code>" or "<code>false</code>".
<p>This may also be a reference to a resource (in the form
"<code>@[<i>package</i>:]<i>type</i>:<i>name</i></code>") or
theme attribute (in the form
"<code>?[<i>package</i>:][<i>type</i>:]<i>name</i></code>")
containing a value of this type.
@attr name uy.edu.fing.chesstrack:show_fps
*/
public static final int CameraBridgeViewBase_show_fps = 0;
};
}
ProyectoAndroid/ChessTrack/ic_launcher-web.png

264 KiB

<?xml version="1.0" encoding="UTF-8"?>
<lint>
</lint>
\ No newline at end of file
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-10
android.library=false
android.library.reference.1=../../../../Android/OpenCV4Android/OpenCV-2.4.9-android-sdk/sdk/java
ProyectoAndroid/ChessTrack/res/drawable-hdpi/ic_launcher.png

8.54 KiB

ProyectoAndroid/ChessTrack/res/drawable-mdpi/ic_launcher.png

4.24 KiB

ProyectoAndroid/ChessTrack/res/drawable-xhdpi/ic_launcher.png

13.6 KiB

ProyectoAndroid/ChessTrack/res/drawable-xxhdpi/ic_launcher.png

27.4 KiB

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:opencv="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<org.opencv.android.JavaCameraView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="gone"
android:id="@+id/chess_track_layout"
opencv:show_fps="true"
opencv:camera_id="any" />
</LinearLayout>
\ No newline at end of file
<resources>
<string name="app_name">ChessTrack</string>
<string name="menu_toggle_tile_numbers">Show/hide tile numbers</string>
<string name="menu_start_new_game">Start new game</string>
</resources>
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
package uy.edu.fing.chesstrack;
import org.opencv.android.BaseLoaderCallback;
import org.opencv.android.CameraBridgeViewBase;
import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener;
import org.opencv.android.JavaCameraView;
import org.opencv.android.LoaderCallbackInterface;
import org.opencv.android.OpenCVLoader;
import org.opencv.core.Mat;
import uy.edu.fing.chesstrack.modulovision.Manager;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.text.Editable;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SurfaceView;
import android.view.WindowManager;
import android.widget.EditText;
public class ChessTrackActivity extends Activity implements
CvCameraViewListener {
private static final String TAG = "CHESSTRACK::Activity";
private static final String IPV4_REGEX = "^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$";
private static final String PORT_REGEX = "^(\\d{4,5})$";
// estados
private static final int IDLE = 0;
private static final int CALIBRAR = 1;
private static final int JUGAR = 2;
private CameraBridgeViewBase _mOpenCvCameraView;
// private JavaCameraView _mOpenCvCameraView;
private Manager _manager;
private MenuItem _mItemCalibrar;
private MenuItem _mItemServer;
private int _estado;
private final BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(
this) {
@Override
public void onManagerConnected(int status) {
switch (status) {
case LoaderCallbackInterface.SUCCESS: {
Log.i(TAG, "OpenCV loaded successfully");
_mOpenCvCameraView.enableView();
}
break;
default: {
super.onManagerConnected(status);
}
break;
}
}
};
@Override
public void onResume() {
super.onResume();
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_9, this,
mLoaderCallback);
}
@Override
public void onCreate(Bundle savedInstanceState) {
Log.i(TAG, "called onCreate");
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.chess_track_layout);
_mOpenCvCameraView = (JavaCameraView) findViewById(R.id.chess_track_layout);
_mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
_mOpenCvCameraView.setCvCameraViewListener(this);
_manager = Manager.getInstance();
}
public void getServerIp() {
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Communication Setup");
alert.setMessage("Set server ip");
final EditText input = new EditText(this);
alert.setView(input);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
Editable value = input.getText();
if (value == null || value.toString().equals("")
|| !value.toString().matches(IPV4_REGEX)) {
Log.i(TAG, "INPUT= not valid IP" + value.toString());
getServerIp();
} else {
Log.i(TAG, "INPUT=" + value.toString());
Log.i(TAG, "IP=" + value.toString());
getServerPort(value.toString());
}
}
});
alert.show();
}
public void getServerPort(final String ip) {
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Communication Setup");
alert.setMessage("Set server port");
final EditText input = new EditText(this);
alert.setView(input);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
Editable value = input.getText();
Log.i(TAG, "INPUT=" + value.toString());
if (value == null || value.toString().equals("")
|| !value.toString().matches(PORT_REGEX)) {
Log.i(TAG, "INPUT= not valid PORT" + value.toString());
getServerPort(ip);
} else {
Log.i(TAG, "INPUT=" + value.toString());
int port = Integer.parseInt(value.toString());
Log.i(TAG, "PORT=" + port);
_manager.setConnection(ip, port);
}
}
});
alert.show();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
Log.i(TAG, "called onCreateOptionsMenu");
_mItemCalibrar = menu.add("Calibrar..");
_mItemServer = menu.add("Conectar Server");
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Log.i(TAG, "Menu Item selected " + item);
if (item == _mItemCalibrar) {
if (_estado == IDLE) {
_estado = CALIBRAR;
}
} else if (item == _mItemServer) {
getServerIp();
}
return true;
}
@Override
public void onPause() {
super.onPause();
if (_mOpenCvCameraView != null) {
_mOpenCvCameraView.disableView();
}
}
@Override
public void onDestroy() {
super.onDestroy();
if (_mOpenCvCameraView != null) {
_mOpenCvCameraView.disableView();
}
if (_manager != null) {
_manager.destroy();
}
}
@Override
public void onCameraViewStarted(int width, int height) {
}
@Override
public void onCameraViewStopped() {
}
@Override
public Mat onCameraFrame(Mat inputFrame) {
if (inputFrame != null) {
switch (_estado) {
case CALIBRAR:
Log.i(TAG, "calibrando...");
if (_manager.calibrar(inputFrame)) {
_estado = JUGAR;
} else {
_estado = IDLE;
}
break;
case JUGAR:
Log.i(TAG, "jugando...");
_manager.processFrame(inputFrame);
break;
case IDLE:
break;
}
}
return inputFrame;
}
}