Commit f7c17493 authored by Ethan Rublee's avatar Ethan Rublee

Bringing the CVCamera up to speed with new changes to android-jni - added…

Bringing the CVCamera up to speed with new changes to android-jni - added settings and centered the camera.
parent 04a428c1
...@@ -13,6 +13,12 @@ ...@@ -13,6 +13,12 @@
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name="com.opencv.camera.CameraConfig" android:label="@string/app_name"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden|keyboard">
</activity>
</application> </application>
......
...@@ -11,7 +11,9 @@ $(info ERROR local environement not setup! try:) ...@@ -11,7 +11,9 @@ $(info ERROR local environement not setup! try:)
$(info gedit $(LOCAL_ENV_MK)) $(info gedit $(LOCAL_ENV_MK))
$(error Please setup the $(LOCAL_ENV_MK) - the default was just created') $(error Please setup the $(LOCAL_ENV_MK) - the default was just created')
endif endif
ifndef ARM_TARGETS
ARM_TARGETS=armeabi armeabi-v7a
endif
ANDROID_NDK_BASE = $(ANDROID_NDK_ROOT) ANDROID_NDK_BASE = $(ANDROID_NDK_ROOT)
$(info OPENCV_CONFIG = $(OPENCV_CONFIG)) $(info OPENCV_CONFIG = $(OPENCV_CONFIG))
...@@ -46,7 +48,8 @@ SWIG_C_OUT = $(SWIG_C_DIR)/cvcamera_swig.cpp ...@@ -46,7 +48,8 @@ SWIG_C_OUT = $(SWIG_C_DIR)/cvcamera_swig.cpp
BUILD_DEFS=OPENCV_CONFIG=$(OPENCV_CONFIG) \ BUILD_DEFS=OPENCV_CONFIG=$(OPENCV_CONFIG) \
PROJECT_PATH=$(PROJECT_PATH) \ PROJECT_PATH=$(PROJECT_PATH) \
V=$(V) \ V=$(V) \
$(NDK_FLAGS) $(NDK_FLAGS) \
ARM_TARGETS=$(ARM_TARGETS)
# The real native library stripped of symbols # The real native library stripped of symbols
LIB = libs/armeabi-v7a/$(LIBNAME) libs/armeabi/$(LIBNAME) LIB = libs/armeabi-v7a/$(LIBNAME) libs/armeabi/$(LIBNAME)
......
# The ARMv7 is significanly faster due to the use of the hardware FPU # The ARMv7 is significanly faster due to the use of the hardware FPU
APP_ABI := armeabi armeabi-v7a APP_ABI := $(ARM_TARGETS)
\ No newline at end of file \ No newline at end of file
This diff is collapsed.
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
#include <opencv2/imgproc/imgproc.hpp> #include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/calib3d/calib3d.hpp> #include <opencv2/calib3d/calib3d.hpp>
#include <vector> #include <vector>
#include "image_pool.h" #include "image_pool.h"
...@@ -24,19 +22,8 @@ ...@@ -24,19 +22,8 @@
#define DETECT_STAR 1 #define DETECT_STAR 1
#define DETECT_SURF 2 #define DETECT_SURF 2
class Processor { class Processor
{
cv::StarFeatureDetector stard;
cv::FastFeatureDetector fastd;
cv::SurfFeatureDetector surfd;
std::vector<cv::KeyPoint> keypoints;
vector<vector<Point2f> > imagepoints;
cv::Mat K;
cv::Mat distortion;
cv::Size imgsize;
//image_pool pool;
public: public:
Processor(); Processor();
...@@ -44,7 +31,7 @@ public: ...@@ -44,7 +31,7 @@ public:
void detectAndDrawFeatures(int idx, image_pool* pool, int feature_type); void detectAndDrawFeatures(int idx, image_pool* pool, int feature_type);
bool detectAndDrawChessboard(int idx,image_pool* pool); bool detectAndDrawChessboard(int idx, image_pool* pool);
void resetChess(); void resetChess();
...@@ -53,7 +40,16 @@ public: ...@@ -53,7 +40,16 @@ public:
void calibrate(const char* filename); void calibrate(const char* filename);
void drawText(int idx, image_pool* pool, const char* text); void drawText(int idx, image_pool* pool, const char* text);
private:
cv::StarFeatureDetector stard;
cv::FastFeatureDetector fastd;
cv::SurfFeatureDetector surfd;
std::vector<cv::KeyPoint> keypoints;
std::vector<std::vector<cv::Point2f> > imagepoints;
cv::Mat K;
cv::Mat distortion;
cv::Size imgsize;
}; };
......
#location of android-opencv port of OpenCV to android #location of android-opencv port of OpenCV to android
OPENCV_CONFIG=../../build/android-opencv.mk OPENCV_CONFIG=../../build/android-opencv.mk
ANDROID_NDK_ROOT=$(HOME)/android-ndk-r4-crystax ANDROID_NDK_ROOT=$(HOME)/android-ndk-r4-crystax
ARM_TARGETS=armeabi armeabi-v7a
...@@ -10,6 +10,7 @@ import android.app.AlertDialog; ...@@ -10,6 +10,7 @@ import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
...@@ -20,16 +21,16 @@ import android.view.Menu; ...@@ -20,16 +21,16 @@ import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.ViewGroup.LayoutParams;
import android.widget.AnalogClock;
import android.widget.Button; import android.widget.Button;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.Toast; import android.widget.Toast;
import com.opencv.camera.CameraConfig;
import com.opencv.camera.NativePreviewer; import com.opencv.camera.NativePreviewer;
import com.opencv.camera.NativeProcessor; import com.opencv.camera.NativeProcessor;
import com.opencv.camera.NativeProcessor.PoolCallback; import com.opencv.camera.NativeProcessor.PoolCallback;
...@@ -77,12 +78,11 @@ public class CVCamera extends Activity { ...@@ -77,12 +78,11 @@ public class CVCamera extends Activity {
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
break; break;
case DIALOG_TUTORIAL_CHESS: case DIALOG_TUTORIAL_CHESS:
Toast Toast.makeText(
.makeText(
this, this,
"Calibration Mode, Point at a chessboard pattern and press the camera button, space," "Calibration Mode, Point at a chessboard pattern and press the camera button, space,"
+ "or the DPAD to capture.", + "or the DPAD to capture.", Toast.LENGTH_LONG)
Toast.LENGTH_LONG).show(); .show();
break; break;
default: default:
...@@ -110,8 +110,9 @@ public class CVCamera extends Activity { ...@@ -110,8 +110,9 @@ public class CVCamera extends Activity {
private Dialog makeCalibFileAlert() { private Dialog makeCalibFileAlert() {
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(calib_text).setTitle( builder.setMessage(calib_text)
"camera.yml at " + calib_file_loc).setCancelable(false) .setTitle("camera.yml at " + calib_file_loc)
.setCancelable(false)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() { .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
...@@ -187,6 +188,7 @@ public class CVCamera extends Activity { ...@@ -187,6 +188,7 @@ public class CVCamera extends Activity {
menu.add("STAR"); menu.add("STAR");
menu.add("SURF"); menu.add("SURF");
menu.add("Chess"); menu.add("Chess");
menu.add("Settings");
return true; return true;
} }
...@@ -224,7 +226,14 @@ public class CVCamera extends Activity { ...@@ -224,7 +226,14 @@ public class CVCamera extends Activity {
} }
else if (item.getTitle().equals("Settings")) {
Intent intent = new Intent(this,CameraConfig.class);
startActivity(intent);
}
mPreview.addCallbackStack(defaultcallbackstack); mPreview.addCallbackStack(defaultcallbackstack);
return true; return true;
} }
...@@ -234,7 +243,6 @@ public class CVCamera extends Activity { ...@@ -234,7 +243,6 @@ public class CVCamera extends Activity {
super.onOptionsMenuClosed(menu); super.onOptionsMenuClosed(menu);
} }
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -263,16 +271,20 @@ public class CVCamera extends Activity { ...@@ -263,16 +271,20 @@ public class CVCamera extends Activity {
glview = new GL2CameraViewer(getApplication(), false, 0, 0); glview = new GL2CameraViewer(getApplication(), false, 0, 0);
glview.setZOrderMediaOverlay(true); glview.setZOrderMediaOverlay(true);
glview.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT)); LinearLayout gllay = new LinearLayout(getApplication());
gllay.setGravity(Gravity.CENTER);
gllay.addView(glview, params);
frame.addView(gllay);
ImageButton capture_button = new ImageButton(getApplicationContext()); ImageButton capture_button = new ImageButton(getApplicationContext());
capture_button.setImageDrawable(getResources().getDrawable(android.R.drawable.ic_menu_camera)); capture_button.setImageDrawable(getResources().getDrawable(
capture_button.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, android.R.drawable.ic_menu_camera));
LayoutParams.WRAP_CONTENT)); capture_button.setLayoutParams(new LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
capture_button.setOnClickListener(new View.OnClickListener() { capture_button.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
captureChess = true; captureChess = true;
...@@ -287,8 +299,8 @@ public class CVCamera extends Activity { ...@@ -287,8 +299,8 @@ public class CVCamera extends Activity {
buttons.addView(capture_button); buttons.addView(capture_button);
Button focus_button = new Button(getApplicationContext()); Button focus_button = new Button(getApplicationContext());
focus_button.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, focus_button.setLayoutParams(new LayoutParams(
LayoutParams.WRAP_CONTENT)); LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
focus_button.setText("Focus"); focus_button.setText("Focus");
focus_button.setOnClickListener(new View.OnClickListener() { focus_button.setOnClickListener(new View.OnClickListener() {
...@@ -299,17 +311,14 @@ public class CVCamera extends Activity { ...@@ -299,17 +311,14 @@ public class CVCamera extends Activity {
}); });
buttons.addView(focus_button); buttons.addView(focus_button);
frame.addView(glview);
frame.addView(buttons); frame.addView(buttons);
setContentView(frame); setContentView(frame);
toasts(DIALOG_OPENING_TUTORIAL); toasts(DIALOG_OPENING_TUTORIAL);
} }
@Override @Override
public boolean onTrackballEvent(MotionEvent event) { public boolean onTrackballEvent(MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_UP){ if (event.getAction() == MotionEvent.ACTION_UP) {
captureChess = true; captureChess = true;
return true; return true;
} }
...@@ -320,8 +329,7 @@ public class CVCamera extends Activity { ...@@ -320,8 +329,7 @@ public class CVCamera extends Activity {
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();
// clears the callback stack
//clears the callback stack
mPreview.onPause(); mPreview.onPause();
glview.onPause(); glview.onPause();
...@@ -332,9 +340,9 @@ public class CVCamera extends Activity { ...@@ -332,9 +340,9 @@ public class CVCamera extends Activity {
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
glview.onResume(); glview.onResume();
mPreview.setParamsFromPrefs(getApplicationContext());
//add an initiall callback stack to the preview on resume... // add an initiall callback stack to the preview on resume...
//this one will just draw the frames to opengl // this one will just draw the frames to opengl
LinkedList<NativeProcessor.PoolCallback> cbstack = new LinkedList<PoolCallback>(); LinkedList<NativeProcessor.PoolCallback> cbstack = new LinkedList<PoolCallback>();
cbstack.add(glview.getDrawCallback()); cbstack.add(glview.getDrawCallback());
mPreview.addCallbackStack(cbstack); mPreview.addCallbackStack(cbstack);
...@@ -363,7 +371,6 @@ public class CVCamera extends Activity { ...@@ -363,7 +371,6 @@ public class CVCamera extends Activity {
NativeProcessor nativeProcessor) { NativeProcessor nativeProcessor) {
processor.detectAndDrawFeatures(idx, pool, cvcamera.DETECT_STAR); processor.detectAndDrawFeatures(idx, pool, cvcamera.DETECT_STAR);
} }
} }
...@@ -396,8 +403,8 @@ public class CVCamera extends Activity { ...@@ -396,8 +403,8 @@ public class CVCamera extends Activity {
} }
if (processor.getNumberDetectedChessboards() == 10) { if (processor.getNumberDetectedChessboards() == 10) {
File opencvdir = new File(Environment File opencvdir = new File(
.getExternalStorageDirectory(), "opencv"); Environment.getExternalStorageDirectory(), "opencv");
if (!opencvdir.exists()) { if (!opencvdir.exists()) {
opencvdir.mkdir(); opencvdir.mkdir();
} }
...@@ -486,8 +493,8 @@ public class CVCamera extends Activity { ...@@ -486,8 +493,8 @@ public class CVCamera extends Activity {
} }
if (processor.getNumberDetectedChessboards() < 10) { if (processor.getNumberDetectedChessboards() < 10) {
processor.drawText(idx, pool, "found " processor.drawText(idx, pool,
+ processor.getNumberDetectedChessboards() "found " + processor.getNumberDetectedChessboards()
+ "/10 chessboards"); + "/10 chessboards");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment