Skip to content

Commit

Permalink
Beta 4 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
w9jds committed Mar 27, 2014
1 parent de73431 commit cc1eacd
Show file tree
Hide file tree
Showing 17 changed files with 314 additions and 135 deletions.
346 changes: 236 additions & 110 deletions .idea/workspace.xml

Large diffs are not rendered by default.

Binary file modified Gallery4Glass.apk
Binary file not shown.
Binary file modified out/production/Gallery4Glass/Gallery4Glass.apk
Binary file not shown.
Binary file modified out/production/Gallery4Glass/Gallery4Glass.unaligned.apk
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified out/production/Gallery4Glass/org/opencv/BuildConfig.class
Binary file not shown.
9 changes: 2 additions & 7 deletions res/layout/opencvpreview_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@

<FrameLayout
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="match_parent"
android:layout_height="match_parent" >

<org.opencv.android.NativeCameraView
<com.w9jds.gallery4glass.Widget.OpenCVSurface
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="gone"
android:id="@+id/camera_preview_opencv"
opencv:show_fps="false"
opencv:camera_id="any" />
android:id="@+id/camera_preview_opencv"/>

</FrameLayout>
65 changes: 48 additions & 17 deletions src/com/w9jds/gallery4glass/CameraActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.hardware.Camera;
Expand All @@ -23,21 +21,26 @@
import com.google.android.glass.touchpad.GestureDetector;
import com.w9jds.gallery4glass.Classes.Gallery4Glass;
import com.w9jds.gallery4glass.Classes.SingleMediaScanner;
import com.w9jds.gallery4glass.Widget.PreviewSurface;
import com.w9jds.gallery4glass.Widget.OpenCVSurface;


import org.opencv.android.CameraBridgeViewBase;
import org.opencv.android.OpenCVLoader;
import org.opencv.core.Mat;

import java.io.File;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;

public class CameraActivity extends Activity
public class CameraActivity extends Activity implements CameraBridgeViewBase.CvCameraViewListener2
{
public static final String ACTION_WINK = "com.google.glass.action.EYE_GESTURE";

// Declare a new Gesture Detector
private GestureDetector mGestureDetector;
// Declare a new Camera Preview Surface
private PreviewSurface mPreviewSurface;
private OpenCVSurface mPreviewSurface;
//create an audio manager for sounds
private AudioManager maManager;
// Zoom level of the camera
Expand All @@ -50,6 +53,9 @@ public void onCreate(Bundle bSavedInstanceState)

Gallery4Glass.CameraOpened();

//start openCV manager
OpenCVLoader.initDebug();

// Turn on Gestures
mGestureDetector = createGestureDetector(this);

Expand All @@ -63,11 +69,13 @@ public void onCreate(Bundle bSavedInstanceState)

private void setPreviewSurface()
{
// Initiate CameraView
mPreviewSurface = new PreviewSurface(this);
setContentView(R.layout.opencvpreview_layout);

setContentView(mPreviewSurface);
mPreviewSurface = (OpenCVSurface) findViewById(R.id.camera_preview_opencv);

mPreviewSurface.setCvCameraViewListener(this);

mPreviewSurface.enableView();
}

@Override
Expand All @@ -77,7 +85,7 @@ protected void onResume()

// Do not hold the camera during onResume
if (mPreviewSurface != null)
mPreviewSurface.releaseCamera();
mPreviewSurface.disableView();

// Set the view
setPreviewSurface();
Expand All @@ -89,8 +97,11 @@ protected void onPause()
super.onPause();

// Do not hold the camera during onPause
// if (mPreviewSurface != null)
// mPreviewSurface.releaseCamera();

if (mPreviewSurface != null)
mPreviewSurface.releaseCamera();
mPreviewSurface.disableView();
}

private GestureDetector createGestureDetector(final Context cContext)
Expand Down Expand Up @@ -122,7 +133,7 @@ else if (gGesture == Gesture.SWIPE_DOWN)
maManager.playSoundEffect(Sounds.DISMISSED);
// If the preview surface isn't null release the camera
if (mPreviewSurface != null)
mPreviewSurface.releaseCamera();
mPreviewSurface.disableView();
// Close activity
finish();
}
Expand Down Expand Up @@ -150,7 +161,7 @@ else if (gGesture == Gesture.SWIPE_LEFT)
else if (gGesture == Gesture.TWO_SWIPE_RIGHT)
{
if (mPreviewSurface != null)
mPreviewSurface.releaseCamera();
mPreviewSurface.disableView();

Gallery4Glass.CameraClosed();

Expand All @@ -174,9 +185,6 @@ public void onShutter()
}
};

/**
* This will be called after taking picture from camera.
*/
final transient private Camera.PictureCallback jpgPictureCallback = new Camera.PictureCallback()
{
/**
Expand All @@ -189,7 +197,6 @@ public void onPictureTaken(final byte[] data, final Camera camera)
new SavePhotoTask().execute(data);
setPreviewSurface();
}

};

@Override
Expand Down Expand Up @@ -255,13 +262,37 @@ private void setupReceivers()
@Override
public void onDestroy()
{

if (mPreviewSurface != null)
mPreviewSurface.disableView();

// Unregister the Receiver
unregisterReceiver(mReceiver);
//close activity
finish();
// Run normal onDestroy
super.onDestroy();
}

class SavePhotoTask extends AsyncTask<byte[], String, String>
@Override
public void onCameraViewStarted(int width, int height)
{

}

@Override
public void onCameraViewStopped()
{

}

@Override
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame)
{
return inputFrame.rgba();
}

private class SavePhotoTask extends AsyncTask<byte[], String, String>
{
@Override
protected String doInBackground(byte[]... jpeg)
Expand Down
2 changes: 1 addition & 1 deletion src/com/w9jds/gallery4glass/Classes/StorageService.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public StorageService(Context context)
mContext = context;
try
{

mClient = new MobileServiceClient("https://glassshare.azure-mobile.net/", "hGZSWGJntAFbXLmYRitDivIhrClsgA21", mContext);
mTableContainers = mClient.getTable("blobcontainers");
mTableBlobs = mClient.getTable("blobs");
}
Expand Down
27 changes: 27 additions & 0 deletions src/com/w9jds/gallery4glass/Widget/OpenCVSurface.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.w9jds.gallery4glass.Widget;

import android.content.Context;
import android.hardware.Camera;
import android.util.AttributeSet;

import org.opencv.android.JavaCameraView;

/**
* Created by w9jds on 3/25/14.
*/
public class OpenCVSurface extends JavaCameraView
{

public OpenCVSurface(Context cContext, AttributeSet args)
{
super(cContext, args);

this.setKeepScreenOn(true);
}

public Camera getCamera()
{
return mCamera;
}

}

0 comments on commit cc1eacd

Please sign in to comment.