diff --git a/.cproject b/.cproject
index d3c1f726..28fe6c0f 100755
--- a/.cproject
+++ b/.cproject
@@ -5,9 +5,9 @@
+
-
@@ -45,10 +45,8 @@
-
-
-
-
+
+
diff --git a/.project b/.project
index d9aa1e51..99cf38f4 100644
--- a/.project
+++ b/.project
@@ -55,7 +55,7 @@
org.eclipse.cdt.make.core.useDefaultBuildCmd
- true
+ false
diff --git a/.settings/org.eclipse.cdt.core.prefs b/.settings/org.eclipse.cdt.core.prefs
index 59692068..44f85a9e 100644
--- a/.settings/org.eclipse.cdt.core.prefs
+++ b/.settings/org.eclipse.cdt.core.prefs
@@ -1,6 +1,6 @@
eclipse.preferences.version=1
environment/project/com.android.toolchain.gcc.1245095277/PATH/delimiter=\:
environment/project/com.android.toolchain.gcc.1245095277/PATH/operation=replace
-environment/project/com.android.toolchain.gcc.1245095277/PATH/value=/usr/lib/lightdm/lightdm\:/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/usr/games\:/usr/local/games\:/home/sergey/android_tools/android-ndk-r10d
+environment/project/com.android.toolchain.gcc.1245095277/PATH/value=/usr/lib/lightdm/lightdm\:/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/usr/games\:/usr/local/games\:/home/ivan/Android/android-ndk-r12b
environment/project/com.android.toolchain.gcc.1245095277/append=true
environment/project/com.android.toolchain.gcc.1245095277/appendContributed=true
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 05859d26..fa4be149 100755
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2,17 +2,17 @@
+ android:versionCode="123"
+ android:versionName="1.0">
-->
-
-
-
-
-
@@ -122,26 +122,26 @@
-
+
@@ -164,5 +164,5 @@
-->
+ android:targetSdkVersion="24"/>
diff --git a/assets/opencamera_modes.xml b/assets/opencamera_modes.xml
index 1a5a9c5b..6e9169d3 100755
--- a/assets/opencamera_modes.xml
+++ b/assets/opencamera_modes.xml
@@ -72,7 +72,7 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -276,6 +302,6 @@
-
+
\ No newline at end of file
diff --git a/jni/Android.mk b/jni/Android.mk
index 5e7dd1a5..388bb231 100755
--- a/jni/Android.mk
+++ b/jni/Android.mk
@@ -92,6 +92,9 @@ include $(MY_CORE_PATH)/bestshot/Android.mk
# Night plugin
include $(MY_CORE_PATH)/nightprocessing/Android.mk
+# FocusStacking plugin
+include $(MY_CORE_PATH)/focusstacking/Android.mk
+
# HDR plugin
include $(MY_CORE_PATH)/hdrprocessing/Android.mk
@@ -122,5 +125,8 @@ include $(MY_CORE_PATH)/histogram/Android.mk
# yuvimage helper
include $(MY_CORE_PATH)/yuvimage/Android.mk
+# yuvbitmap helper
+include $(MY_CORE_PATH)/yuvbitmap/Android.mk
+
# swapheap helper (move data between native and java heaps)
include $(MY_CORE_PATH)/swapheap/Android.mk
diff --git a/jni/almashot/armeabi-v7a/libalmalib_eval.a b/jni/almashot/armeabi-v7a/libalmalib_eval.a
index b8784eba..812e093e 100644
Binary files a/jni/almashot/armeabi-v7a/libalmalib_eval.a and b/jni/almashot/armeabi-v7a/libalmalib_eval.a differ
diff --git a/jni/almashot/x86/libalmalib_eval.a b/jni/almashot/x86/libalmalib_eval.a
index 94542057..815a14f9 100644
Binary files a/jni/almashot/x86/libalmalib_eval.a and b/jni/almashot/x86/libalmalib_eval.a differ
diff --git a/jni/focusstacking/Android.mk b/jni/focusstacking/Android.mk
new file mode 100755
index 00000000..14d2bb95
--- /dev/null
+++ b/jni/focusstacking/Android.mk
@@ -0,0 +1,13 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+include $(LOCAL_PATH)/../Flags.mk
+
+LOCAL_MODULE := almashot-fstacking
+LOCAL_SRC_FILES := almashot-fstacking.cpp
+LOCAL_CFLAGS += -DLOG_ON
+LOCAL_STATIC_LIBRARIES := almalib gomp
+LOCAL_LDLIBS := -ldl -lz -llog
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/jni/focusstacking/almashot-fstacking.cpp b/jni/focusstacking/almashot-fstacking.cpp
new file mode 100755
index 00000000..cd584f95
--- /dev/null
+++ b/jni/focusstacking/almashot-fstacking.cpp
@@ -0,0 +1,441 @@
+/*
+ The contents of this file are subject to the Mozilla Public License
+ Version 1.1 (the "License"); you may not use this file except in
+ compliance with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
+
+ Software distributed under the License is distributed on an "AS IS"
+ basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ License for the specific language governing rights and limitations
+ under the License.
+
+ The Original Code is collection of files collectively known as Open Camera.
+
+ The Initial Developer of the Original Code is Almalence Inc.
+ Portions created by Initial Developer are Copyright (C) 2013
+ by Almalence Inc. All Rights Reserved.
+ */
+
+#include
+#include
+#include
+#include
+
+#include "almashot.h"
+#include "fstacking.h"
+
+#ifdef LOG_ON
+#define LOG_TAG "AlmalenceFocusStacking"
+#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG,__VA_ARGS__)
+#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__ )
+#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__ )
+#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__ )
+#else
+#define LOG_TAG
+#define LOGD(...)
+#define LOGE(...)
+#define LOGI(...)
+#define LOGW(...)
+#endif
+
+// This triggers openmp constructors and destructors to be called upon library load/unload
+void __attribute__((constructor)) initialize_openmp() {
+}
+void __attribute__((destructor)) release_openmp() {
+}
+
+#include "fstacking-utils.h"
+
+#define MAX_FFRAMES 8
+
+static int iInputWidth = 0;
+static int iInputHeight = 0;
+static int iImageAmount = 0;
+
+static unsigned char *inputFrame[MAX_FFRAMES] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
+static unsigned char *alignedFrame[MAX_FFRAMES] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
+
+static float focusDistances[MAX_FFRAMES] = {0, 0, 0, 0, 0, 0, 0, 0};
+static unsigned char* focusMap = NULL;
+
+static void *instance = NULL;
+static int almashot_inited = 0;
+static unsigned char *OutPic = NULL;
+
+/*
+ * Initialize Almashot engine. Must be called first
+ */
+extern "C" JNIEXPORT jstring JNICALL Java_com_almalence_focusstacking_AlmaShotFocusStacking_AlmaShotInitialize
+(
+ JNIEnv* env,
+ jobject thiz
+)
+{
+ LOGE("Initialize - start");
+ char status[1024];
+ int err=0;
+
+ if (almashot_inited == 0)
+ {
+ err = AlmaShot_Initialize(1);
+
+ if (err == ALMA_ALL_OK)
+ almashot_inited = 1;
+ }
+
+ sprintf (status, " init status: %d\n", err);
+
+ LOGE("Initialize - end");
+ return env->NewStringUTF(status);
+}
+
+
+/*
+ * Initialize focus stacking instance
+ * @in - array of pointers to input frames
+ * @focusDist - array of focus distance for each input frame (in diopter)
+ * @nFrames - number of input frames
+ * @sx - width of input frames
+ * @sy - height of input frames
+ * @fmap - byte array that represents focus areas map (read doc for details)
+ */
+extern "C" JNIEXPORT jint JNICALL Java_com_almalence_focusstacking_AlmaShotFocusStacking_FStackingInitialize
+(
+ JNIEnv* env,
+ jobject thiz,
+ jintArray in,
+ jfloatArray focusDist,
+ jint nFrames,
+ jint sx,
+ jint sy,
+ jbyteArray fmap
+)
+{
+ LOGE("FStackingInitialize - start");
+ int i;
+ unsigned char **yuv;
+ float* focus;
+ char status[1024];
+
+ iInputWidth = sx;
+ iInputHeight = sy;
+ iImageAmount = nFrames;
+
+ yuv = (unsigned char**)env->GetIntArrayElements(in, NULL);
+ int yuv_length = sx*sy+2*((sx+1)/2)*((sy+1)/2);
+
+ focus = (float*)env->GetFloatArrayElements(focusDist, NULL);
+
+ if(fmap != NULL)
+ focusMap = (unsigned char *)env->GetByteArrayElements(fmap, NULL);
+ else
+ focusMap = NULL;
+
+ for (i = 0; i < iImageAmount; ++i)
+ {
+ inputFrame[i] = yuv[i];
+ focusDistances[i] = focus[i];
+ }
+
+// __android_log_print(ANDROID_LOG_ERROR, "CameraTest", "START INPUT SAVE");
+// for (int i=0; iReleaseIntArrayElements(in, (jint*)yuv, JNI_ABORT);
+ env->ReleaseFloatArrayElements(focusDist, (jfloat*)focus, JNI_ABORT);
+
+ if(fmap != NULL)
+ env->ReleaseByteArrayElements(fmap, (jbyte*)focusMap, JNI_ABORT);
+
+ LOGE("FStacking_Initialize. Frames total: %d\n", (int)nFrames);
+ return nFrames;
+}
+
+
+/*
+ * Finalize Almashot engine
+ */
+extern "C" JNIEXPORT jint JNICALL Java_com_almalence_focusstacking_AlmaShotFocusStacking_AlmaShotRelease
+(
+ JNIEnv* env,
+ jobject
+)
+{
+ LOGE("Release - start");
+
+ if (almashot_inited == 1)
+ {
+ AlmaShot_Release();
+ almashot_inited = 0;
+ }
+
+ LOGE("Release - end");
+ return 0;
+}
+
+
+/*
+ * Free FocusStacking instance and memory for the output frame
+ */
+extern "C" JNIEXPORT jint JNICALL Java_com_almalence_focusstacking_AlmaShotFocusStacking_FStackingFreeInstance
+(
+ JNIEnv* env,
+ jobject
+)
+{
+ LOGE("FreeInstance - start");
+ if (OutPic)
+ {
+// LOGE("free(OutPic) - start");
+ free(OutPic);
+ OutPic = NULL;
+// LOGE("free(OutPic) - end");
+ }
+
+ if (instance)
+ {
+ FStacking_FreeInstance(instance, 1);
+ instance = NULL;
+ }
+
+ LOGE("FreeInstance - end");
+ return 0;
+}
+
+
+/*
+ * Get one input frame by index
+ */
+extern "C" JNIEXPORT jint JNICALL Java_com_almalence_focusstacking_AlmaShotFocusStacking_GetInputFrame
+(
+ JNIEnv* env,
+ jobject thiz,
+ jint index
+)
+{
+ return (jint)inputFrame[index];
+}
+
+
+/*
+ * Get one input frame by index in byteArray format
+ * @in - input frames
+ * @index - index of desired frame
+ * @orientation - desired rotation degrees of frame
+ * @mirror - flip frame horizontally
+ */
+extern "C" JNIEXPORT jbyteArray JNICALL Java_com_almalence_focusstacking_AlmaShotFocusStacking_GetInputByteFrameNative
+(
+ JNIEnv* env,
+ jobject thiz,
+ jintArray in,
+ jint index,
+ jint orientation,
+ jboolean mirror
+)
+{
+// LOGE("GetInputByteFrame - start");
+
+ unsigned char** yuv = (unsigned char**)env->GetIntArrayElements(in, NULL);
+
+ unsigned char *data;
+ jbyteArray jdata = env->NewByteArray(iInputWidth * iInputHeight * 2);
+ data = (unsigned char*)env->GetByteArrayElements(jdata, NULL);
+
+ int flipLeftRight, flipUpDown;
+ int rotate90 = orientation == 90 || orientation == 270;
+ if (mirror)
+ flipUpDown = flipLeftRight = orientation == 180 || orientation == 90;
+ else
+ flipUpDown = flipLeftRight = orientation == 180 || orientation == 270;
+
+// LOGE("TransformNV21 - start");
+ TransformNV21(yuv[index], data, iInputWidth, iInputHeight, NULL, flipLeftRight, flipUpDown, rotate90);
+// LOGE("TransformNV21 - end");
+
+ env->ReleaseByteArrayElements(jdata, (jbyte*)data, 0);
+ env->ReleaseIntArrayElements(in, (jint*)yuv, 0);
+
+// LOGE("GetInputByteFrame - end");
+
+ return jdata;
+}
+
+
+/*
+ * Get pointer to aligned frame by index
+ * NOTE: Aligned frames is available only after FStackingProcess method successfully done
+ * @index - requested frame index
+ */
+extern "C" JNIEXPORT jint JNICALL Java_com_almalence_focusstacking_AlmaShotFocusStacking_GetAlignedFrame
+(
+ JNIEnv* env,
+ jobject thiz,
+ jint index
+)
+{
+ return (jint)alignedFrame[index];
+}
+
+
+/*
+ * Get all aligned frames from Focus stacking instance
+ */
+extern "C" JNIEXPORT jintArray JNICALL Java_com_almalence_focusstacking_AlmaShotFocusStacking_GetAlignedFrames
+(
+ JNIEnv* env,
+ jobject thiz
+)
+{
+// LOGE("Get aligned frames - start. iInputWidth = %d, iInputHeight = %d, iImageAmount = %d", iInputWidth, iInputHeight, iImageAmount);
+ //Store aligned input frames
+ FStacking_GetAlignedFrames(instance,
+ alignedFrame,
+ iInputWidth,
+ iInputHeight,
+ iImageAmount);
+// LOGE("Get aligned frames - end");
+
+// __android_log_print(ANDROID_LOG_ERROR, "CameraTest", "START ALIGNED SAVE");
+// for (int i = 0; i < iImageAmount; ++i)
+// {
+// char str[256];
+// sprintf(str, "/sdcard/DCIM/fstacking_aligned%02d.yuv", i);
+// FILE *f = fopen (str, "wb");
+// fwrite(alignedFrame[i], iInputWidth * iInputHeight + 2 * ((iInputWidth + 1)/2) * ((iInputHeight + 1)/2), 1, f);
+// fclose(f);
+// }
+// __android_log_print(ANDROID_LOG_ERROR, "CameraTest", "ALIGNED SAVCED");
+
+ jintArray jalign = env->NewIntArray(iImageAmount);
+ env->SetIntArrayRegion(jalign, 0, iImageAmount, (jint*)alignedFrame);
+
+// LOGE("Create aligned frames array - end");
+
+ return jalign;
+}
+
+
+/*
+ * Main process function. Calls an Almalence's focus stacking feature
+ * This method can be called only after FStackingInitialize function
+ * @orientation - desired rotation degrees of result frame
+ * @mirror - flip result frame horizontally
+ * @transform - true if it's need to transform result according above two arguments
+ *
+ * @return - 'All-In-Focus' frame as byte array in NV21 format
+ */
+extern "C" JNIEXPORT jbyteArray JNICALL Java_com_almalence_focusstacking_AlmaShotFocusStacking_FStackingProcess
+(
+ JNIEnv* env,
+ jobject thiz,
+ jint orientation,
+ jboolean mirror,
+ jboolean transform
+)
+{
+ FStacking_Align(&instance,
+ inputFrame,
+ focusMap,
+ NULL,
+ 655, // gain (sensor specific, might need adjustment)
+ iInputWidth, iInputHeight,
+ iImageAmount,
+ iImageAmount/2, // base frame (from which to take background)
+ 256, // do not use pre-filter
+ 256, // do not use post-filter
+ 1, // re-scale output
+ 1
+ );
+
+// for(int i = 0; i < iInputWidth/16*iInputHeight/16; i++)
+// LOGE("focusMap[i] = %d", (int)focusMap[i]);
+
+ LOGE("Focus stacking processing - start");
+
+ unsigned char *OutNV21;
+ unsigned char *data;
+// LOGE("JBYTEARRAY - start new size 0");
+ jbyteArray jdata = env->NewByteArray(0);
+// LOGE("JBYTEARRAY - end new size 0");
+
+ int x0_out, y0_out, w_out, h_out;
+
+ if(OutPic)
+ {
+ free(OutPic);
+ LOGE("old OutPic free");
+ }
+
+// jbyteArray jdata = env->NewByteArray(iInputWidth * iInputHeight * 2);
+// OutPic = (unsigned char*)env->GetByteArrayElements(jdata, NULL);
+ OutPic = (unsigned char *)malloc(iInputWidth * iInputHeight * 2);
+// LOGE("OutPic malloced");
+
+ if (FStacking_Process(instance,
+ &OutPic,
+ &x0_out, &y0_out,
+ &w_out, &h_out) == ALMA_ALL_OK)
+ {
+ LOGE("Focus stacking processing - ok. x0_out = %d y0_out = %d width = %d height = %d", x0_out, y0_out, w_out, h_out);
+ }
+ else
+ {
+ LOGE("Focus stacking processing - error");
+ return NULL;
+ }
+
+
+// char str[256];
+// sprintf(str, "/sdcard/DCIM/fstacking_android_res.yuv");
+// FILE *f = fopen (str, "wb");
+// fwrite(OutPic, sx*sy+2*((sx+1)/2)*((sy+1)/2), 1, f);
+// fclose(f);
+
+ if(transform)
+ {
+// LOGE("Focus stacking processing - transform start");
+ int flipLeftRight, flipUpDown;
+ int rotate90 = orientation == 90 || orientation == 270;
+ if (mirror)
+ flipUpDown = flipLeftRight = orientation == 180 || orientation == 90;
+ else
+ flipUpDown = flipLeftRight = orientation == 180 || orientation == 270;
+
+ OutNV21 = OutPic;
+ if (rotate90)
+ OutNV21 = (unsigned char *)malloc(iInputWidth * iInputHeight * 2);
+
+ TransformNV21(OutPic, OutNV21, iInputWidth, iInputHeight, NULL, flipLeftRight, flipUpDown, rotate90);
+
+ if (rotate90)
+ {
+ free(OutPic);
+ OutPic = OutNV21;
+ }
+// LOGE("Focus stacking processing - transform end");
+ }
+
+// LOGE("Focus stacking processing - new ouput byte array start");
+ jdata = env->NewByteArray(iInputWidth * iInputHeight * 2);
+ data = (unsigned char*)env->GetByteArrayElements(jdata, NULL);
+
+// data = (unsigned char *)malloc(iInputWidth * iInputHeight * 2);
+ memcpy (data, OutPic, iInputWidth * iInputHeight * 2);
+
+ env->ReleaseByteArrayElements(jdata, (jbyte*)data, 0);
+// LOGE("Focus stacking processing - new ouput byte array end");
+// free(OutPic);
+// OutPic = NULL;
+
+ return jdata;
+// return (jint)data;
+// return (jint) OutPic;
+}
diff --git a/jni/focusstacking/fstacking-utils.h b/jni/focusstacking/fstacking-utils.h
new file mode 100755
index 00000000..76c22131
--- /dev/null
+++ b/jni/focusstacking/fstacking-utils.h
@@ -0,0 +1,223 @@
+/*
+The contents of this file are subject to the Mozilla Public License
+Version 1.1 (the "License"); you may not use this file except in
+compliance with the License. You may obtain a copy of the License at
+http://www.mozilla.org/MPL/
+
+Software distributed under the License is distributed on an "AS IS"
+basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+License for the specific language governing rights and limitations
+under the License.
+
+The Original Code is collection of files collectively known as Open Camera.
+
+The Initial Developer of the Original Code is Almalence Inc.
+Portions created by Initial Developer are Copyright (C) 2013
+by Almalence Inc. All Rights Reserved.
+*/
+
+#include
+#include
+
+void TransformPlane8bit
+(
+ unsigned char * In,
+ unsigned char * Out,
+ int sx,
+ int sy,
+ int flipLeftRight,
+ int flipUpDown,
+ int rotate90
+)
+{
+ int y;
+ int osx, osy;
+
+ // no transform case
+ if ((!flipLeftRight) && (!flipUpDown) && (!rotate90))
+ {
+ if (In!=Out)
+ memcpy (Out, In, sx*sy*sizeof(unsigned char));
+ return;
+ }
+
+ // can't rotate in-place
+ if (rotate90 && (In == Out))
+ return;
+
+ if (rotate90) {osx = sy; osy = sx;}
+ else {osx = sx; osy = sy;}
+
+ // processing 4 mirrored locations at once
+ // +1 here to cover case when image dimensions are odd
+ #pragma omp parallel for schedule(guided)
+ for (y=0; y<(sy+1)/2; ++y)
+ {
+ int x;
+ int ox, oy;
+ unsigned char t1, t2, t3, t4;
+
+ for (x=0; x<(sx+1)/2; ++x)
+ {
+ if (rotate90)
+ {
+ if (flipLeftRight) ox = y;
+ else ox = osx-1-y;
+ if (flipUpDown) oy = osy-1-x;
+ else oy = x;
+
+ t1 = In[x + y*sx];
+ t2 = In[sx-1-x + y*sx];
+ t3 = In[x + (sy-1-y)*sx];
+ t4 = In[sx-1-x + (sy-1-y)*sx];
+
+ Out[ox + oy*osx] = t1;
+ Out[osx-1-ox + oy*osx] = t3;
+ Out[ox + (osy-1-oy)*osx] = t2;
+ Out[osx-1-ox + (osy-1-oy)*osx] = t4;
+ }
+ else
+ {
+ if (flipLeftRight) ox = sx-1-x;
+ else ox = x;
+ if (flipUpDown) oy = sy-1-y;
+ else oy = y;
+
+ t1 = In[x + y*sx];
+ t2 = In[sx-1-x + y*sx];
+ t3 = In[x + (sy-1-y)*sx];
+ t4 = In[sx-1-x + (sy-1-y)*sx];
+
+ Out[ox + oy*osx] = t1;
+ Out[osx-1-ox + oy*osx] = t2;
+ Out[ox + (osy-1-oy)*osx] = t3;
+ Out[osx-1-ox + (osy-1-oy)*osx] = t4;
+ }
+ }
+ }
+}
+
+
+void TransformPlane16bit
+(
+ unsigned short * In,
+ unsigned short * Out,
+ int sx,
+ int sy,
+ int flipLeftRight,
+ int flipUpDown,
+ int rotate90
+)
+{
+ int y;
+ int osx, osy;
+
+ // no transform case
+ if ((!flipLeftRight) && (!flipUpDown) && (!rotate90))
+ {
+ if (In!=Out)
+ memcpy (Out, In, sx*sy*sizeof(unsigned short));
+ return;
+ }
+
+ // can't rotate in-place
+ if (rotate90 && (In == Out))
+ return;
+
+ if (rotate90) {osx = sy; osy = sx;}
+ else {osx = sx; osy = sy;}
+
+ // processing 4 mirrored locations at once
+ #pragma omp parallel for schedule(guided)
+ for (y=0; y<(sy+1)/2; ++y)
+ {
+ int x;
+ int ox, oy;
+ unsigned short t1, t2, t3, t4;
+
+ for (x=0; x<(sx+1)/2; ++x)
+ {
+ if (rotate90)
+ {
+ if (flipLeftRight) ox = y;
+ else ox = osx-1-y;
+ if (flipUpDown) oy = osy-1-x;
+ else oy = x;
+
+ t1 = In[x + y*sx];
+ t2 = In[sx-1-x + y*sx];
+ t3 = In[x + (sy-1-y)*sx];
+ t4 = In[sx-1-x + (sy-1-y)*sx];
+
+ Out[ox + oy*osx] = t1;
+ Out[osx-1-ox + oy*osx] = t3;
+ Out[ox + (osy-1-oy)*osx] = t2;
+ Out[osx-1-ox + (osy-1-oy)*osx] = t4;
+ }
+ else
+ {
+ if (flipLeftRight) ox = sx-1-x;
+ else ox = x;
+ if (flipUpDown) oy = sy-1-y;
+ else oy = y;
+
+ t1 = In[x + y*sx];
+ t2 = In[sx-1-x + y*sx];
+ t3 = In[x + (sy-1-y)*sx];
+ t4 = In[sx-1-x + (sy-1-y)*sx];
+
+ Out[ox + oy*osx] = t1;
+ Out[osx-1-ox + oy*osx] = t2;
+ Out[ox + (osy-1-oy)*osx] = t3;
+ Out[osx-1-ox + (osy-1-oy)*osx] = t4;
+ }
+ }
+ }
+}
+
+
+// mirror and/or rotate NV21 image
+//
+// Note:
+// - mirroring can be performed in-place, rotation can not
+// - rotation is 90 degree clockwise
+// - if need to rotate 180 degree - call with flipLeftRight=1, flipUpDown=1
+// - if need to rotate 90 degree counter-clockwise - call with flipLeftRight=1, flipUpDown=1, rotate90=1
+// - it is assumed that image width is even and image height is even
+// - crop coordinates are also transformed if given, but no cropping is performed
+//
+void TransformNV21
+(
+ unsigned char * InNV21,
+ unsigned char * OutNV21,
+ int sx,
+ int sy,
+ int *crop,
+ int flipLeftRight,
+ int flipUpDown,
+ int rotate90
+)
+{
+ int tmp;
+
+ TransformPlane8bit(InNV21, OutNV21, sx, sy, flipLeftRight, flipUpDown, rotate90);
+
+ // treat UV as a single 16bit entity - makes transform faster
+ TransformPlane16bit((unsigned short*)(InNV21+sx*sy), (unsigned short*)(OutNV21+sx*sy), sx/2, sy/2, flipLeftRight, flipUpDown, rotate90);
+
+ if (crop)
+ {
+ if (rotate90)
+ {
+ tmp = crop[0]; crop[0] = crop[1]; crop[1] = tmp;
+ tmp = crop[2]; crop[2] = crop[3]; crop[3] = tmp;
+ if (!flipLeftRight) crop[0] = sy-(crop[0]+crop[2]);
+ if (flipUpDown) crop[1] = sx-(crop[1]+crop[3]);
+ }
+ else
+ {
+ if (flipLeftRight) crop[0] = sx-(crop[0]+crop[2]);
+ if (flipUpDown) crop[1] = sy-(crop[1]+crop[3]);
+ }
+ }
+}
diff --git a/jni/groupshot/Android.mk b/jni/groupshot/Android.mk
index bf9bc4b3..7618fee3 100755
--- a/jni/groupshot/Android.mk
+++ b/jni/groupshot/Android.mk
@@ -116,11 +116,12 @@ LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/FaceRecEm/common/src/b_FDSDK/
LOCAL_SHARED_LIBRARIES := \
- libandroid_runtime \
libnativehelper \
libutils \
libskia \
libcutils
+
+# libandroid_runtime \
LOCAL_MODULE:= libFFTEm
diff --git a/jni/include/almashot/filters.h b/jni/include/almashot/filters.h
index 245ac1ca..27a0ba88 100644
--- a/jni/include/almashot/filters.h
+++ b/jni/include/almashot/filters.h
@@ -384,6 +384,8 @@ void Filters_FilterMoving
int stride
);
+void Filters_RefBlur(Uint8 *in, Uint8 *out, Uint8 *nMov,
+ int mstride, int sx, int sy, int stride, int mod);
#if defined __cplusplus
}
diff --git a/jni/include/almashot/fstacking.h b/jni/include/almashot/fstacking.h
index a2c9a2fc..2412d817 100644
--- a/jni/include/almashot/fstacking.h
+++ b/jni/include/almashot/fstacking.h
@@ -68,6 +68,24 @@ int FStacking_Align
int fastMode
);
+int FStacking_GetAlignedFrames
+(
+ void *instance,
+ Uint8 **out,
+ int sx,
+ int sy,
+ int nFrames
+);
+
+
+int FStacking_GetFocusAreaMap
+(
+ void *instance,
+ Uint8 *out,
+ int sx,
+ int sy
+);
+
int FStacking_Process
(
diff --git a/jni/include/almashot/supersensor.h b/jni/include/almashot/supersensor.h
index 97931d95..be365764 100644
--- a/jni/include/almashot/supersensor.h
+++ b/jni/include/almashot/supersensor.h
@@ -63,11 +63,9 @@ int Super_Process
int syo,
int nFrames,
int SensorGain,
- int DeGhostGain,
- int DeGhostFrames,
int postFilter,
int postSharpen,
- int gamma,
+ float gamma,
int cameraIndex,
int externalBuffers
);
diff --git a/jni/nightprocessing/almashot-night.cpp b/jni/nightprocessing/almashot-night.cpp
index 300ae0a7..49d44256 100755
--- a/jni/nightprocessing/almashot-night.cpp
+++ b/jni/nightprocessing/almashot-night.cpp
@@ -192,87 +192,87 @@ extern "C" JNIEXPORT jint JNICALL Java_com_almalence_plugins_processing_night_Al
}
}
- if (fgamma && (iso>0))
+ if (fgamma != 0.0f && (iso > 0) && cameraIndex != 903)
{
// iso 100 = +0.1
// iso 800 = -0.05
- fgamma += 0.1f - ( logf(iso) * 3.321928095f-6.644f)*0.15f/3.f;
- if (fgamma < 0.45f) fgamma = 0.45f;
- if (fgamma > 0.6f) fgamma = 0.6f;
+ fgamma += 0.09f - (logf(iso) * 3.321928095f - 6.644f) * 0.165f/3.0f;//log2f replaced with logf(iso) * 3.321928095f for android <4.3
}
- // for SR-only fgamma = 0, gamma will evaluate to 0 also
- int gamma = (int)(fgamma * 256 + 0.5f);
+ if (fgamma != 0.0f)
+ {
+ if (fgamma < 0.43f) fgamma = 0.43f;
+ if (fgamma > 0.6f) fgamma = 0.6f;
+ }
- // threshold at which profiles are switched (about 1.5x zoom)
int zoomAbove15x = sxo >= 3*(sx_zoom-2*SIZE_GUARANTEE_BORDER)/2;
int zoomAbove30x = sxo >= 3*sx_zoom;
+ float zoom = sxo / float(sx_zoom);
+
+ int filter = 256;
+ int sharpen = 1;
+ if (zoomAbove30x) sharpen = 0x80; // fine edge enhancement instead of primitive sharpen at high zoom levels
+
+//
+//
+//
+// if (fgamma && (iso>0))
+// {
+// // iso 100 = +0.1
+// // iso 800 = -0.05
+// fgamma += 0.1f - ( logf(iso) * 3.321928095f-6.644f)*0.15f/3.f;
+// if (fgamma < 0.45f) fgamma = 0.45f;
+// if (fgamma > 0.6f) fgamma = 0.6f;
+// }
+//
+// // for SR-only fgamma = 0, gamma will evaluate to 0 also
+// int gamma = (int)(fgamma * 256 + 0.5f);
+//
+// // threshold at which profiles are switched (about 1.5x zoom)
+// int zoomAbove15x = sxo >= 3*(sx_zoom-2*SIZE_GUARANTEE_BORDER)/2;
+// int zoomAbove30x = sxo >= 3*sx_zoom;
- int sensorGain, deGhostGain, filter, sharpen;
-
switch (cameraIndex)
{
- case 100: // Nexus 5
- deGhostGain = 256*80/100;
- sensorGain = (int)( 256*powf((float)iso/100, 0.5f) );
+ case 103:// Nexus 6
+ case 507:// LG G Flex2
+ case 1900:// Cyanogen 0
+ case 2201:
+ break;
+ case 100: // Nexus 5
// slightly more sharpening and less filtering at low zooms
sharpen = 2;
- filter = 384; // 320; // 256;
- if (zoomAbove30x) sharpen = 0x80; // fine edge enhancement instead of primitive sharpen at high zoom levels
- else if (zoomAbove15x) sharpen = 1;
- else filter = 192;
- break;
- case 103: // Nexus 6
- deGhostGain = 256*50/100;
- sensorGain = (int)( 107*256/100*powf((float)iso/100, 0.7f) );
-
- sharpen = 1;
- if (!zoomAbove15x) sharpen = 0x80; // slightly more filtering at low zooms (noise interpolation artefacts are evident otherwise)
- filter = 256;
+ if (zoomAbove15x) filter = 384;
+ else filter = 192;
break;
- case 105: // Nexus 5X
- case 106: // Nexus 6P
- deGhostGain = (256 * (60 - 0.015f * iso) / 100);
- if (deGhostGain < 56) deGhostGain = 56;
- sensorGain = (int)(1.7f * 256 * powf(((float)iso) / 100, 0.45f));
+ case 105:// Nexus 5X - same camera module as in Nexus 6p
+ case 106:// Nexus 6P
sharpen = 2;
- if (zoomAbove30x) sharpen = 0x80;// fine edge enhancement instead of primitive sharpen at high zoom levels
if (zoomAbove15x) filter = 256;
else filter = 192;
break;
- case 507: // LG G Flex2
- deGhostGain = 256*60/100;
- sensorGain = (int)( 2*256*powf((float)iso/100, 0.45f) );
- sharpen = 1;
- if (zoomAbove30x) sharpen = 0x80;// fine edge enhancement instead of primitive sharpen at high zoom levels
- filter = 300;
- if (!zoomAbove15x) filter = 192;// slightly less filtering at low zooms (somehow sr processing is creating less sharp images here)
+ case 903:// HTC10
+ // use both edge enhancement and sharpening at high zoom levels
+ sharpen |= 1;
break;
- case 1006:// Galaxy S7
- deGhostGain = (100 - (int)(iso * 0.0004167f)) * 256 / 100;
- sensorGain = (int)(1.05f * 256 * powf(((float)iso) / 100, 0.5f));
- sharpen = 1;
+ case 1005:// Galaxy S6
// do not use fine edge enhancement (looks too plastic on S6)
- //if (zoomAbove30x) sharpen = 0x80;// fine edge enhancement instead of primitive sharpen at high zoom levels
- filter = 256;
- //if (!zoomAbove15x) filter = 320;// slightly more filtering at low zooms
+ sharpen = 1;
+ filter = 288; // 256;
break;
- case 2000:// OnePlus 2
- deGhostGain = (256 * (50 - 0.01f * iso) / 100);
- if (deGhostGain < 54) deGhostGain = 54;
- sensorGain = (int)(1.4f * 256 * powf(((float)iso) / 100, 0.45f));
+ case 1006:// Galaxy S7
+ // do not use fine edge enhancement (looks too plastic on S6)
sharpen = 1;
- if (zoomAbove30x) sharpen = 0x80;// fine edge enhancement instead of primitive sharpen at high zoom levels
+ break;
- filter = 256;
+ case 2000:// OnePlus 2
if (zoomAbove15x) filter = 160;
-
break;
default:
__android_log_print(ANDROID_LOG_INFO, "CameraTest", "Error: Unknown camera");
@@ -286,12 +286,10 @@ extern "C" JNIEXPORT jint JNICALL Java_com_almalence_plugins_processing_night_Al
int err = Super_Process(
yuv, NULL, &OutPic,
sx_zoom, sy_zoom, sx_zoom, sxo, syo, nImages,
- sensorGain,
- deGhostGain*deghostTable[DeGhostPref]/256,
- 1, // deghostFrames
+ iso,
filter,
sharpen,
- gamma,
+ fgamma,
cameraIndex,
0); // externalBuffers
diff --git a/jni/utils/Android.mk b/jni/utils/Android.mk
index 7d836f2b..ed8131b3 100755
--- a/jni/utils/Android.mk
+++ b/jni/utils/Android.mk
@@ -6,6 +6,6 @@ LOCAL_MODULE := utils-image
LOCAL_SRC_FILES := ImageConversionUtils.cpp
LOCAL_STATIC_LIBRARIES := jpeg gomp
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
-LOCAL_LDLIBS := -ldl -llog
+LOCAL_LDLIBS := -ldl -llog -landroid -ljnigraphics
include $(BUILD_SHARED_LIBRARY)
diff --git a/jni/utils/ImageConversionUtils.cpp b/jni/utils/ImageConversionUtils.cpp
index f25de2a9..099501b2 100755
--- a/jni/utils/ImageConversionUtils.cpp
+++ b/jni/utils/ImageConversionUtils.cpp
@@ -20,6 +20,7 @@ by Almalence Inc. All Rights Reserved.
#include
#include
#include
+#include
#include
#include "jpeglib.h"
@@ -952,3 +953,87 @@ extern "C" JNIEXPORT jintArray JNICALL Java_com_almalence_util_ImageConversion_N
return jpixels;
}
+
+
+extern "C" JNIEXPORT jintArray JNICALL Java_com_almalence_util_ImageConversion_NV21ByteArraytoARGB
+(
+ JNIEnv* env,
+ jobject thiz,
+ jbyteArray inptr,
+ jint srcW,
+ jint srcH,
+ jobject rect,
+ jint dstW,
+ jint dstH
+)
+{
+ LOGD("NV21toARGB - start");
+
+ Uint32 * pixels;
+ jintArray jpixels = NULL;
+
+ jclass class_rect = env->GetObjectClass(rect);
+ jfieldID id_left = env->GetFieldID(class_rect, "left", "I");
+ jint left = env->GetIntField(rect,id_left);
+ jfieldID id_top = env->GetFieldID(class_rect, "top", "I");
+ jint top = env->GetIntField(rect,id_top);
+ jfieldID id_right = env->GetFieldID(class_rect, "right", "I");
+ jint right = env->GetIntField(rect,id_right);
+ jfieldID id_bottom = env->GetFieldID(class_rect, "bottom", "I");
+ jint bottom = env->GetIntField(rect,id_bottom);
+
+ jpixels = env->NewIntArray(dstW*dstH);
+ LOGD("Memory alloc size = %d * %d", dstW, dstH);
+ pixels = (Uint32 *)env->GetIntArrayElements(jpixels, NULL);
+
+ Uint8 *inpxls = (Uint8 *)env->GetByteArrayElements(inptr, NULL);;
+
+ NV21_to_RGB_scaled(inpxls, srcW, srcH, left, top, right - left, bottom - top, dstW, dstH, 4, (Uint8 *)pixels);
+
+ env->ReleaseIntArrayElements(jpixels, (jint*)pixels, 0);
+ env->ReleaseByteArrayElements(inptr, (jbyte*)inpxls, 0);
+
+ LOGD("NV21toARGB - end");
+
+ return jpixels;
+}
+
+extern "C" JNIEXPORT jboolean JNICALL Java_com_almalence_util_ImageConversion_BitmapFromNV21ByteArray
+(
+ JNIEnv* env,
+ jobject thiz,
+ jobject bitmap,
+ jbyteArray inptr,
+ jint srcW,
+ jint srcH,
+ jobject rect,
+ jint dstW,
+ jint dstH
+)
+{
+ int ret;
+ Uint32 * bitmap_data;
+
+ if ((ret = AndroidBitmap_lockPixels(env, bitmap, ((void**)&bitmap_data))) < 0)
+ return false;
+
+ jclass class_rect = env->GetObjectClass(rect);
+ jfieldID id_left = env->GetFieldID(class_rect, "left", "I");
+ jint left = env->GetIntField(rect,id_left);
+ jfieldID id_top = env->GetFieldID(class_rect, "top", "I");
+ jint top = env->GetIntField(rect,id_top);
+ jfieldID id_right = env->GetFieldID(class_rect, "right", "I");
+ jint right = env->GetIntField(rect,id_right);
+ jfieldID id_bottom = env->GetFieldID(class_rect, "bottom", "I");
+ jint bottom = env->GetIntField(rect,id_bottom);
+
+ Uint8 *inpxls = (Uint8 *)env->GetByteArrayElements(inptr, NULL);
+
+ NV21_to_RGB_scaled(inpxls, srcW, srcH, left, top, right - left, bottom - top, dstW, dstH, 4, (Uint8 *)bitmap_data);
+
+ AndroidBitmap_unlockPixels(env, bitmap);
+
+ env->ReleaseByteArrayElements(inptr, (jbyte*)inpxls, 0);
+
+ return true;
+}
diff --git a/jni/yuvbitmap/Android.mk b/jni/yuvbitmap/Android.mk
new file mode 100755
index 00000000..c140fd84
--- /dev/null
+++ b/jni/yuvbitmap/Android.mk
@@ -0,0 +1,13 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(LOCAL_PATH)/../Flags.mk
+
+LOCAL_MODULE := YuvBitmap
+LOCAL_SRC_FILES := YuvBitmap.cpp
+LOCAL_LDLIBS := \
+ -L. -Ljni/$(TARGET_ARCH_ABI) \
+ -llog \
+ -landroid \
+ -ljnigraphics
+
+include $(BUILD_SHARED_LIBRARY)
\ No newline at end of file
diff --git a/jni/yuvbitmap/YuvBitmap.cpp b/jni/yuvbitmap/YuvBitmap.cpp
new file mode 100644
index 00000000..585d71bd
--- /dev/null
+++ b/jni/yuvbitmap/YuvBitmap.cpp
@@ -0,0 +1,124 @@
+#include
+
+#include
+
+#include
+#include
+
+#define get_Ysz(in, sx, sy, crop_x, crop_y, x, y) ((in)[(crop_x)+(crop_y)*(sx)+(x)+(y)*(sx)])
+#define get_Usz(in, sx, sy, crop_x, crop_y, x, y) ((in)[(sx)*(sy)+(crop_x)+((crop_y)/2)*(sx)+((x)|1)+((y)/2)*(sx)])
+#define get_Vsz(in, sx, sy, crop_x, crop_y, x, y) ((in)[(sx)*(sy)+(crop_x)+((crop_y)/2)*(sx)+((x)&~1)+((y)/2)*(sx)])
+
+#define CLIP8(x) ( (x)<0 ? 0 : (x)>255 ? 255 : (x) )
+#define CSC_R(Y,V) CLIP8((128*(Y)+176*((V)-128)) >> 7 )
+#define CSC_B(Y,U) CLIP8((128*(Y)+222*((U)-128)) >> 7 )
+#define CSC_G(Y,U,V) CLIP8((128*(Y)-89*((V)-128)-43*((U)-128)) >> 7 )
+
+extern "C"
+{
+
+inline int min(int a, int b)
+{
+ return (a < b ? a : b);
+}
+
+void NV21_to_RGB
+(
+ unsigned char * in,
+ int * out,
+ int sx,
+ int sy,
+ int crop_x,
+ int crop_y,
+ int crop_w,
+ int crop_h,
+ int crop_w_abs
+)
+{
+ int x, y;
+ short Y1, Y2, u, v, vp, up, va, ua;
+ unsigned int R, G, B;
+
+ for (y=0; yGetByteArrayElements(inputArray, NULL);
+
+ NV21_to_RGB((uint8_t*)inputFrame, bitmap_data, input_w, input_h, crop_x, crop_y, actual_crop_w, actual_crop_h, crop_w);
+
+ AndroidBitmap_unlockPixels(env, bitmap);
+
+ env->ReleaseByteArrayElements(inputArray, (jbyte*)inputFrame, 0);
+
+ return true;
+}
+
+}
diff --git a/jni/yuvimage/Android.mk b/jni/yuvimage/Android.mk
index 12d8caab..f454cdf3 100755
--- a/jni/yuvimage/Android.mk
+++ b/jni/yuvimage/Android.mk
@@ -5,7 +5,8 @@ include $(LOCAL_PATH)/../Flags.mk
LOCAL_MODULE := yuvimage
LOCAL_SRC_FILES := yuvimage.cpp YuvToJpegEncoderMT.cpp
LOCAL_STATIC_LIBRARIES := almalib jpeg gomp
-LOCAL_LDLIBS := -llog \
- $(call host-path, $(LOCAL_PATH)/../prebuilt/$(TARGET_ARCH_ABI)/libandroid_runtime.so)
+LOCAL_LDLIBS := -llog
+#\
+# $(call host-path, $(LOCAL_PATH)/../prebuilt/$(TARGET_ARCH_ABI)/libandroid_runtime.so)
include $(BUILD_SHARED_LIBRARY)
\ No newline at end of file
diff --git a/res/drawable-hdpi/icon.png b/res/drawable-hdpi/icon.png
old mode 100755
new mode 100644
index a9dc4537..15f6e1b2
Binary files a/res/drawable-hdpi/icon.png and b/res/drawable-hdpi/icon.png differ
diff --git a/res/drawable-large-hdpi/icon.png b/res/drawable-large-hdpi/icon.png
old mode 100755
new mode 100644
index a9dc4537..15f6e1b2
Binary files a/res/drawable-large-hdpi/icon.png and b/res/drawable-large-hdpi/icon.png differ
diff --git a/res/drawable-mdpi/icon.png b/res/drawable-mdpi/icon.png
old mode 100755
new mode 100644
index c9874140..4688de55
Binary files a/res/drawable-mdpi/icon.png and b/res/drawable-mdpi/icon.png differ
diff --git a/res/drawable-xhdpi/icon.png b/res/drawable-xhdpi/icon.png
old mode 100755
new mode 100644
index 485c3c3f..5c547a6e
Binary files a/res/drawable-xhdpi/icon.png and b/res/drawable-xhdpi/icon.png differ
diff --git a/res/drawable-xlarge-hdpi/icon.png b/res/drawable-xlarge-hdpi/icon.png
old mode 100755
new mode 100644
index a9dc4537..15f6e1b2
Binary files a/res/drawable-xlarge-hdpi/icon.png and b/res/drawable-xlarge-hdpi/icon.png differ
diff --git a/res/drawable/icon.png b/res/drawable/icon.png
old mode 100755
new mode 100644
index c9874140..4688de55
Binary files a/res/drawable/icon.png and b/res/drawable/icon.png differ
diff --git a/res/layout-large/gui_almalence_layout.xml b/res/layout-large/gui_almalence_layout.xml
index 78e62919..6ca07888 100755
--- a/res/layout-large/gui_almalence_layout.xml
+++ b/res/layout-large/gui_almalence_layout.xml
@@ -152,7 +152,7 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/plugin_vf_barcodescanner_view_layout_landscape.xml b/res/layout/plugin_vf_barcodescanner_view_layout_landscape.xml
index 464a0783..7ae56a40 100755
--- a/res/layout/plugin_vf_barcodescanner_view_layout_landscape.xml
+++ b/res/layout/plugin_vf_barcodescanner_view_layout_landscape.xml
@@ -1,6 +1,6 @@
ABC Widget. Nabízí rychlý přístup k jakémukoli režimu snímání již z domovské obrazovky!
+Vyzkoušejte také náš ABC Widget. Nabízí rychlý přístup k jakémukoli režimu snímání již z domovské obrazovky!
Již nebudete mít několik aplikací pro focení. A Better Camera umí všechno, co potřebujete.
diff --git a/res/values-hr/description_strings.xml b/res/values-hr/description_strings.xml
index ca4cb64d..700fcb28 100755
--- a/res/values-hr/description_strings.xml
+++ b/res/values-hr/description_strings.xml
@@ -19,7 +19,7 @@ Za sve prilike, sve mogućnosti za kameru Android:
+ mogućnost pristupa svim opcijama kamere, opcije i mogućnosti
-Isprobaj ABC Widget. Brzi pristup programu sa pozadine mobitela!
+Isprobaj ABC Widget. Brzi pristup programu sa pozadine mobitela!
Zaboravi loše programe koji ne imaju sve, A Better Camera ima sve što je u mogućnosti kamere!
diff --git a/res/values-pl-rPL/description.xml b/res/values-pl-rPL/description.xml
index cc2335d7..2f5c4c6a 100755
--- a/res/values-pl-rPL/description.xml
+++ b/res/values-pl-rPL/description.xml
@@ -16,7 +16,7 @@
+ pełny dostęp do wszystkich elementów sterujących aparatem, ustawieniami i funkcjami
-Wypróbuj nasz Widżet ABC. Szybki dostęp do dowolnego trybu na ekranie głównym!
+Wypróbuj nasz Widżet ABC. Szybki dostęp do dowolnego trybu na ekranie głównym!
Zapomnij o konieczności posiadania dziesiątek aplikacji aparatu. A Better Camera ma wszystko, czego potrzebujesz.
diff --git a/res/values/array_plugin_capture_focusbracketing.xml b/res/values/array_plugin_capture_focusbracketing.xml
new file mode 100755
index 00000000..82207879
--- /dev/null
+++ b/res/values/array_plugin_capture_focusbracketing.xml
@@ -0,0 +1,16 @@
+
+
+
+
+ - @string/Pref_FocusBracketingMode_standard
+ - @string/Pref_FocusBracketingMode_macro
+ - @string/Pref_FocusBracketingMode_fullrange
+
+
+
+ - 0
+ - 1
+ - 2
+
+
+
diff --git a/res/values/array_plugin_processing_focusstacking.xml b/res/values/array_plugin_processing_focusstacking.xml
new file mode 100644
index 00000000..0e3ef27c
--- /dev/null
+++ b/res/values/array_plugin_processing_focusstacking.xml
@@ -0,0 +1,24 @@
+
+
+
+
+ - @string/Pref_SaveMode_resultonly
+ - @string/Pref_SaveMode_processed
+ - @string/Pref_SaveMode_all
+
+
+
+ - 0
+ - 1
+ - 2
+
+
+
+ - @string/dimensions_none
+
+
+
+ - 0
+
+
+
\ No newline at end of file
diff --git a/res/values/strings_modes.xml b/res/values/strings_modes.xml
index 9d606a7d..f513bd30 100755
--- a/res/values/strings_modes.xml
+++ b/res/values/strings_modes.xml
@@ -12,6 +12,9 @@
Expo-bracketing
+ Focus-bracketing
+
+
HDR
diff --git a/res/values/strings_opencamera.xml b/res/values/strings_opencamera.xml
index d7f1bba6..5679c454 100755
--- a/res/values/strings_opencamera.xml
+++ b/res/values/strings_opencamera.xml
@@ -3,12 +3,12 @@
%1$s mode free shots left: %2$d
Free %1$s shots exhausted, please unlock
- A Better Camera
- A Better Camera v3.40\n(©) by Almalence Inc
+ Focus Stacking Camera
+ Focus Stacking Camera v1.00\n(©) by Almalence Inc
Error: Unable to save image!
Use this folder
diff --git a/res/values/strings_plugin_capture_focusbracketing.xml b/res/values/strings_plugin_capture_focusbracketing.xml
new file mode 100755
index 00000000..cae82fc8
--- /dev/null
+++ b/res/values/strings_plugin_capture_focusbracketing.xml
@@ -0,0 +1,17 @@
+
+
+ Focusbracketing capture
+ Shot mode
+
+ focusPrefFocusBracketing
+
+ Standard
+ Macro
+ Full range
+
+
+ Edit mode
+ Start edit mode after burst capturing finished
+ focusPrefFocusBracketingEditMode
+
+
diff --git a/res/values/strings_plugin_processing_focusstacking.xml b/res/values/strings_plugin_processing_focusstacking.xml
new file mode 100755
index 00000000..fedbe52f
--- /dev/null
+++ b/res/values/strings_plugin_processing_focusstacking.xml
@@ -0,0 +1,15 @@
+
+
+ Processing
+
+ Save mode
+ \"All in focus\" result only
+ Result plus aligned input frames
+ All frames (result, aligned, input)
+
+ outputImageSizePrefCommonFront
+ outputImageSizePrefCommonBack
+ fStackingSaveModePref
+ Output resolution
+
+
diff --git a/res/values/strings_preferences_modes.xml b/res/values/strings_preferences_modes.xml
index 30ccb4ab..c53443e9 100755
--- a/res/values/strings_preferences_modes.xml
+++ b/res/values/strings_preferences_modes.xml
@@ -6,6 +6,7 @@
Self-timer
Burst
Expo-bracketing
+ Focus-bracketing
HDR
Night
Super
diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml
index 7f8eb9b3..2c263a68 100755
--- a/res/xml/preferences.xml
+++ b/res/xml/preferences.xml
@@ -1,7 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/xml/preferences_capture_night.xml b/res/xml/preferences_capture_night.xml
index 1feecae4..bf58e281 100755
--- a/res/xml/preferences_capture_night.xml
+++ b/res/xml/preferences_capture_night.xml
@@ -12,7 +12,7 @@
@@ -41,31 +41,31 @@
+
+
+
+
\ No newline at end of file
diff --git a/res/xml/preferences_processing_hdr.xml b/res/xml/preferences_processing_hdr.xml
index 00692a70..6e70a0ae 100755
--- a/res/xml/preferences_processing_hdr.xml
+++ b/res/xml/preferences_processing_hdr.xml
@@ -11,7 +11,7 @@
-
*/
//
@@ -22,11 +22,10 @@
import android.preference.PreferenceManager;
/* */
//
+import com.almalence.focuscam.cameracontroller.CameraController;
public class AlarmReceiver extends BroadcastReceiver
{
diff --git a/src/com/almalence/opencam/ApplicationInterface.java b/src/com/almalence/focuscam/ApplicationInterface.java
similarity index 96%
rename from src/com/almalence/opencam/ApplicationInterface.java
rename to src/com/almalence/focuscam/ApplicationInterface.java
index 2c5c6ead..e6ec15cc 100644
--- a/src/com/almalence/opencam/ApplicationInterface.java
+++ b/src/com/almalence/focuscam/ApplicationInterface.java
@@ -17,17 +17,17 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
/* */
//
import com.almalence.sony.cameraremote.SimpleStreamSurfaceView;
@@ -136,6 +136,10 @@ public interface ApplicationInterface
//Used to re-initialize camera object if needed.
public void relaunchCamera();
+ //Used to re-initialize camera object in time.
+ public void pauseCamera();
+ public void resumeCamera();
+
//Inform Application that current capturing is failed.
public void captureFailed();
diff --git a/src/com/almalence/opencam/ApplicationScreen.java b/src/com/almalence/focuscam/ApplicationScreen.java
similarity index 98%
rename from src/com/almalence/opencam/ApplicationScreen.java
rename to src/com/almalence/focuscam/ApplicationScreen.java
index e8a464c6..3b045cb2 100644
--- a/src/com/almalence/opencam/ApplicationScreen.java
+++ b/src/com/almalence/focuscam/ApplicationScreen.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
import java.io.File;
@@ -77,16 +77,16 @@ Portions created by Initial Developer are Copyright (C) 2013
/* */
//
import com.almalence.sony.cameraremote.SimpleStreamSurfaceView;
@@ -1178,6 +1178,27 @@ public void onFinish()
ApplicationScreen.instance.resumeMain();
}
}
+
+ @Override
+ public void pauseCamera()
+ {
+ CameraController.onPause(true);
+
+ if (CameraController.isRemoteCamera())
+ stopRemotePreview();
+ }
+
+ @Override
+ public void resumeCamera()
+ {
+ CameraController.onResume();
+
+ // One of device camera is selected.
+ if (CameraController.isUseCamera2())
+ CameraController.setupCamera(null, true);
+ else if ((surfaceCreated && (!CameraController.isCameraCreated())))
+ CameraController.setupCamera(surfaceHolder, true);
+ }
protected long getAvailableInternalMemory()
{
diff --git a/src/com/almalence/opencam/CameraParameters.java b/src/com/almalence/focuscam/CameraParameters.java
similarity index 98%
rename from src/com/almalence/opencam/CameraParameters.java
rename to src/com/almalence/focuscam/CameraParameters.java
index d4b9601b..e699c660 100755
--- a/src/com/almalence/opencam/CameraParameters.java
+++ b/src/com/almalence/focuscam/CameraParameters.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
diff --git a/src/com/almalence/opencam/ConfigParser.java b/src/com/almalence/focuscam/ConfigParser.java
similarity index 91%
rename from src/com/almalence/opencam/ConfigParser.java
rename to src/com/almalence/focuscam/ConfigParser.java
index 0cb9a8bb..19d42419 100755
--- a/src/com/almalence/opencam/ConfigParser.java
+++ b/src/com/almalence/focuscam/ConfigParser.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
import java.io.IOException;
@@ -34,10 +34,10 @@ Portions created by Initial Developer are Copyright (C) 2013
import org.xmlpull.v1.XmlPullParserException;
/* */
//
import android.content.Context;
@@ -174,20 +174,20 @@ private String readDefaultMode(XmlPullParser parser) throws XmlPullParserExcepti
parser.require(XmlPullParser.START_TAG, ns, "defaultmode");
String modeID = parser.getAttributeValue(null, "id");
- //set super mode by default on these devices
- if (CameraController.isNexus5or6 ||
- CameraController.isFlex2 ||
- CameraController.isOnePlusTwo||
- CameraController.isGalaxyS7)
- {
- Iterator it = modes.iterator();
- while(it.hasNext())
- {
- Mode mode = it.next();
- if(mode.modeID.contains("nightmode"))
- modeID = "nightmode";
- }
- }
+ //set super mode by default on these devices (only for A Better Camera)
+// if (CameraController.isNexus5or6 ||
+// CameraController.isFlex2 ||
+// CameraController.isOnePlusTwo||
+// CameraController.isGalaxyS7)
+// {
+// Iterator it = modes.iterator();
+// while(it.hasNext())
+// {
+// Mode mode = it.next();
+// if(mode.modeID.contains("nightmode"))
+// modeID = "nightmode";
+// }
+// }
parser.nextTag();
return modeID;
diff --git a/src/com/almalence/opencam/FolderPicker.java b/src/com/almalence/focuscam/FolderPicker.java
similarity index 95%
rename from src/com/almalence/opencam/FolderPicker.java
rename to src/com/almalence/focuscam/FolderPicker.java
index d4d0268d..89a6a565 100755
--- a/src/com/almalence/opencam/FolderPicker.java
+++ b/src/com/almalence/focuscam/FolderPicker.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
import java.io.File;
@@ -28,6 +28,8 @@ Portions created by Initial Developer are Copyright (C) 2013
import java.util.Collections;
import java.util.Comparator;
+import com.almalence.focuscam.R;
+
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
diff --git a/src/com/almalence/opencam/FolderPickerLollipop.java b/src/com/almalence/focuscam/FolderPickerLollipop.java
similarity index 94%
rename from src/com/almalence/opencam/FolderPickerLollipop.java
rename to src/com/almalence/focuscam/FolderPickerLollipop.java
index d9c4c4a3..6e66e5d3 100644
--- a/src/com/almalence/opencam/FolderPickerLollipop.java
+++ b/src/com/almalence/focuscam/FolderPickerLollipop.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
import java.io.File;
diff --git a/src/com/almalence/opencam/Fragment.java b/src/com/almalence/focuscam/Fragment.java
similarity index 98%
rename from src/com/almalence/opencam/Fragment.java
rename to src/com/almalence/focuscam/Fragment.java
index da1bf685..131dffff 100755
--- a/src/com/almalence/opencam/Fragment.java
+++ b/src/com/almalence/focuscam/Fragment.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
@@ -64,14 +64,15 @@ Portions created by Initial Developer are Copyright (C) 2013
import android.widget.Toast;
/* */
//
diff --git a/src/com/almalence/opencam/HWButtonStart.java b/src/com/almalence/focuscam/HWButtonStart.java
similarity index 96%
rename from src/com/almalence/opencam/HWButtonStart.java
rename to src/com/almalence/focuscam/HWButtonStart.java
index f59df5bb..a617c0fa 100755
--- a/src/com/almalence/opencam/HWButtonStart.java
+++ b/src/com/almalence/focuscam/HWButtonStart.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
import android.content.BroadcastReceiver;
diff --git a/src/com/almalence/opencam/MainScreen.java b/src/com/almalence/focuscam/MainScreen.java
similarity index 98%
rename from src/com/almalence/opencam/MainScreen.java
rename to src/com/almalence/focuscam/MainScreen.java
index dd2ee110..e252100d 100755
--- a/src/com/almalence/opencam/MainScreen.java
+++ b/src/com/almalence/focuscam/MainScreen.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
import java.io.File;
@@ -96,17 +96,18 @@ Portions created by Initial Developer are Copyright (C) 2013
import com.almalence.util.Util;
//
/* */
/***
@@ -1634,17 +1635,17 @@ public boolean onKeyDownEvent(int keyCode, KeyEvent event)
return true;
//
return false;
@@ -2732,7 +2733,7 @@ public static boolean checkLaunches(Mode mode)
if (mode.SKU.isEmpty())
{
int launchesLeft = MainScreen.getLeftLaunches(mode.modeID);
-// launchesLeft = 100; //Using for testing free version
+ launchesLeft = 100; //Using for testing free version
if ((1 == launchesLeft) || (3 == launchesLeft))
{
@@ -2772,7 +2773,7 @@ public static boolean checkLaunches(Mode mode)
}
int launchesLeft = MainScreen.getLeftLaunches(mode.modeID);
-// launchesLeft = 100; //Using for testing free version
+ launchesLeft = 100; //Using for testing free version
int id = MainScreen.getAppResources().getIdentifier(
(CameraController.isUseCamera2() ? mode.modeNameHAL : mode.modeName), "string",
MainScreen.thiz.getPackageName());
@@ -2874,7 +2875,7 @@ private boolean isABCUnlockedInstalled(Activity activity)
{
try
{
- activity.getPackageManager().getInstallerPackageName("com.almalence.opencam_plus");
+ activity.getPackageManager().getInstallerPackageName("com.almalence.focuscam_plus");
} catch (IllegalArgumentException e)
{
return false;
@@ -2888,7 +2889,7 @@ private static void callStoreForUnlocked(Activity activity)
try
{
Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setData(Uri.parse("market://details?id=com.almalence.opencam_plus"));
+ intent.setData(Uri.parse("market://details?id=com.almalence.focuscam_plus"));
activity.startActivity(intent);
} catch (ActivityNotFoundException e)
{
@@ -2926,7 +2927,7 @@ public static void callStoreFree(Activity act)
try
{
Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setData(Uri.parse("market://details?id=com.almalence.opencam"));
+ intent.setData(Uri.parse("market://details?id=com.almalence.focuscam"));
act.startActivity(intent);
} catch (ActivityNotFoundException e)
{
@@ -2957,7 +2958,7 @@ protected void resetOrSaveSettings()
boolean isSaving = prefs.getBoolean("SaveConfiguration_Mode", true);
if (!isSaving)
{
- prefsEditor.putString("defaultModeName", "single");
+ prefsEditor.putString("defaultModeName", "focusbracketing");
prefsEditor.commit();
}
diff --git a/src/com/almalence/opencam/Mode.java b/src/com/almalence/focuscam/Mode.java
similarity index 97%
rename from src/com/almalence/opencam/Mode.java
rename to src/com/almalence/focuscam/Mode.java
index 4a0836a9..2ee26021 100755
--- a/src/com/almalence/opencam/Mode.java
+++ b/src/com/almalence/focuscam/Mode.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
import java.util.ArrayList;
diff --git a/src/com/almalence/opencam/NotificationService.java b/src/com/almalence/focuscam/NotificationService.java
similarity index 96%
rename from src/com/almalence/opencam/NotificationService.java
rename to src/com/almalence/focuscam/NotificationService.java
index 7151888b..90c261af 100644
--- a/src/com/almalence/opencam/NotificationService.java
+++ b/src/com/almalence/focuscam/NotificationService.java
@@ -17,13 +17,15 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
+import com.almalence.focuscam.R;
+
import android.app.Notification;
import android.app.Service;
import android.content.Intent;
diff --git a/src/com/almalence/opencam/Plugin.java b/src/com/almalence/focuscam/Plugin.java
similarity index 97%
rename from src/com/almalence/opencam/Plugin.java
rename to src/com/almalence/focuscam/Plugin.java
index 5fa26914..6e463325 100755
--- a/src/com/almalence/opencam/Plugin.java
+++ b/src/com/almalence/focuscam/Plugin.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
import java.util.ArrayList;
@@ -52,16 +52,16 @@ Portions created by Initial Developer are Copyright (C) 2013
import android.widget.ImageView;
import com.almalence.asynctaskmanager.Task;
+import com.almalence.focuscam.cameracontroller.CameraController;
+import com.almalence.focuscam.cameracontroller.CameraController.Size;
/* */
//
diff --git a/src/com/almalence/opencam/PluginCapture.java b/src/com/almalence/focuscam/PluginCapture.java
similarity index 93%
rename from src/com/almalence/opencam/PluginCapture.java
rename to src/com/almalence/focuscam/PluginCapture.java
index 29499276..7ee33f8c 100755
--- a/src/com/almalence/opencam/PluginCapture.java
+++ b/src/com/almalence/focuscam/PluginCapture.java
@@ -17,13 +17,13 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
import java.util.Date;
diff --git a/src/com/almalence/opencam/PluginExport.java b/src/com/almalence/focuscam/PluginExport.java
similarity index 93%
rename from src/com/almalence/opencam/PluginExport.java
rename to src/com/almalence/focuscam/PluginExport.java
index 696b7e45..54698e8a 100755
--- a/src/com/almalence/opencam/PluginExport.java
+++ b/src/com/almalence/focuscam/PluginExport.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
diff --git a/src/com/almalence/opencam/PluginManager.java b/src/com/almalence/focuscam/PluginManager.java
similarity index 97%
rename from src/com/almalence/opencam/PluginManager.java
rename to src/com/almalence/focuscam/PluginManager.java
index 971a5b65..ee925169 100644
--- a/src/com/almalence/opencam/PluginManager.java
+++ b/src/com/almalence/focuscam/PluginManager.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
@@ -58,6 +58,7 @@ Portions created by Initial Developer are Copyright (C) 2013
import com.almalence.plugins.capture.bestshot.BestShotCapturePlugin;
import com.almalence.plugins.capture.burst.BurstCapturePlugin;
import com.almalence.plugins.capture.expobracketing.ExpoBracketingCapturePlugin;
+import com.almalence.plugins.capture.focusbracketing.FocusBracketingCapturePlugin;
import com.almalence.plugins.capture.multishot.MultiShotCapturePlugin;
import com.almalence.plugins.capture.night.NightCapturePlugin;
import com.almalence.plugins.capture.panoramaaugmented.PanoramaAugmentedCapturePlugin;
@@ -67,6 +68,7 @@ Portions created by Initial Developer are Copyright (C) 2013
import com.almalence.plugins.export.standard.ExportPlugin;
import com.almalence.plugins.processing.bestshot.BestshotProcessingPlugin;
import com.almalence.plugins.processing.hdr.HDRProcessingPlugin;
+import com.almalence.plugins.processing.focusstacking.FocusStackingProcessingPlugin;
import com.almalence.plugins.processing.multishot.MultiShotProcessingRouter;
import com.almalence.plugins.processing.night.NightProcessingPlugin;
import com.almalence.plugins.processing.panorama.PanoramaProcessingPlugin;
@@ -81,12 +83,13 @@ Portions created by Initial Developer are Copyright (C) 2013
import com.almalence.plugins.vf.infoset.InfosetVFPlugin;
import com.almalence.plugins.vf.zoom.ZoomVFPlugin;
/* */
//
@@ -186,6 +189,10 @@ protected void createPlugins()
ExpoBracketingCapturePlugin expoBracketingCapturePlugin = new ExpoBracketingCapturePlugin();
pluginList.put(expoBracketingCapturePlugin.getID(), expoBracketingCapturePlugin);
listCapture.add(expoBracketingCapturePlugin);
+
+ FocusBracketingCapturePlugin focusBracketingCapturePlugin = new FocusBracketingCapturePlugin();
+ pluginList.put(focusBracketingCapturePlugin.getID(), focusBracketingCapturePlugin);
+ listCapture.add(focusBracketingCapturePlugin);
NightCapturePlugin nightCapturePlugin = new NightCapturePlugin();
pluginList.put(nightCapturePlugin.getID(), nightCapturePlugin);
@@ -231,6 +238,10 @@ protected void createPlugins()
HDRProcessingPlugin hdrProcessingPlugin = new HDRProcessingPlugin();
pluginList.put(hdrProcessingPlugin.getID(), hdrProcessingPlugin);
listProcessing.add(hdrProcessingPlugin);
+
+ FocusStackingProcessingPlugin focusStackingProcessingPlugin = new FocusStackingProcessingPlugin();
+ pluginList.put(focusStackingProcessingPlugin.getID(), focusStackingProcessingPlugin);
+ listProcessing.add(focusStackingProcessingPlugin);
MultiShotProcessingRouter multiShotProcessingPlugin = new MultiShotProcessingRouter();
pluginList.put(multiShotProcessingPlugin.getID(), multiShotProcessingPlugin);
@@ -596,6 +607,9 @@ public void loadHeaderContent(String settings, PreferenceFragment pf)
} else if ("expobracketing".equals(settings))
{
AddModeSettings("expobracketing", pf);
+ } else if ("focusbracketing".equals(settings))
+ {
+ AddModeSettings("focusbracketing", pf);
} else if ("hdr".equals(settings))
{
AddModeSettings("hdrmode", pf);
@@ -984,10 +998,13 @@ public boolean handleApplicationMessage(Message msg)
pluginList.get(activeProcessing).onStartPostProcessing();
ApplicationScreen.getGUIManager().onPostProcessingStarted();
+
+ ApplicationScreen.instance.pauseCamera();
}
break;
case ApplicationInterface.MSG_POSTPROCESSING_FINISHED:
+ ApplicationScreen.instance.resumeCamera();
sessionID = 0;
String sSessionID = getFromSharedMem("sessionID");
if (sSessionID != null)
diff --git a/src/com/almalence/opencam/PluginManagerBase.java b/src/com/almalence/focuscam/PluginManagerBase.java
similarity index 90%
rename from src/com/almalence/opencam/PluginManagerBase.java
rename to src/com/almalence/focuscam/PluginManagerBase.java
index 25345b9f..8e3ba0e2 100644
--- a/src/com/almalence/opencam/PluginManagerBase.java
+++ b/src/com/almalence/focuscam/PluginManagerBase.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
@@ -83,10 +83,11 @@ Portions created by Initial Developer are Copyright (C) 2013
import com.almalence.util.exifreader.metadata.exif.ExifSubIFDDirectory;
/* */
//
@@ -791,6 +792,8 @@ public void onCameraParametersSetup()
pluginList.get(activeVF.get(i)).onCameraParametersSetup();
if (null != pluginList.get(activeCapture))
pluginList.get(activeCapture).onCameraParametersSetup();
+ if (null != pluginList.get(activeProcessing))
+ pluginList.get(activeProcessing).onCameraParametersSetup();
}
public void onCameraSetup()
@@ -1651,6 +1654,193 @@ private void saveInputFileNew(boolean isYUV, Long SessionID, int i, byte[] buffe
ApplicationScreen.instance.getContentResolver().insert(Images.Media.EXTERNAL_CONTENT_URI, values);
}
+ public void saveInputFileMPO(boolean isYUV, Long SessionID, int nFrames, int[] yuvBuffer, String fileFormat)
+ {
+ CameraController.Size imageSize = CameraController.getCameraImageSize();
+ ContentValues values = null;
+ String resultOrientation = getFromSharedMem("frameorientation1" + Long.toString(SessionID));
+ String resultMirrored = getFromSharedMem("framemirrored1" + Long.toString(SessionID));
+
+ Boolean cameraMirrored = false;
+ if (resultMirrored != null)
+ cameraMirrored = Boolean.parseBoolean(resultMirrored);
+
+ int mDisplayOrientation = 0;
+ if (resultOrientation != null)
+ {
+ mDisplayOrientation = Integer.parseInt(resultOrientation);
+ }
+
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext());
+ boolean saveGeoInfo = prefs.getBoolean("useGeoTaggingPrefExport", false);
+
+ File saveDir = getSaveDir(false);
+ File file = new File(saveDir, fileFormat + ".mpo");
+ FileOutputStream os = null;
+
+ try
+ {
+ try
+ {
+ os = new FileOutputStream(file);
+ } catch (Exception e)
+ {
+ // save always if not working saving to sdcard
+ e.printStackTrace();
+ saveDir = getSaveDir(true);
+ file = new File(saveDir, fileFormat + ".mpo");
+
+ os = new FileOutputStream(file);
+ }
+ } catch (FileNotFoundException e1)
+ {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+ try
+ {
+ if (os != null)
+ {
+
+ for(int i = 0; i < nFrames; i++)
+ {
+ jpegQuality = Integer.parseInt(prefs.getString(MainScreen.sJPEGQualityPref, "95"));
+
+ com.almalence.YuvImage image = new com.almalence.YuvImage(yuvBuffer[i], ImageFormat.NV21,
+ imageSize.getWidth(), imageSize.getHeight(), null);
+ // to avoid problems with SKIA
+ int cropHeight = image.getHeight() - image.getHeight() % 16;
+ image.compressToJpeg(new Rect(0, 0, image.getWidth(), cropHeight), jpegQuality, os);
+ }
+
+ mDisplayOrientation = saveExifToInput(file, mDisplayOrientation, cameraMirrored, saveGeoInfo);
+
+ os.close();
+ }
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ values = new ContentValues();
+ values.put(ImageColumns.TITLE, file.getName().substring(0, file.getName().lastIndexOf(".")));
+ values.put(ImageColumns.DISPLAY_NAME, file.getName());
+ values.put(ImageColumns.DATE_TAKEN, System.currentTimeMillis());
+ values.put(ImageColumns.MIME_TYPE, "image/jpeg");
+ values.put(ImageColumns.ORIENTATION, mDisplayOrientation);
+ values.put(ImageColumns.DATA, file.getAbsolutePath());
+
+ if (saveGeoInfo)
+ {
+ Location l = MLocation.getLocation(ApplicationScreen.getMainContext());
+
+ if (l != null)
+ {
+ values.put(ImageColumns.LATITUDE, l.getLatitude());
+ values.put(ImageColumns.LONGITUDE, l.getLongitude());
+ }
+ }
+
+ ApplicationScreen.instance.getContentResolver().insert(Images.Media.EXTERNAL_CONTENT_URI, values);
+ }
+
+
+ public void saveFocusAreasFile(int yuvBuffer, String fileFormat, int mImageWidth, int mImageHeight)
+ {
+
+ ContentValues values = null;
+
+ DocumentFile file;
+ DocumentFile saveDir = getSaveDirNew(false);
+ if (saveDir == null || !saveDir.exists())
+ {
+ return;
+ }
+
+ file = saveDir.createFile("image/jpeg", fileFormat);
+ if (file == null || !file.canWrite())
+ {
+ return;
+ }
+
+ OutputStream os = null;
+ File bufFile = new File(ApplicationScreen.instance.getFilesDir(), "buffer.jpeg");
+ try
+ {
+ os = new FileOutputStream(bufFile);
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ if (os != null)
+ {
+ try
+ {
+ jpegQuality = 95;
+
+ com.almalence.YuvImage image = new com.almalence.YuvImage(yuvBuffer, ImageFormat.NV21,
+ mImageWidth, mImageHeight, null);
+ // to avoid problems with SKIA
+ int cropHeight = image.getHeight() - image.getHeight() % 16;
+ image.compressToJpeg(new Rect(0, 0, image.getWidth(), cropHeight), jpegQuality, os);
+ os.close();
+ } catch (IOException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ // Copy buffer image with exif tags into result file.
+ InputStream is = null;
+ int len;
+ byte[] buf = new byte[1024];
+ try
+ {
+ os = ApplicationScreen.instance.getContentResolver().openOutputStream(file.getUri());
+ is = new FileInputStream(bufFile);
+ while ((len = is.read(buf)) > 0)
+ {
+ os.write(buf, 0, len);
+ }
+ is.close();
+ os.close();
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ bufFile.delete();
+
+ values = new ContentValues();
+ values.put(ImageColumns.TITLE, file.getName().substring(0, file.getName().lastIndexOf(".")));
+ values.put(ImageColumns.DISPLAY_NAME, file.getName());
+ values.put(ImageColumns.DATE_TAKEN, System.currentTimeMillis());
+ values.put(ImageColumns.MIME_TYPE, "image/jpeg");
+ values.put(ImageColumns.ORIENTATION, 0);
+
+ String filePath = file.getName();
+ // If we able to get File object, than get path from it.
+ // fileObject should not be null for files on phone memory.
+ File fileObject = Util.getFileFromDocumentFile(file);
+ if (fileObject != null)
+ {
+ filePath = fileObject.getAbsolutePath();
+ values.put(ImageColumns.DATA, filePath);
+ } else
+ {
+ // This case should typically happen for files saved to SD
+ // card.
+ String documentPath = Util.getAbsolutePathFromDocumentFile(file);
+ values.put(ImageColumns.DATA, documentPath);
+ }
+
+ ApplicationScreen.instance.getContentResolver().insert(Images.Media.EXTERNAL_CONTENT_URI, values);
+ }
+
+
public static int saveExifToInput(File file, int displayOrientation, boolean cameraMirrored, boolean saveGeo)
{
try
diff --git a/src/com/almalence/opencam/PluginManagerInterface.java b/src/com/almalence/focuscam/PluginManagerInterface.java
similarity index 96%
rename from src/com/almalence/opencam/PluginManagerInterface.java
rename to src/com/almalence/focuscam/PluginManagerInterface.java
index 741b66b8..4139028f 100755
--- a/src/com/almalence/opencam/PluginManagerInterface.java
+++ b/src/com/almalence/focuscam/PluginManagerInterface.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
import android.hardware.camera2.CaptureResult;
diff --git a/src/com/almalence/opencam/PluginProcessing.java b/src/com/almalence/focuscam/PluginProcessing.java
similarity index 94%
rename from src/com/almalence/opencam/PluginProcessing.java
rename to src/com/almalence/focuscam/PluginProcessing.java
index 0d608e01..f15cb1cb 100755
--- a/src/com/almalence/opencam/PluginProcessing.java
+++ b/src/com/almalence/focuscam/PluginProcessing.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
public abstract class PluginProcessing extends Plugin
diff --git a/src/com/almalence/opencam/PluginType.java b/src/com/almalence/focuscam/PluginType.java
similarity index 92%
rename from src/com/almalence/opencam/PluginType.java
rename to src/com/almalence/focuscam/PluginType.java
index b4963176..1b7106d4 100755
--- a/src/com/almalence/opencam/PluginType.java
+++ b/src/com/almalence/focuscam/PluginType.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
/***
diff --git a/src/com/almalence/opencam/PluginViewfinder.java b/src/com/almalence/focuscam/PluginViewfinder.java
similarity index 93%
rename from src/com/almalence/opencam/PluginViewfinder.java
rename to src/com/almalence/focuscam/PluginViewfinder.java
index 907fbd35..ed332880 100755
--- a/src/com/almalence/opencam/PluginViewfinder.java
+++ b/src/com/almalence/focuscam/PluginViewfinder.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
public abstract class PluginViewfinder extends Plugin
diff --git a/src/com/almalence/opencam/Preferences.java b/src/com/almalence/focuscam/Preferences.java
similarity index 97%
rename from src/com/almalence/opencam/Preferences.java
rename to src/com/almalence/focuscam/Preferences.java
index 5257bb49..d3522de7 100755
--- a/src/com/almalence/opencam/Preferences.java
+++ b/src/com/almalence/focuscam/Preferences.java
@@ -17,14 +17,16 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
import java.util.List;
+import com.almalence.focuscam.R;
+
import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.content.Intent;
diff --git a/src/com/almalence/opencam/ProcessingService.java b/src/com/almalence/focuscam/ProcessingService.java
similarity index 97%
rename from src/com/almalence/opencam/ProcessingService.java
rename to src/com/almalence/focuscam/ProcessingService.java
index 8aafb030..80f2d959 100644
--- a/src/com/almalence/opencam/ProcessingService.java
+++ b/src/com/almalence/focuscam/ProcessingService.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
diff --git a/src/com/almalence/opencam/SavingService.java b/src/com/almalence/focuscam/SavingService.java
similarity index 99%
rename from src/com/almalence/opencam/SavingService.java
rename to src/com/almalence/focuscam/SavingService.java
index cd0f8603..a7e2b57a 100644
--- a/src/com/almalence/opencam/SavingService.java
+++ b/src/com/almalence/focuscam/SavingService.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
@@ -80,11 +80,11 @@ Portions created by Initial Developer are Copyright (C) 2013
import com.almalence.util.Util;
/* */
//
+import com.almalence.focuscam.cameracontroller.CameraController;
+import com.almalence.focuscam.R;
public class SavingService extends NotificationService
{
diff --git a/src/com/almalence/opencam/SoundPlayer.java b/src/com/almalence/focuscam/SoundPlayer.java
similarity index 97%
rename from src/com/almalence/opencam/SoundPlayer.java
rename to src/com/almalence/focuscam/SoundPlayer.java
index 597cf01c..28b8b12c 100755
--- a/src/com/almalence/opencam/SoundPlayer.java
+++ b/src/com/almalence/focuscam/SoundPlayer.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
import java.io.IOException;
diff --git a/src/com/almalence/opencam/cameracontroller/Camera2Controller.java b/src/com/almalence/focuscam/cameracontroller/Camera2Controller.java
similarity index 94%
rename from src/com/almalence/opencam/cameracontroller/Camera2Controller.java
rename to src/com/almalence/focuscam/cameracontroller/Camera2Controller.java
index 29927c3e..c3e10e55 100755
--- a/src/com/almalence/opencam/cameracontroller/Camera2Controller.java
+++ b/src/com/almalence/focuscam/cameracontroller/Camera2Controller.java
@@ -17,10 +17,10 @@
*/
/* */
//
import java.nio.ByteBuffer;
@@ -72,17 +72,10 @@
import com.almalence.util.Util;
//
-/* */
+import com.almalence.focuscam.ApplicationInterface;
+import com.almalence.focuscam.ApplicationScreen;
+import com.almalence.focuscam.CameraParameters;
+import com.almalence.focuscam.PluginManagerInterface;
//Controller of camera2 interface
@@ -111,9 +104,13 @@ public class Camera2Controller
private static long[] exposureTime = null; //List of exposure time values for each requested shot.
private static long currentExposure = 0; //Exposure time of last captured frame
private static int currentSensitivity = 0; //Sensor sensitivity (ISO) of last captured frame
+ private static float[] focusDistance = null; //List of focus distance values for each requested shot
private static int blevel = 0; //Black level offset
private static int wlevel = 1024; //Maximum raw value output by sensor.
+ private static boolean fbRequested = false; //Flag to show that focus bracketing capture is needed
+ private static List fbRequests = null; //Capture requests for focus bracketing
+
private static boolean manualPowerGamma = false; //Used only for Almalence's SuperSensor mode
private static RggbChannelVector rggbChannelVector = null; //Gains applying to raw color channels for manual white-balance logic
@@ -226,7 +223,9 @@ public static boolean checkHardwareLevel()
Camera2Controller.getInstance().camCharacter = Camera2Controller.getInstance().manager
.getCameraCharacteristics(CameraController.cameraIdList[0]);
int level = Camera2Controller.getInstance().camCharacter.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);
- return (level == CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED || level == CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_FULL);
+ return (level == CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED ||
+ level == CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_FULL ||
+ level == 3);//CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_3);
// || level == CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY);
} catch (Exception e)
{
@@ -1316,6 +1315,23 @@ public static float getCameraMinimumFocusDistance()
return 0;
}
+ public static float getCameraHyperfocalFocusDistance()
+ {
+ if (Camera2Controller.getInstance().camCharacter != null &&
+ (Camera2Controller.getInstance().camCharacter.get(CameraCharacteristics.LENS_INFO_FOCUS_DISTANCE_CALIBRATION) ==
+ CameraCharacteristics.LENS_INFO_FOCUS_DISTANCE_CALIBRATION_APPROXIMATE ||
+ Camera2Controller.getInstance().camCharacter.get(CameraCharacteristics.LENS_INFO_FOCUS_DISTANCE_CALIBRATION) ==
+ CameraCharacteristics.LENS_INFO_FOCUS_DISTANCE_CALIBRATION_CALIBRATED))
+ return Camera2Controller.getInstance().camCharacter.get(CameraCharacteristics.LENS_INFO_HYPERFOCAL_DISTANCE);
+
+ return 0;
+ }
+
+ public static float getCameraFocusDistance()
+ {
+ return PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext()).getFloat(ApplicationScreen.sFocusDistancePref, -1);
+ }
+
public static long getCameraMinimumExposureTime()
{
if (Camera2Controller.getInstance().camCharacter != null
@@ -1774,7 +1790,7 @@ public static void setRepeatingRequest()
try
{
- Camera2Controller.getInstance().mCaptureSession.setRepeatingRequest(Camera2Controller.previewRequestBuilder.build(), captureCallback, null);
+ Camera2Controller.getInstance().mCaptureSession.setRepeatingRequest(Camera2Controller.previewRequestBuilder.build(), previewCaptureCallback, null);
} catch (CameraAccessException e)
{
e.printStackTrace();
@@ -2325,7 +2341,7 @@ else if(flashMode == CameraParameters.FLASH_MODE_TORCH || flashMode == CameraPar
// ev - exposure compensation
// gain - sensor sensitivity (ISO)
// expo - exposure time value in case of manual exposure time preference
- private static void SetupPerFrameParameters(int ev, int gain, long expo, boolean isRAWCapture)
+ private static void SetupPerFrameParameters(int ev, int gain, long expo, float focusDistance, boolean isRAWCapture)
{
// explicitly disable AWB for the duration of still/burst capture to get
// full burst with the same WB
@@ -2375,6 +2391,20 @@ private static void SetupPerFrameParameters(int ev, int gain, long expo, boolean
rawRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_OFF);
}
}
+
+ if(focusDistance != -1)
+ {
+ stillRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_OFF);
+ stillRequestBuilder.set(CaptureRequest.LENS_FOCUS_DISTANCE, focusDistance);
+
+ precaptureRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_OFF);
+ precaptureRequestBuilder.set(CaptureRequest.LENS_FOCUS_DISTANCE, focusDistance);
+ if(isRAWCapture)
+ {
+ rawRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_OFF);
+ rawRequestBuilder.set(CaptureRequest.LENS_FOCUS_DISTANCE, focusDistance);
+ }
+ }
}
@@ -2423,7 +2453,7 @@ private static CaptureRequest.Builder setConstantPowerGamma(CaptureRequest.Build
//it starts sequence of tuning still capture requests
//Call next methods only when capture become allowed (preview is focused)
public static int captureImageWithParamsCamera2(final int nFrames, final int format, final int[] pause,
- final int[] evRequested, final int[] gain, final long[] exposure,
+ final int[] evRequested, final int[] gain, final long[] exposure, final float[] focusDistances,
final boolean setPowerGamma, final boolean resInHeap, final boolean indication)
{
// inCapture = true; Debug variable. Used in logic to capture RAW in Super mode on Galaxy S6
@@ -2440,7 +2470,7 @@ public static int captureImageWithParamsCamera2(final int nFrames, final int for
{
try
{
- Camera2Controller.getInstance().mCaptureSession.capture(Camera2Controller.previewRequestBuilder.build(), captureCallback, null);
+ Camera2Controller.getInstance().mCaptureSession.capture(Camera2Controller.previewRequestBuilder.build(), previewCaptureCallback, null);
}
catch (CameraAccessException e)
{
@@ -2458,18 +2488,18 @@ public void onTick(long millisUntilFinished)
if (captureAllowed)
{
this.cancel();
- captureImageWithParamsCamera2Allowed(nFrames, format, pause, evRequested, gain, exposure, setPowerGamma, resInHeap, indication);
+ captureImageWithParamsCamera2Allowed(nFrames, format, pause, evRequested, gain, exposure, focusDistances, setPowerGamma, resInHeap, indication);
}
}
public void onFinish()
{
- captureImageWithParamsCamera2Allowed(nFrames, format, pause, evRequested, gain, exposure, setPowerGamma, resInHeap, indication);
+ captureImageWithParamsCamera2Allowed(nFrames, format, pause, evRequested, gain, exposure, focusDistances, setPowerGamma, resInHeap, indication);
}
}.start();
}
else
- captureImageWithParamsCamera2Allowed(nFrames, format, pause, evRequested, gain, exposure, setPowerGamma, resInHeap, indication);
+ captureImageWithParamsCamera2Allowed(nFrames, format, pause, evRequested, gain, exposure, focusDistances, setPowerGamma, resInHeap, indication);
return requestID;
}
@@ -2479,7 +2509,7 @@ public void onFinish()
//First of all make pre-capture request for exposure metering
//For all devices lower that HARDWARE_LEVEL_FULL or LIMITED just call capture method without pre-capture
public static void captureImageWithParamsCamera2Allowed (final int nFrames, final int format, final int[] pause,
- final int[] evRequested, final int[] gain, final long[] exposure, final boolean setPowerGamma, final boolean resInHeap, final boolean indication) {
+ final int[] evRequested, final int[] gain, final long[] exposure, final float[] focusDistances, final boolean setPowerGamma, final boolean resInHeap, final boolean indication) {
try
{
lastCaptureFormat = format;
@@ -2526,14 +2556,14 @@ public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest requ
CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER_IDLE);
captureImageWithParamsCamera2Simple(nFrames, format, pause,
- evRequested, gain, exposure, setPowerGamma, resInHeap, indication);
+ evRequested, gain, exposure, focusDistances, setPowerGamma, resInHeap, indication);
}
}, null);
}
} else
{
captureImageWithParamsCamera2Simple(nFrames, format, pause,
- evRequested, gain, exposure, setPowerGamma, resInHeap, indication);
+ evRequested, gain, exposure, focusDistances, setPowerGamma, resInHeap, indication);
}
} catch (CameraAccessException e)
{
@@ -2561,14 +2591,15 @@ public void handleMessage(Message msg)
pauseBetweenShots == null ? 0 : pauseBetweenShots[currentFrameIndex],
evCompensation == null ? 0 : evCompensation[currentFrameIndex],
sensorGain == null ? currentSensitivity : sensorGain[currentFrameIndex],
- exposureTime == null ? 0 : exposureTime[currentFrameIndex], manualPowerGamma);
+ exposureTime == null ? 0 : exposureTime[currentFrameIndex], focusDistance == null ? -1.0f : focusDistance[currentFrameIndex],
+ manualPowerGamma);
}
}
};
//Exact here we request capture session to capture frame
public static int captureImageWithParamsCamera2Simple(final int nFrames, final int format, final int[] pause,
- final int[] evRequested, final int[] gain, final long[] exposure,
+ final int[] evRequested, final int[] gain, final long[] exposure, final float[] focusDistances,
final boolean setPowerGamma, final boolean resInHeap, final boolean indication)
{
@@ -2608,6 +2639,7 @@ public static int captureImageWithParamsCamera2Simple(final int nFrames, final i
currentFrameIndex = 0;
pauseBetweenShots = pause;
evCompensation = evRequested;
+ focusDistance = focusDistances;
sensorGain = gain;
exposureTime = exposure;
@@ -2619,7 +2651,8 @@ public static int captureImageWithParamsCamera2Simple(final int nFrames, final i
pauseBetweenShots == null ? 0 : pauseBetweenShots[currentFrameIndex],
evCompensation == null ? selectedEvCompensation : evCompensation[currentFrameIndex],
sensorGain == null ? currentSensitivity : sensorGain[currentFrameIndex],
- exposureTime == null ? 0 : exposureTime[currentFrameIndex], manualPowerGamma);
+ exposureTime == null ? 0 : exposureTime[currentFrameIndex], focusDistance == null ? -1.0f : focusDistance[currentFrameIndex],
+ manualPowerGamma);
//Pre-capture was commented because it was second time when it called!
//First time it's calling in captureImageWithParamsCamera2Allowed method
@@ -2686,30 +2719,57 @@ public static int captureImageWithParamsCamera2Simple(final int nFrames, final i
// }
// }
- for (int n = 0; n < nFrames; ++n)
- {
- SetupPerFrameParameters(evRequested == null ? selectedEvCompensation : evRequested[n], gain == null ? currentSensitivity : gain[n],
- exposure == null ? 0 : exposure[n], isRAWCapture);
-
- if(Camera2Controller.getInstance().mCaptureSession != null)
+ if(focusDistances == null)
+ for (int n = 0; n < nFrames; ++n)
{
- try
- {
- requestID = Camera2Controller.getInstance().mCaptureSession.capture(stillRequestBuilder.build(),
- stillCaptureCallback, null);
+ SetupPerFrameParameters(evRequested == null ? selectedEvCompensation : evRequested[n], gain == null ? currentSensitivity : gain[n],
+ exposure == null ? 0 : exposure[n], focusDistances == null ? -1.0f : focusDistances[n], isRAWCapture);
- pluginManager.addRequestID(n, requestID);
- // FixMe: Why aren't requestID assigned if there is request with ev's being adjusted??
- // if (evRequested == null) requestID = tmp;
-
- if(isRAWCapture)
- Camera2Controller.getInstance().mCaptureSession.capture(rawRequestBuilder.build(),
- stillCaptureCallback, null);
- } catch (CameraAccessException e)
+ if(Camera2Controller.getInstance().mCaptureSession != null)
{
- e.printStackTrace();
+ try
+ {
+ requestID = Camera2Controller.getInstance().mCaptureSession.capture(stillRequestBuilder.build(),
+ stillCaptureCallback, null);
+
+ pluginManager.addRequestID(n, requestID);
+ // FixMe: Why aren't requestID assigned if there is request with ev's being adjusted??
+ // if (evRequested == null) requestID = tmp;
+
+ if(isRAWCapture)
+ Camera2Controller.getInstance().mCaptureSession.capture(rawRequestBuilder.build(),
+ stillCaptureCallback, null);
+ } catch (CameraAccessException e)
+ {
+ e.printStackTrace();
+ }
}
}
+ else
+ {
+ List requests = new ArrayList();
+ for (int n = 0; n < nFrames; ++n)
+ {
+ SetupPerFrameParameters(evRequested == null ? selectedEvCompensation : evRequested[n], gain == null ? currentSensitivity : gain[n],
+ exposure == null ? 0 : exposure[n], focusDistances == null ? -1.0f : focusDistances[n], isRAWCapture);
+
+ requests.add(stillRequestBuilder.build());
+ }
+
+ startFocusBracketingCapture(focusDistances, requests);
+// if(Camera2Controller.getInstance().mCaptureSession != null)
+// {
+// try
+// {
+// requestID = Camera2Controller.getInstance().mCaptureSession.captureBurst(requests,
+// stillCaptureCallback, null);
+//
+// pluginManager.addRequestID(0, requestID);
+// } catch (CameraAccessException e)
+// {
+// e.printStackTrace();
+// }
+// }
}
}
@@ -2721,7 +2781,7 @@ public static int captureImageWithParamsCamera2Simple(final int nFrames, final i
//Method to capture next image in case of multishot requested
//Called for all frames instead very first frame
public static int captureNextImageWithParams(final int format, final int frameIndex, final int pause, final int evRequested,
- final int gain, final long exposure, final boolean setPowerGamma)
+ final int gain, final long exposure, final float focusDistance, final boolean setPowerGamma)
{
int requestID = -1;
@@ -2738,15 +2798,16 @@ public static int captureNextImageWithParams(final int format, final int frameIn
}
final boolean isRAWCapture = (format == CameraController.RAW);
- SetupPerFrameParameters(evRequested, gain, exposure, isRAWCapture);
- captureNextImageWithParamsSimple(format, frameIndex, pause, evRequested, gain, exposure);
+ SetupPerFrameParameters(evRequested, gain, exposure, focusDistance, isRAWCapture);
+ captureNextImageWithParamsSimple(format, frameIndex, pause, evRequested, gain, exposure, focusDistance);
return requestID;
}
private static int captureNextImageWithParamsSimple(final int format, final int frameIndex,
final int pause, final int evRequested,
- final int gain, final long exposure)
+ final int gain, final long exposure,
+ final float focusDistance)
{
int requestID = -1;
@@ -2810,6 +2871,28 @@ public void onFinish()
return requestID;
}
+
+
+
+ private static void startFocusBracketingCapture(final float[] focusDistances, final List requests)
+ {
+ fbRequests = requests;
+ totalFrames = requests.size();
+ currentFrameIndex = 0;
+ focusDistance = focusDistances;
+
+ Camera2Controller.setCameraFocusDistanceCamera2(focusDistance[currentFrameIndex]);
+ fbRequested = true;
+
+ }
+
+ private static void nextFocusBracketingCapture()
+ {
+ Camera2Controller.setCameraFocusDistanceCamera2(focusDistance[currentFrameIndex]);
+ fbRequested = true;
+ }
+
+
//Initiate auto focus regardless to focus mode
//actually used to 'lock' focus before manual exposure metering is set
@@ -2821,7 +2904,7 @@ public static void forceFocusCamera2()
CameraCharacteristics.CONTROL_AF_TRIGGER_START);
try
{
- Camera2Controller.getInstance().mCaptureSession.capture(Camera2Controller.previewRequestBuilder.build(), captureCallback, null);
+ Camera2Controller.getInstance().mCaptureSession.capture(Camera2Controller.previewRequestBuilder.build(), previewCaptureCallback, null);
} catch (CameraAccessException e)
{
e.printStackTrace();
@@ -2843,7 +2926,7 @@ public static boolean autoFocusCamera2()
try
{
- Camera2Controller.getInstance().mCaptureSession.setRepeatingRequest(Camera2Controller.previewRequestBuilder.build(), captureCallback, null);
+ Camera2Controller.getInstance().mCaptureSession.setRepeatingRequest(Camera2Controller.previewRequestBuilder.build(), previewCaptureCallback, null);
} catch (CameraAccessException e)
{
e.printStackTrace();
@@ -2855,7 +2938,7 @@ public static boolean autoFocusCamera2()
CameraCharacteristics.CONTROL_AF_TRIGGER_START);
try
{
- Camera2Controller.getInstance().mCaptureSession.capture(Camera2Controller.previewRequestBuilder.build(), captureCallback, null);
+ Camera2Controller.getInstance().mCaptureSession.capture(Camera2Controller.previewRequestBuilder.build(), previewCaptureCallback, null);
} catch (CameraAccessException e)
{
e.printStackTrace();
@@ -2886,7 +2969,7 @@ public static void cancelAutoFocusCamera2()
CameraCharacteristics.CONTROL_AF_TRIGGER_CANCEL);
try
{
- Camera2Controller.getInstance().mCaptureSession.capture(Camera2Controller.previewRequestBuilder.build(), captureCallback, null);
+ Camera2Controller.getInstance().mCaptureSession.capture(Camera2Controller.previewRequestBuilder.build(), previewCaptureCallback, null);
} catch (CameraAccessException e)
{
e.printStackTrace();
@@ -2897,7 +2980,7 @@ public static void cancelAutoFocusCamera2()
CameraCharacteristics.CONTROL_AF_TRIGGER_IDLE);
try
{
- Camera2Controller.getInstance().mCaptureSession.capture(Camera2Controller.previewRequestBuilder.build(), captureCallback, null);
+ Camera2Controller.getInstance().mCaptureSession.capture(Camera2Controller.previewRequestBuilder.build(), previewCaptureCallback, null);
} catch (CameraAccessException e)
{
e.printStackTrace();
@@ -3288,7 +3371,7 @@ public void onConfigured(final CameraCaptureSession session)
};
- private final static CameraCaptureSession.CaptureCallback captureCallback = new CameraCaptureSession.CaptureCallback()
+ private final static CameraCaptureSession.CaptureCallback previewCaptureCallback = new CameraCaptureSession.CaptureCallback()
{
boolean resetInProgress = false;
int resetRequestId = 0;
@@ -3300,6 +3383,7 @@ public void onCaptureCompleted(
CaptureRequest request,
TotalCaptureResult result)
{
+ if(!previewRunning) return;
try
{
// if(Camera2Controller.autoFocusTriggered)
@@ -3379,9 +3463,47 @@ else if(!captureAllowed)
resetCaptureCallback();
captureAllowed = true;
}
+
+ int lensState = result.get(CaptureResult.LENS_STATE);
+ if(lensState == CaptureResult.LENS_STATE_MOVING)
+ captureAllowed = false;
+ else
+ captureAllowed = true;
} catch (Exception e) {
e.printStackTrace();
}
+
+ try {
+
+ if(Camera2Controller.fbRequested)
+ {
+ float fdist = result.get(CaptureResult.LENS_FOCUS_DISTANCE);
+ float r = Util.round(fdist, 2);
+ float f = Util.round(focusDistance[currentFrameIndex], 1);
+// Log.e(TAG, "onPreview FOCUS DISTANCE = " + fdist + " waiting for distance = " + focusDistance[currentFrameIndex] + "\n Rounded real focus = " + r + " expected focus = " + f);
+ if(Math.abs(r - f) < 0.1f)
+ {
+ if(Camera2Controller.getInstance().mCaptureSession != null)
+ {
+ try
+ {
+ fbRequested = false;
+ int requestID = Camera2Controller.getInstance().mCaptureSession.capture(fbRequests.get(currentFrameIndex++),
+ stillCaptureCallback, null);
+
+ pluginManager.addRequestID(currentFrameIndex, requestID);
+ } catch (CameraAccessException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
}
public void onCaptureSequenceCompleted(CameraCaptureSession session, int sequenceId, long frameNumber) {
@@ -3402,7 +3524,7 @@ private void resetCaptureCallback()
CameraCharacteristics.CONTROL_AF_TRIGGER_CANCEL);
try
{
- Camera2Controller.getInstance().mCaptureSession.capture(Camera2Controller.previewRequestBuilder.build(), captureCallback, null);
+ Camera2Controller.getInstance().mCaptureSession.capture(Camera2Controller.previewRequestBuilder.build(), previewCaptureCallback, null);
} catch (CameraAccessException e)
{
e.printStackTrace();
@@ -3414,7 +3536,7 @@ private void resetCaptureCallback()
CameraCharacteristics.CONTROL_AF_TRIGGER_IDLE);
try
{
- resetRequestId = Camera2Controller.getInstance().mCaptureSession.capture(Camera2Controller.previewRequestBuilder.build(), captureCallback, null);
+ resetRequestId = Camera2Controller.getInstance().mCaptureSession.capture(Camera2Controller.previewRequestBuilder.build(), previewCaptureCallback, null);
} catch (CameraAccessException e)
{
e.printStackTrace();
@@ -3667,6 +3789,11 @@ public void onImageAvailable(ImageReader ir)
if (CameraController.getFocusMode() != CameraParameters.AF_MODE_CONTINUOUS_PICTURE && !CameraController.isGalaxyS7)
Camera2Controller.cancelAutoFocusCamera2();
}
+
+ if(focusDistance != null && currentFrameIndex < totalFrames)
+ {
+ nextFocusBracketingCapture();
+ }
}
// Image should be closed after we are done with it
diff --git a/src/com/almalence/opencam/cameracontroller/CameraController.java b/src/com/almalence/focuscam/cameracontroller/CameraController.java
similarity index 98%
rename from src/com/almalence/opencam/cameracontroller/CameraController.java
rename to src/com/almalence/focuscam/cameracontroller/CameraController.java
index 4304c5cb..2ac56180 100644
--- a/src/com/almalence/opencam/cameracontroller/CameraController.java
+++ b/src/com/almalence/focuscam/cameracontroller/CameraController.java
@@ -17,10 +17,10 @@
*/
/* */
//
@@ -72,19 +72,19 @@
import com.almalence.util.ImageConversion;
import com.almalence.util.Util;
//
/* */
public class CameraController implements Camera.PictureCallback, Camera.AutoFocusCallback, Camera.ErrorCallback,
@@ -127,7 +127,14 @@ public class CameraController implements Camera.PictureCallback, Camera.AutoFocu
Build.MODEL.toLowerCase(Locale.US).replace(" ", "").contains("lg-us995")||
Build.MODEL.toLowerCase(Locale.US).replace(" ", "").contains("lg-ls996");
- public static boolean isG5 = Build.MODEL.toLowerCase(Locale.US).replace(" ", "").contains("lg-h830");
+ public static boolean isG5 = Build.MODEL.toLowerCase(Locale.US).replace(" ", "").contains("lg-h830")||
+ Build.MODEL.toLowerCase(Locale.US).replace(" ", "").contains("lg-h850")||
+ Build.MODEL.toLowerCase(Locale.US).replace(" ", "").contains("lg-h858")||
+ Build.MODEL.toLowerCase(Locale.US).replace(" ", "").contains("lg-vs987")||
+ Build.MODEL.toLowerCase(Locale.US).replace(" ", "").contains("lg-h820")||
+ Build.MODEL.toLowerCase(Locale.US).replace(" ", "").contains("lg-ls992")||
+ Build.MODEL.toLowerCase(Locale.US).replace(" ", "").contains("lg-us992")||
+ Build.MODEL.toLowerCase(Locale.US).replace(" ", "").contains("lg-h860n");
public static boolean isG4 = Build.MODEL.toLowerCase(Locale.US).replace(" ", "").contains("lg-h818") ||
Build.MODEL.toLowerCase(Locale.US).replace(" ", "").contains("lg-h815") ||
@@ -202,7 +209,7 @@ public class CameraController implements Camera.PictureCallback, Camera.AutoFocu
public static boolean isMotoXPure = Build.MODEL.toLowerCase().replace(" ", "").contains("xt1575");
public static boolean isHTCM10 = Build.MODEL.toLowerCase().replace(" ", "").contains("htc_m10h");
-
+ public static boolean isSnapdgragonTestDevice = Build.MODEL.toLowerCase(Locale.US).replace(" ", "").contains("msm8996forarm64");
// Android camera parameters constants
private static String sceneAuto;
@@ -1154,8 +1161,13 @@ public static boolean isSuperModePossible()
// hard-code to enable these only, as we have no profiles for
// other models at the moment
- if ((CameraController.isNexus5or6 || CameraController.isFlex2
- || CameraController.isOnePlusTwo || CameraController.isGalaxyS7)
+ if ((CameraController.isNexus5or6 ||
+ CameraController.isFlex2 ||
+ CameraController.isOnePlusTwo ||
+ CameraController.isGalaxyS7 ||
+ CameraController.isHTCM10
+ //CameraController.isG5
+ )
/*|| CameraController.isGalaxyS6*/
/*|| CameraController.isG4*/)
SuperModeOk = true;
@@ -1594,6 +1606,8 @@ protected static void addResolution(int ii, int currSizeWidth, int currSizeHeigh
float mpix = (float) lmpix / 1000000.f;
float ratio = (float) ((float) currSizeWidth / (float) currSizeHeight);
+ if (!(Math.abs(ratio - 4 / 3.f) < 0.1f))
+ return;
// find good location in a list
int loc;
for (loc = 0; loc < CameraController.ResolutionsMPixList.size(); ++loc)
@@ -3242,6 +3256,22 @@ public static float getMinimumFocusDistance()
else
return 0;
}
+
+ public static float getHyperfocalFocusDistance()
+ {
+ if (CameraController.isCamera2)
+ return Camera2Controller.getCameraHyperfocalFocusDistance();
+ else
+ return 0;
+ }
+
+ public static float getCameraFocusDistance()
+ {
+ if (CameraController.isCamera2)
+ return Camera2Controller.getCameraFocusDistance();
+ else
+ return -1.0f;
+ }
public static boolean isManualExposureTimeSupported()
{
@@ -4235,7 +4265,7 @@ public static void configureMediaRecorder(MediaRecorder mediaRecorder)
// Note: per-frame 'gain' and 'exposure' parameters are only effective for
// Camera2 API at the moment
public static int captureImagesWithParams(int nFrames, int format, int[] pause, int[] evRequested, int[] gain,
- long[] exposure, boolean setPowerGamma, boolean resInHeap, boolean indicate)
+ long[] exposure, float[] focusDistances, boolean setPowerGamma, boolean resInHeap, boolean indicate)
{
pauseBetweenShots = pause;
evValues = evRequested;
@@ -4284,7 +4314,7 @@ public void onAutoFocus(boolean success, Camera camera)
}
return 0;
} else
- return Camera2Controller.captureImageWithParamsCamera2(nFrames, format, pause, evRequested, gain, exposure, setPowerGamma,
+ return Camera2Controller.captureImageWithParamsCamera2(nFrames, format, pause, evRequested, gain, exposure, focusDistances, setPowerGamma,
resultInHeap, indicateCapturing);
} else
{
diff --git a/src/com/almalence/focuscam/cameracontroller/SensorOrientation.java b/src/com/almalence/focuscam/cameracontroller/SensorOrientation.java
new file mode 100644
index 00000000..294a5bfc
--- /dev/null
+++ b/src/com/almalence/focuscam/cameracontroller/SensorOrientation.java
@@ -0,0 +1,211 @@
+package com.almalence.focuscam.cameracontroller;
+////import com.almalence.focuscam.ApplicationScreen;
+////import com.almalence.focuscam.ui.EglEncoder;
+////import com.almalence.plugins.capture.panoramaaugmented.AugmentedPanoramaEngine;
+////import com.almalence.plugins.capture.preshot.PreShot;
+////import com.almalence.plugins.capture.video.DROVideoEngine;
+////import com.almalence.util.ImageConversion;
+////import com.almalence.util.Util;
+////
+////import android.graphics.Bitmap;
+////import android.graphics.Matrix;
+////import android.opengl.EGL14;
+////
+////
+////
+//
+//// Back Front
+////Nexus 5: 90 270
+////Nexus 5x: 270 270
+////LG Flex2: 90 270
+////OnePlus One2: 90 270
+////Nexus 6p: 90 90
+////Nexus 6: 90 90
+//
+//
+//
+//class SensorOrientation
+//{
+// SensorOrientation()
+// {
+// //ImageAdapter.decodeJPEG(YUV)FromData
+// Matrix matrix = new Matrix();
+// //Workaround for Nexus5x, image is flipped because of sensor orientation
+// if(CameraController.isNexus5x) //b f| f_
+// matrix.postRotate(mCameraMirrored ? (mIsLandscape ? 90 : 270) : 270); //(Nexus 5x: postRotate(270, 270, 90))
+// else
+// matrix.postRotate(mCameraMirrored ? (mIsLandscape ? 90 : 270) : 90); //(Nexus 5: postRotate(90, -90, 90))
+//
+//
+//
+// //GUI.getImageDataOrientation
+// int i = (mDeviceOrientation + (CameraController.isNexus5x? (CameraController.isFrontCamera()? 90 : 270) : 90)) % 360;
+//
+//
+//
+// //PreshotProcessing.getMultishotBitmap
+// if (mCameraMirrored && (90 == PreShot.getOrientation(index) || 270 == PreShot.getOrientation(index)))
+// {
+// Matrix matrix = new Matrix();
+// matrix.postRotate(180);
+// bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
+// }
+//
+// if ((CameraController.isFlippedSensorDevice() && mCameraMirrored) || (CameraController.isNexus5x && !mCameraMirrored))
+// {
+// Matrix matrix = new Matrix();
+// matrix.postRotate(180);
+// bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
+// }
+//
+//
+//
+// //ObjectRemoval(Sequence)Processing.handleMessage. MSG_REDRAW
+// Matrix matrix = new Matrix();
+// //Workaround for Nexus5x, image is flipped because of sensor orientation
+// matrix.postRotate(CameraController.isNexus5x? (mCameraMirrored ? 90 : -90) : 90);
+// Bitmap rotated = Bitmap.createBitmap(PreviewBmp, 0, 0, PreviewBmp.getWidth(), PreviewBmp.getHeight(),
+// matrix, true);
+// mImgView.setImageBitmap(rotated);
+// mImgView.setRotation(CameraController.isFrontCamera() ? ((mDisplayOrientation == 0 || mDisplayOrientation == 180) ? 0
+// : 180)
+// : 0);
+//
+//
+//
+// //FocusVFPlugin.initialize
+// Matrix matrix = new Matrix();
+// Util.prepareMatrix(matrix, mirror, (CameraController.isNexus5x && !mirror)? 270 : 90 , mPreviewWidth, mPreviewHeight);
+//
+//
+//
+// //NightCapturePlugin.onPreviewFrame
+// //Workaround for Nexus5x, image is flipped because of sensor orientation
+// if(CameraController.isNexus5x)
+// {
+// dataRotated = new byte[dataS.length];
+// ImageConversion.TransformNV21(dataS, dataRotated, imageWidth, imageHeight, 1, 1, 0);
+// yuvData = dataRotated;
+// }
+// else
+// yuvData = dataS;
+//
+//
+//
+//
+// //Multishots onStartPostProcessing
+// //Workaround for Nexus5x, image is flipped because of sensor orientation
+// if(CameraController.isNexus5x)
+// mImgView.setRotation(mCameraMirrored ? ((mDisplayOrientationOnStartProcessing == 0 || mDisplayOrientationOnStartProcessing == 180) ? 0
+// : 180)
+// : 180);
+// else
+// mImgView.setRotation(mCameraMirrored ? ((mDisplayOrientationOnStartProcessing == 0 || mDisplayOrientationOnStartProcessing == 180) ? 0
+// : 180)
+// : 0);
+//
+//
+//
+//
+// //Workaround for Nexus5x, image is flipped horizontally & vertically because of sensor orientation
+// if(CameraController.isNexus5x && !mCameraMirrored)
+// {
+// x = mDisplayWidth - event.getY();
+// y = event.getX();
+// }
+// else
+// {
+// x = event.getY();
+// y = mDisplayHeight - 1 - event.getX();
+// }
+//
+//
+//
+// //ObjectRemoval.onTouch
+// //Workaround for Nexus5x, image is flipped horizontally & vertically because of sensor orientation
+// if(CameraController.isNexus5x && !mCameraMirrored)
+// {
+// x = mDisplayWidth - event.getY();
+// y = event.getX();
+// }
+// else
+// {
+// x = event.getY();
+// y = mDisplayHeight - 1 - event.getX();
+// }
+//
+//
+//
+//
+// //FocusVFPlugin.onTouchFocusAndMeteringArea (onTouchFocusArea + onTouchMeteringArea)
+// //TODO: Logic of coordinate's swapping must be based on sensor orientation not on device model!
+// if (!CameraController.isNexus5x)
+// {
+// int tmpX = xRaw;
+// xRaw = yRaw;
+// yRaw = previewWidth - tmpX - 1;
+// }
+// else
+// {
+// int tmpX = xRaw;
+// xRaw = previewHeight - yRaw - 1;
+// yRaw = tmpX;
+// }
+//
+//
+//
+//
+//
+// //AugmentedPanoramaEngine.AugmentedFrameTaken
+// if (CameraController.isFrontCamera())
+// {
+// if (CameraController.isFlippedSensorDevice())
+// ImageConversion.TransformNV21N(yuv_address,
+// yuv_address,
+// AugmentedPanoramaEngine.this.height,
+// AugmentedPanoramaEngine.this.width,
+// 0, 1, 0);
+// else
+// ImageConversion.TransformNV21N(yuv_address,
+// yuv_address,
+// AugmentedPanoramaEngine.this.height,
+// AugmentedPanoramaEngine.this.width,
+// 1, 0, 0);
+// }
+// else
+// {
+// //Workaround for Nexus5x, image is flipped because of sensor orientation
+// if(CameraController.isNexus5x)
+// {
+// ImageConversion.TransformNV21N(yuv_address,
+// yuv_address,
+// AugmentedPanoramaEngine.this.height,
+// AugmentedPanoramaEngine.this.width,
+// 1, 1, 0);
+// }
+// }
+//
+//
+//
+//
+// //DROVideoEngine.startRecording
+// DROVideoEngine.this.encoder = new EglEncoder(path, DROVideoEngine.this.previewWidth,
+// DROVideoEngine.this.previewHeight, 24, 20000000, CameraController.isNexus5x ? (ApplicationScreen
+// .getGUIManager().getImageDataOrientation() + 180) % 360 : ApplicationScreen
+// .getGUIManager().getImageDataOrientation(), EGL14
+// .eglGetCurrentContext());
+//
+//
+//
+// //GroupShotProcessingPlugin.setupImageView
+// if(CameraController.isNexus5x)
+// mImgView.setRotation(mCameraMirrored ? ((mDisplayOrientationOnStartProcessing == 0 || mDisplayOrientationOnStartProcessing == 180) ? 0
+// : 180)
+// : 180);
+// else
+// mImgView.setRotation(mCameraMirrored ? ((mDisplayOrientationOnStartProcessing == 0 || mDisplayOrientationOnStartProcessing == 180) ? 0
+// : 180)
+// : 0);
+// }
+//
+//};
diff --git a/src/com/almalence/opencam/cameracontroller/SonyRemoteCamera.java b/src/com/almalence/focuscam/cameracontroller/SonyRemoteCamera.java
similarity index 98%
rename from src/com/almalence/opencam/cameracontroller/SonyRemoteCamera.java
rename to src/com/almalence/focuscam/cameracontroller/SonyRemoteCamera.java
index f13f5470..ab0b30bd 100644
--- a/src/com/almalence/opencam/cameracontroller/SonyRemoteCamera.java
+++ b/src/com/almalence/focuscam/cameracontroller/SonyRemoteCamera.java
@@ -1,8 +1,8 @@
/* */
//
@@ -45,18 +45,18 @@
import com.almalence.util.ImageConversion;
/* */
//
diff --git a/src/com/almalence/opencam/ui/AlmalenceGUI.java b/src/com/almalence/focuscam/ui/AlmalenceGUI.java
similarity index 99%
rename from src/com/almalence/opencam/ui/AlmalenceGUI.java
rename to src/com/almalence/focuscam/ui/AlmalenceGUI.java
index 2d44a60f..00d0a0aa 100644
--- a/src/com/almalence/opencam/ui/AlmalenceGUI.java
+++ b/src/com/almalence/focuscam/ui/AlmalenceGUI.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
@@ -94,6 +94,17 @@ Portions created by Initial Developer are Copyright (C) 2013
import android.widget.TextView;
import android.widget.Toast;
+import com.almalence.focuscam.ApplicationInterface;
+import com.almalence.focuscam.ApplicationScreen;
+import com.almalence.focuscam.CameraParameters;
+import com.almalence.focuscam.ConfigParser;
+import com.almalence.focuscam.MainScreen;
+import com.almalence.focuscam.Mode;
+import com.almalence.focuscam.Plugin;
+import com.almalence.focuscam.PluginManager;
+import com.almalence.focuscam.PluginType;
+import com.almalence.focuscam.Preferences;
+import com.almalence.focuscam.cameracontroller.CameraController;
import com.almalence.googsharing.Thumbnail;
import com.almalence.plugins.capture.panoramaaugmented.PanoramaAugmentedCapturePlugin;
import com.almalence.ui.Panel;
@@ -106,33 +117,22 @@ Portions created by Initial Developer are Copyright (C) 2013
import com.almalence.util.Util;
//
/* */
/***
@@ -8110,9 +8110,9 @@ public void openGallery(boolean isOpenExternal)
// if installed - run ABC Editor
if (AppEditorNotifier.isABCEditorInstalled(ApplicationScreen.instance))
{
- Intent intent = new Intent("com.almalence.opencameditor.action.REVIEW", uri);
+ Intent intent = new Intent("com.almalence.focuscameditor.action.REVIEW", uri);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
- ApplicationScreen.instance.startActivity(intent);// com.almalence.opencameditor
+ ApplicationScreen.instance.startActivity(intent);// com.almalence.focuscameditor
}
// if not installed - show that we have editor and let user install
// it of run standard dialog
diff --git a/src/com/almalence/opencam/ui/AlmalenceStore.java b/src/com/almalence/focuscam/ui/AlmalenceStore.java
similarity index 95%
rename from src/com/almalence/opencam/ui/AlmalenceStore.java
rename to src/com/almalence/focuscam/ui/AlmalenceStore.java
index 9d990990..5352dcd2 100755
--- a/src/com/almalence/opencam/ui/AlmalenceStore.java
+++ b/src/com/almalence/focuscam/ui/AlmalenceStore.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
import java.util.ArrayList;
@@ -28,18 +28,18 @@ Portions created by Initial Developer are Copyright (C) 2013
import java.util.List;
/* */
//
import com.almalence.ui.RotateImageView;
diff --git a/src/com/almalence/opencam/ui/AudioRecorder.java b/src/com/almalence/focuscam/ui/AudioRecorder.java
similarity index 98%
rename from src/com/almalence/opencam/ui/AudioRecorder.java
rename to src/com/almalence/focuscam/ui/AudioRecorder.java
index f29d7dbc..dddb5aca 100755
--- a/src/com/almalence/opencam/ui/AudioRecorder.java
+++ b/src/com/almalence/focuscam/ui/AudioRecorder.java
@@ -1,8 +1,8 @@
/* */
//
import java.io.IOException;
diff --git a/src/com/almalence/opencam/ui/ColorEffectQuickSetting.java b/src/com/almalence/focuscam/ui/ColorEffectQuickSetting.java
similarity index 91%
rename from src/com/almalence/opencam/ui/ColorEffectQuickSetting.java
rename to src/com/almalence/focuscam/ui/ColorEffectQuickSetting.java
index 01107b89..fa1f6dcb 100644
--- a/src/com/almalence/opencam/ui/ColorEffectQuickSetting.java
+++ b/src/com/almalence/focuscam/ui/ColorEffectQuickSetting.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
@@ -36,15 +36,14 @@ Portions created by Initial Developer are Copyright (C) 2013
import com.almalence.ui.RotateDialog;
//
+import com.almalence.focuscam.MainScreen;
+import com.almalence.focuscam.cameracontroller.CameraController;
+import com.almalence.focuscam.R;
/* */
public class ColorEffectQuickSetting
diff --git a/src/com/almalence/opencam/ui/EglEncoder.java b/src/com/almalence/focuscam/ui/EglEncoder.java
similarity index 99%
rename from src/com/almalence/opencam/ui/EglEncoder.java
rename to src/com/almalence/focuscam/ui/EglEncoder.java
index ad0b9a65..00881b97 100755
--- a/src/com/almalence/opencam/ui/EglEncoder.java
+++ b/src/com/almalence/focuscam/ui/EglEncoder.java
@@ -1,8 +1,8 @@
/* */
//
diff --git a/src/com/almalence/opencam/ui/ElementAdapter.java b/src/com/almalence/focuscam/ui/ElementAdapter.java
similarity index 94%
rename from src/com/almalence/opencam/ui/ElementAdapter.java
rename to src/com/almalence/focuscam/ui/ElementAdapter.java
index aefad7f6..f1d28869 100755
--- a/src/com/almalence/opencam/ui/ElementAdapter.java
+++ b/src/com/almalence/focuscam/ui/ElementAdapter.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
diff --git a/src/com/almalence/opencam/ui/GLLayer.java b/src/com/almalence/focuscam/ui/GLLayer.java
similarity index 94%
rename from src/com/almalence/opencam/ui/GLLayer.java
rename to src/com/almalence/focuscam/ui/GLLayer.java
index d2d05e57..ce5673d9 100755
--- a/src/com/almalence/opencam/ui/GLLayer.java
+++ b/src/com/almalence/focuscam/ui/GLLayer.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
import java.io.IOException;
@@ -32,12 +32,12 @@ Portions created by Initial Developer are Copyright (C) 2013
/* */
//
diff --git a/src/com/almalence/opencam/ui/GUI.java b/src/com/almalence/focuscam/ui/GUI.java
similarity index 96%
rename from src/com/almalence/opencam/ui/GUI.java
rename to src/com/almalence/focuscam/ui/GUI.java
index 093c15dc..6af1e9f9 100755
--- a/src/com/almalence/opencam/ui/GUI.java
+++ b/src/com/almalence/focuscam/ui/GUI.java
@@ -16,10 +16,10 @@ Portions created by Initial Developer are Copyright (C) 2013
by Almalence Inc. All Rights Reserved.
*/
/* */
//
@@ -40,15 +40,14 @@ Portions created by Initial Developer are Copyright (C) 2013
import android.widget.RelativeLayout;
/* */
//
+import com.almalence.focuscam.ApplicationScreen;
+import com.almalence.focuscam.Plugin;
+import com.almalence.focuscam.cameracontroller.CameraController;
/***
* GUI implements basic functionality for GUI.
diff --git a/src/com/almalence/opencam/ui/ImageSizeQuickSetting.java b/src/com/almalence/focuscam/ui/ImageSizeQuickSetting.java
similarity index 93%
rename from src/com/almalence/opencam/ui/ImageSizeQuickSetting.java
rename to src/com/almalence/focuscam/ui/ImageSizeQuickSetting.java
index 275927da..335998e9 100644
--- a/src/com/almalence/opencam/ui/ImageSizeQuickSetting.java
+++ b/src/com/almalence/focuscam/ui/ImageSizeQuickSetting.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
import android.content.Context;
@@ -38,17 +38,10 @@ Portions created by Initial Developer are Copyright (C) 2013
import com.almalence.ui.ListPreferenceAdapter;
import com.almalence.ui.RotateDialog;
//
-/* */
+import com.almalence.focuscam.ApplicationScreen;
+import com.almalence.focuscam.MainScreen;
+import com.almalence.focuscam.cameracontroller.CameraController;
+import com.almalence.focuscam.R;
public class ImageSizeQuickSetting
{
diff --git a/src/com/almalence/opencam/ui/QuickSettingDialog.java b/src/com/almalence/focuscam/ui/QuickSettingDialog.java
similarity index 91%
rename from src/com/almalence/opencam/ui/QuickSettingDialog.java
rename to src/com/almalence/focuscam/ui/QuickSettingDialog.java
index c9e0aa90..f92807e9 100644
--- a/src/com/almalence/opencam/ui/QuickSettingDialog.java
+++ b/src/com/almalence/focuscam/ui/QuickSettingDialog.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
@@ -31,10 +31,10 @@ Portions created by Initial Developer are Copyright (C) 2013
import com.almalence.ui.RotateLayout;
//
/* */
public class QuickSettingDialog extends RotateDialog
diff --git a/src/com/almalence/opencam/ui/SamplePagerAdapter.java b/src/com/almalence/focuscam/ui/SamplePagerAdapter.java
similarity index 95%
rename from src/com/almalence/opencam/ui/SamplePagerAdapter.java
rename to src/com/almalence/focuscam/ui/SamplePagerAdapter.java
index c82a4774..665f7661 100755
--- a/src/com/almalence/opencam/ui/SamplePagerAdapter.java
+++ b/src/com/almalence/focuscam/ui/SamplePagerAdapter.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
diff --git a/src/com/almalence/opencam/ui/SeekBarPreference.java b/src/com/almalence/focuscam/ui/SeekBarPreference.java
similarity index 98%
rename from src/com/almalence/opencam/ui/SeekBarPreference.java
rename to src/com/almalence/focuscam/ui/SeekBarPreference.java
index 554738da..819f5a11 100644
--- a/src/com/almalence/opencam/ui/SeekBarPreference.java
+++ b/src/com/almalence/focuscam/ui/SeekBarPreference.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
diff --git a/src/com/almalence/opencam/ui/SelfTimerAndPhotoTimeLapse.java b/src/com/almalence/focuscam/ui/SelfTimerAndPhotoTimeLapse.java
similarity index 97%
rename from src/com/almalence/opencam/ui/SelfTimerAndPhotoTimeLapse.java
rename to src/com/almalence/focuscam/ui/SelfTimerAndPhotoTimeLapse.java
index 01c90a9e..424ba947 100644
--- a/src/com/almalence/opencam/ui/SelfTimerAndPhotoTimeLapse.java
+++ b/src/com/almalence/focuscam/ui/SelfTimerAndPhotoTimeLapse.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
@@ -48,16 +48,16 @@ Portions created by Initial Developer are Copyright (C) 2013
import com.almalence.ui.RotateImageView;
//
/* */
public class SelfTimerAndPhotoTimeLapse
diff --git a/src/com/almalence/opencam/ui/SelfTimerAndTimeLapseDialog.java b/src/com/almalence/focuscam/ui/SelfTimerAndTimeLapseDialog.java
similarity index 93%
rename from src/com/almalence/opencam/ui/SelfTimerAndTimeLapseDialog.java
rename to src/com/almalence/focuscam/ui/SelfTimerAndTimeLapseDialog.java
index c084a576..9af66781 100644
--- a/src/com/almalence/opencam/ui/SelfTimerAndTimeLapseDialog.java
+++ b/src/com/almalence/focuscam/ui/SelfTimerAndTimeLapseDialog.java
@@ -17,10 +17,10 @@ Portions created by Initial Developer are Copyright (C) 2013
*/
/* */
//
import android.content.Context;
@@ -31,10 +31,10 @@ Portions created by Initial Developer are Copyright (C) 2013
import com.almalence.ui.RotateLayout;
//
/* */
public class SelfTimerAndTimeLapseDialog extends RotateDialog
diff --git a/src/com/almalence/opencam/ui/SonyCameraDeviceExplorer.java b/src/com/almalence/focuscam/ui/SonyCameraDeviceExplorer.java
similarity index 94%
rename from src/com/almalence/opencam/ui/SonyCameraDeviceExplorer.java
rename to src/com/almalence/focuscam/ui/SonyCameraDeviceExplorer.java
index 0b406602..385018ca 100644
--- a/src/com/almalence/opencam/ui/SonyCameraDeviceExplorer.java
+++ b/src/com/almalence/focuscam/ui/SonyCameraDeviceExplorer.java
@@ -1,8 +1,8 @@
/* */
//
@@ -30,17 +30,16 @@
import com.almalence.sony.cameraremote.SimpleSsdpClient;
import com.almalence.sony.cameraremote.utils.WifiListener;
/* */
//
+import com.almalence.focuscam.ApplicationScreen;
+import com.almalence.focuscam.MainScreen;
+import com.almalence.focuscam.cameracontroller.CameraController;
+import com.almalence.focuscam.R;
public class SonyCameraDeviceExplorer implements WifiListener
{
diff --git a/src/com/almalence/opencam/ui/SonyCameraDeviceExplorerDialog.java b/src/com/almalence/focuscam/ui/SonyCameraDeviceExplorerDialog.java
similarity index 84%
rename from src/com/almalence/opencam/ui/SonyCameraDeviceExplorerDialog.java
rename to src/com/almalence/focuscam/ui/SonyCameraDeviceExplorerDialog.java
index 6353a2bd..c475443b 100644
--- a/src/com/almalence/opencam/ui/SonyCameraDeviceExplorerDialog.java
+++ b/src/com/almalence/focuscam/ui/SonyCameraDeviceExplorerDialog.java
@@ -1,8 +1,8 @@
/* */
//
@@ -12,10 +12,10 @@
import com.almalence.ui.RotateLayout;
/* */
//
public class SonyCameraDeviceExplorerDialog extends RotateDialog
diff --git a/src/com/almalence/focusstacking/AlmaShotFocusStacking.java b/src/com/almalence/focusstacking/AlmaShotFocusStacking.java
new file mode 100755
index 00000000..9a0aad6d
--- /dev/null
+++ b/src/com/almalence/focusstacking/AlmaShotFocusStacking.java
@@ -0,0 +1,290 @@
+/*
+The contents of this file are subject to the Mozilla Public License
+Version 1.1 (the "License"); you may not use this file except in
+compliance with the License. You may obtain a copy of the License at
+http://www.mozilla.org/MPL/
+
+Software distributed under the License is distributed on an "AS IS"
+basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+License for the specific language governing rights and limitations
+under the License.
+
+The Original Code is collection of files collectively known as Open Camera.
+
+The Initial Developer of the Original Code is Almalence Inc.
+Portions created by Initial Developer are Copyright (C) 2016
+by Almalence Inc. All Rights Reserved.
+ */
+
+package com.almalence.focusstacking;
+
+import java.util.List;
+
+public final class AlmaShotFocusStacking
+{
+ private static int[] mInputFrames;
+ private static int mFramesAmount;
+
+ private static List mFocusDistances; //Focus distances for each input frame
+
+ private static int mBaseFrameIndex; //Frame around which focus depth will be changed
+ private static int mCurrentFocusDepth; //How much frames to take for focus stacking process
+
+ private static byte[] mFocusAreasMap; //Shows on which input frame desired area is better focused
+
+ private static int mImageWidth;
+ private static int mImageHeight;
+
+ private static boolean mFirstProcessing = true;
+
+
+ /*
+ * PUBLIC API =====================================>
+ */
+
+ /**
+ * Initialize Focus stacking engine, it should be called once for current focus bracketed frames set
+ **/
+ public static void Initialize(int[] frames, List focusDistances, int nFrames, int sx, int sy)
+ {
+ AlmaShotInitialize();
+
+ mInputFrames = frames;
+ mFramesAmount = nFrames;
+ mFocusDistances = focusDistances;
+
+ mImageWidth = sx;
+ mImageHeight = sy;
+
+ mFocusAreasMap = new byte[mImageWidth/16 * mImageHeight/16];
+
+ mFirstProcessing = true;
+ }
+
+ /**
+ * Stops focus stacking instance and finalize Almashot engine
+ * @return 0
+ */
+ public static int Release()
+ {
+ FStackingFreeInstance();
+ return AlmaShotRelease();
+ }
+
+ /**
+ * Get input frame
+ *
+ * @param index
+ * index of desired input frame
+ * @return pointer to input frame in NV21 format
+ */
+ public static int GetInputFrame(int index)
+ {
+ return mInputFrames[index];
+ }
+
+
+ /**
+ * Get input frame as byte array
+ * @param index
+ * index of desired input frame
+ * @param outWidth
+ * width of input frame
+ * @param outHeight
+ * height of input frame
+ * @param rotate
+ * orientation of input frame
+ * @param mirrored
+ * flag to show whether frame was shot to front camera or rear camera
+ * @return byte array
+ * rotated input frame in NV21 format
+ */
+ public static byte[] GetInputByteFrame(int index, int rotate, boolean mirrored)
+ {
+ return GetInputByteFrameNative(mInputFrames, index, rotate, mirrored);
+ }
+
+ /**
+ * Process function. Call only after Initialize(). *
+ * @param focusDistance - Base focus distance
+ * @param depthOfFocus - desired depth of focus from base focus distance. Depth calculated in both directions: closer and further
+ * @param rotate - desired rotation of result
+ * @param mirrored - is result needs to be mirrored
+ * @param transformResult - if true, engine will transform result according rotate and mirrored arguments
+ * @return byte array of result 'all in focus' frame in NV21 format
+ */
+ public static byte[] Process(float focusDistance, int depthOfFocus, int rotate, boolean mirrored, boolean transformResult)
+ {
+
+ int baseFrameIndex = mFocusDistances.indexOf(focusDistance);
+ if(baseFrameIndex == -1)
+ return null;
+
+
+ int frameAmount = mFramesAmount;
+ int firstFrameIndex = 0;
+ int lastFrameIndex = mFramesAmount - 1;
+
+ firstFrameIndex = baseFrameIndex - (depthOfFocus - 1);
+ lastFrameIndex = baseFrameIndex + (depthOfFocus - 1);
+
+ if(firstFrameIndex < 0) firstFrameIndex = 0;
+ if(lastFrameIndex > (mFramesAmount - 1)) lastFrameIndex = mFramesAmount - 1;
+
+ frameAmount = lastFrameIndex - firstFrameIndex + 1;
+ int[] compressed_frame = new int[frameAmount];
+ float[] focusDist = new float[frameAmount];
+
+ int index = 0;
+ for(int i = firstFrameIndex; i <= lastFrameIndex; i++)
+ {
+ compressed_frame[index] = mInputFrames[i];
+ focusDist[index] = mFocusDistances.get(i);
+ index++;
+ }
+
+ byte[] fmap = null;
+ if(frameAmount == mFramesAmount && mFirstProcessing)
+ {
+ fmap = mFocusAreasMap;
+ mFirstProcessing = false;
+ }
+
+ FStackingFreeInstance();
+ AlmaShotFocusStacking.FStackingInitialize(compressed_frame, focusDist, frameAmount, mImageWidth, mImageHeight, fmap);
+
+ byte[] result = FStackingProcess(rotate, mirrored, transformResult);
+
+ return result;
+ }
+
+
+ /**
+ * Get focus areas map
+ * @return Byte array of frame indexes. Each element of array represents 16x16 pixels area on result frame.
+ */
+ public static byte[] GetFocusAreasMap()
+ {
+ return mFocusAreasMap;
+ }
+
+ /**
+ * Get index of best focused frame in desired coordinates
+ * @param sx - x coordinate
+ * @param sy - y coordinate
+ * @return Index of input frame which best focused on desired point
+ */
+ public static int GetFocusedFrameIndex(int sx, int sy)
+ {
+ int x_lenght = mImageWidth/16;
+
+ int index_x = Math.round(sx/16 - 1);
+ int index_y = Math.round(sy/16 - 1);
+
+ if(index_x < 0) index_x = 0;
+ if(index_y < 0) index_y = 0;
+
+ int map_index = index_y * x_lenght + index_x;
+// Log.e("FStacking", "map index = " + map_index);
+
+ if(map_index > mFocusAreasMap.length - 1)
+ return -1;
+
+ return mFocusAreasMap[map_index];
+ }
+
+ /**
+ * Get all aligned frames. JNI's method.
+ * @return array of pointers to aligned frames in NV21 format
+ */
+ public static synchronized native int[] GetAlignedFrames();
+ /**
+ * Get one aligned frame. JNI's method.
+ * @param index - index of input frame which aligned version is requested
+ * @return pointer to aligned frame in NV21 format
+ */
+ public static synchronized native int GetAlignedFrame(int index);
+
+
+ /*
+ * PRIVATE API ======================================>
+ */
+
+ /**
+ * Initialize Almalence engine.
+ * Private method used in public Initialize method.
+ *
+ * @return status string such as "init status: "
+ */
+ private static synchronized native String AlmaShotInitialize();
+
+
+ /**
+ * Initialize Focus stacking jni-engine.
+ * This is a private method. Used in public method Process
+ *
+ * @param frames
+ * input frames in NV21 format
+ * @param focusDistances
+ * array of focus distances for each frame in diopter 1\m
+ * @param nFrames
+ * number of input frames
+ * @param sx
+ * width of input frames
+ * @param sy
+ * height of input frames
+ * @param fmap
+ * array of frame indexes for each AoI (Area of Interest)
+ * @return status string such as "init status: "
+ */
+ private static synchronized native int FStackingInitialize(int[] frames, float[] focusDistances, int nFrames, int sx, int sy, byte[] fmap);
+
+
+ /**
+ * Finalize Focus stacking instance.
+ * Used in public method Release()
+ */
+ private static synchronized native int FStackingFreeInstance();
+
+
+ /**
+ * Finalize Almalence engine.
+ * Used in public method Release()
+ */
+ private static synchronized native int AlmaShotRelease();
+
+ /**
+ * Get NV21(YVU420 planer) as Seamless-processed result
+ * Private method. Used in public method Process
+ *
+ * @param width
+ * input frame width size
+ * @param height
+ * input frame Height size
+ * @param crop
+ * array of 4 integer that contains x, y, width, height for
+ * cropping
+ * @param layout
+ * filled with index of frame.
+ * @return NV21(YVU420 planer)
+ */
+ private static synchronized native byte[] FStackingProcess(int rotate, boolean mirrored, boolean transformResult);
+
+ /**
+ * Get input frame by index as byte array. JNI's method
+ *
+ * @param frames - array of input frames
+ * @param index - desired input frame
+ * @param rotate - desired rotation of frame
+ * @param mirrored - is need to mirror frame
+ * @return input frame as byte array in NV21 format
+ */
+ private static synchronized native byte[] GetInputByteFrameNative(int[] frames, int index, int rotate, boolean mirrored);
+
+ static
+ {
+ System.loadLibrary("almalib");
+ System.loadLibrary("almashot-fstacking");
+ }
+}
+
diff --git a/src/com/almalence/googsharing/Thumbnail.java b/src/com/almalence/googsharing/Thumbnail.java
index 011d556a..4dd878c1 100755
--- a/src/com/almalence/googsharing/Thumbnail.java
+++ b/src/com/almalence/googsharing/Thumbnail.java
@@ -55,10 +55,10 @@
import android.util.Log;
/* */
//
import com.almalence.util.Util;
diff --git a/src/com/almalence/plugins/capture/bestshot/BestShotCapturePlugin.java b/src/com/almalence/plugins/capture/bestshot/BestShotCapturePlugin.java
index a0eb894d..362f9de0 100755
--- a/src/com/almalence/plugins/capture/bestshot/BestShotCapturePlugin.java
+++ b/src/com/almalence/plugins/capture/bestshot/BestShotCapturePlugin.java
@@ -27,24 +27,24 @@ Portions created by Initial Developer are Copyright (C) 2013
import android.hardware.camera2.CaptureResult;
/* */
//
@@ -144,7 +144,7 @@ public void takePicture()
imagesTaken = 0;
resultCompleted = 0;
createRequestIDList(imageAmount);
- CameraController.captureImagesWithParams(imageAmount, CameraController.YUV, null, null, null, null, false, true, true);
+ CameraController.captureImagesWithParams(imageAmount, CameraController.YUV, null, null, null, null, null, false, true, true);
}
@Override
diff --git a/src/com/almalence/plugins/capture/burst/BurstCapturePlugin.java b/src/com/almalence/plugins/capture/burst/BurstCapturePlugin.java
index 98dbf990..833fdfef 100755
--- a/src/com/almalence/plugins/capture/burst/BurstCapturePlugin.java
+++ b/src/com/almalence/plugins/capture/burst/BurstCapturePlugin.java
@@ -35,24 +35,24 @@ Portions created by Initial Developer are Copyright (C) 2013
import android.widget.Toast;
/* */
//
import com.almalence.util.HeapUtil;
@@ -347,7 +347,7 @@ public void takePicture()
final int[] pause = new int[imageAmount];
Arrays.fill(pause, pauseBetweenShots);
createRequestIDList(imageAmount * 2);
- CameraController.captureImagesWithParams(imageAmount, CameraController.RAW, pause, null, null, null, false, true,
+ CameraController.captureImagesWithParams(imageAmount, CameraController.RAW, pause, null, null, null, null, false, true,
true);
return;
}
@@ -363,7 +363,7 @@ public void takePicture()
final int[] pause = new int[imageAmount];
Arrays.fill(pause, pauseBetweenShots);
createRequestIDList(imageAmount);
- CameraController.captureImagesWithParams(imageAmount, CameraController.JPEG, pause, null, null, null, false, true,
+ CameraController.captureImagesWithParams(imageAmount, CameraController.JPEG, pause, null, null, null, null, false, true,
true);
}
diff --git a/src/com/almalence/plugins/capture/expobracketing/ExpoBracketingCapturePlugin.java b/src/com/almalence/plugins/capture/expobracketing/ExpoBracketingCapturePlugin.java
index 8443ba69..56086660 100755
--- a/src/com/almalence/plugins/capture/expobracketing/ExpoBracketingCapturePlugin.java
+++ b/src/com/almalence/plugins/capture/expobracketing/ExpoBracketingCapturePlugin.java
@@ -28,24 +28,24 @@ Portions created by Initial Developer are Copyright (C) 2013
import android.util.Log;
/* */
//
@@ -680,11 +680,11 @@ public void CaptureFrame()
createRequestIDList(captureRAW? total_frames*2 : total_frames);
if (captureRAW)
- CameraController.captureImagesWithParams(total_frames, CameraController.RAW, null, evValues, gain, exposure,
+ CameraController.captureImagesWithParams(total_frames, CameraController.RAW, null, evValues, gain, exposure, null,
false, true, true);
else
CameraController.captureImagesWithParams(total_frames, isHDRMode ? CameraController.YUV
- : CameraController.JPEG, null, evValues, gain, exposure, false, true, true);
+ : CameraController.JPEG, null, evValues, gain, exposure, null, false, true, true);
}
public void onAutoFocus(boolean paramBoolean)
diff --git a/src/com/almalence/plugins/capture/focusbracketing/FocusBracketingCapturePlugin.java b/src/com/almalence/plugins/capture/focusbracketing/FocusBracketingCapturePlugin.java
new file mode 100755
index 00000000..3e417c90
--- /dev/null
+++ b/src/com/almalence/plugins/capture/focusbracketing/FocusBracketingCapturePlugin.java
@@ -0,0 +1,517 @@
+/*
+The contents of this file are subject to the Mozilla Public License
+Version 1.1 (the "License"); you may not use this file except in
+compliance with the License. You may obtain a copy of the License at
+http://www.mozilla.org/MPL/
+
+Software distributed under the License is distributed on an "AS IS"
+basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+License for the specific language governing rights and limitations
+under the License.
+
+The Original Code is collection of files collectively known as Open Camera.
+
+The Initial Developer of the Original Code is Almalence Inc.
+Portions created by Initial Developer are Copyright (C) 2013
+by Almalence Inc. All Rights Reserved.
+ */
+
+package com.almalence.plugins.capture.focusbracketing;
+
+import java.util.Date;
+import java.util.List;
+
+import android.annotation.TargetApi;
+import android.content.SharedPreferences;
+import android.hardware.camera2.CaptureResult;
+import android.preference.PreferenceManager;
+import android.util.Log;
+
+import com.almalence.focuscam.ApplicationInterface;
+import com.almalence.focuscam.ApplicationScreen;
+import com.almalence.focuscam.CameraParameters;
+import com.almalence.focuscam.PluginCapture;
+import com.almalence.focuscam.PluginManager;
+import com.almalence.focuscam.R;
+import com.almalence.focuscam.cameracontroller.CameraController;
+/* */
+//
+
+/***
+ * Implements capture plugin with focus bracketing.
+ ***/
+
+public class FocusBracketingCapturePlugin extends PluginCapture
+{
+// private static final int MAX_HDR_FRAMES = 4;
+// private int preferenceEVCompensationValue;
+
+ // almashot - related
+// public static int[] evValues = new int[MAX_HDR_FRAMES];
+// public static int[] evIdx = new int[MAX_HDR_FRAMES];
+ private int frame_num;
+// public static float ev_step;
+// private boolean cm7_crap;
+
+ // shared between activities
+ public static int CapIdx;
+ public static int total_frames;
+// public static boolean LumaAdaptationAvailable = false;
+
+ // preferences
+// public static boolean RefocusPreference;
+// public static boolean UseLumaAdaptation;
+// private int preferenceSceneMode;
+ private int preferenceFocusMode;
+ private float preferenceFocusDistanceValue;
+
+ private static String sModePref;
+
+ boolean aeLocked = false;
+ boolean awLocked = false;
+
+// private int[] pauseBetweenShots = { 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000 };
+
+ public FocusBracketingCapturePlugin()
+ {
+ super("com.almalence.plugins.focusbracketingcapture", R.xml.preferences_capture_focusbracketing,
+ R.xml.preferences_capture_focusbracketing, 0, null);
+ }
+
+ private static String ModePreference;
+
+ private float[] focusDistances;
+
+ @Override
+ public void onCreate()
+ {
+ sModePref = ApplicationScreen.getAppResources().getString(R.string.Preference_FocusBracketingPref);
+ }
+
+ @Override
+ public void onStart()
+ {
+ getPrefs();
+ }
+
+ @Override
+ public void onResume()
+ {
+ inCapture = false;
+ aboutToTakePicture = false;
+
+ isAllImagesTaken = false;
+ isAllCaptureResultsCompleted = true;
+
+ aeLocked = false;
+ awLocked = false;
+
+ AeUnlock();
+ AwUnlock();
+
+ ApplicationScreen.instance.muteShutter(false);
+
+ preferenceFocusMode = ApplicationScreen.instance.getFocusModePref(ApplicationScreen.sDefaultFocusValue);
+
+ ApplicationScreen.setCaptureFormat(CameraController.YUV);
+ }
+
+ @Override
+ public void onPause()
+ {
+ CameraController.setCameraFocusMode(preferenceFocusMode);
+ }
+
+
+ @Override
+ public void onStop()
+ {
+ }
+
+ @Override
+ public void onGUICreate()
+ {
+// ApplicationScreen.instance.disableCameraParameter(CameraParameter.CAMERA_PARAMETER_FOCUS, true, false, true);
+ }
+
+ public boolean delayedCaptureSupported()
+ {
+ return true;
+ }
+
+ @Override
+ public void setupCameraParameters()
+ {
+ CameraController.Size imageSize = CameraController.getCameraImageSize();
+ CameraController.setPictureSize(imageSize.getWidth(), imageSize.getHeight());
+
+ //TODO: set Focus mode to MANUAL
+// try
+// {
+// int[] focusModes = CameraController.getSupportedFocusModes();
+// if (focusModes != null && focusModes.length > 0 && CameraController.isManualFocusDistanceSupported())
+// {
+// ApplicationScreen.instance.setFocusModePref(CameraParameters.MF_MODE);
+// ApplicationScreen.getPluginManager().sendMessage(ApplicationInterface.MSG_BROADCAST,
+// ApplicationInterface.MSG_FOCUS_LOCKED);
+// }
+//
+// } catch (RuntimeException e)
+// {
+// Log.e("FocusBracketing", "ApplicationScreen.setupCamera unable to set manual focus distance");
+// }
+
+// CameraController.resetExposureCompensation();
+// ApplicationScreen.instance.setEVPref(0);
+ }
+
+// @Override
+// public void selectImageDimension()
+// {
+// //max size will be used for best performance of focus stacking API
+// int captureIndex = 0;
+//
+// int imgCaptureWidth = CameraController.ResolutionsSizeList.get(captureIndex).getWidth();
+// int imgCaptureHeight = CameraController.ResolutionsSizeList.get(captureIndex).getHeight();
+//
+// CameraController.setCameraImageSize(new CameraController.Size(imgCaptureWidth, imgCaptureHeight));
+//
+// }
+
+ @Override
+ public void setCameraPreviewSize()
+ {
+ List cs = CameraController.getSupportedPreviewSizes();
+
+ CameraController.Size imageSize = CameraController.getCameraImageSize();
+ CameraController.Size os = getOptimalPreviewSize(cs, imageSize.getWidth(), imageSize.getHeight());
+ ApplicationScreen.instance.setCameraPreviewSize(os.getWidth(), os.getHeight());
+ }
+
+
+ public void onShutterClick()
+ {
+ if (!inCapture)
+ {
+ Date curDate = new Date();
+ SessionID = curDate.getTime();
+
+ startCaptureSequence();
+ }
+ }
+
+
+ private void startCaptureSequence()
+ {
+ ApplicationScreen.instance.muteShutter(true);
+
+ if (!inCapture)
+ {
+ inCapture = true;
+
+ // reiniting for every shutter press
+ frame_num = 0;
+ resultCompleted = 0;
+
+// if (CameraController.isAutoFocusPerform())
+// aboutToTakePicture = true;
+// else
+
+ if(CameraController.getFocusMode() == CameraParameters.MF_MODE)
+ preferenceFocusDistanceValue = CameraController.getCameraFocusDistance();
+
+ CaptureFrame();
+ }
+ }
+
+
+ public void CaptureFrame()
+ {
+ Log.e("FBCapture", "start focus bracketing capture");
+// float hyperFocalDistance = CameraController.getHyperfocalFocusDistance();
+// CameraController.setCameraFocusDistance(hyperFocalDistance);
+ int[] pauseBetweenShots = null;
+ switch (Integer.parseInt(ModePreference))
+ {
+ case 0: // Standard (3 shots: 2m, 66sm, 40sm)
+ total_frames = 3;
+ focusDistances = new float[3];
+ focusDistances[0] = 1.0f/2.0f;
+ focusDistances[1] = 1.0f/0.66f;
+ focusDistances[2] = 1.0f/0.40f;
+ break;
+ case 1: // Macro (5 shots: 22sm, 18sm, 15sm, 13sm, 11sm)
+ total_frames = 5;
+ focusDistances = new float[5];
+ focusDistances[0] = 1.0f/0.22f;//hyperFocalDistance;
+ focusDistances[1] = 1.0f/0.18f;
+ focusDistances[2] = 1.0f/0.15f;
+ focusDistances[3] = 1.0f/0.13f;
+ focusDistances[4] = 1.0f/0.11f;
+// pauseBetweenShots = new int[]{ 1000, 0, 0, 0, 0};
+ break;
+ case 2: // Full-range (8 shots: 2m, 66sm, 40sm, 22sm, 18sm, 15sm, 13sm, 11sm)
+ total_frames = 8;
+ focusDistances = new float[8];
+ focusDistances[0] = 1.0f/2.0f;//hyperFocalDistance;
+ focusDistances[1] = 1.0f/0.66f;
+ focusDistances[2] = 1.0f/0.40f;
+ focusDistances[3] = 1.0f/0.22f;
+ focusDistances[4] = 1.0f/0.18f;
+ focusDistances[5] = 1.0f/0.15f;
+ focusDistances[6] = 1.0f/0.13f;
+ focusDistances[7] = 1.0f/0.11f;
+// pauseBetweenShots = new int[]{ 1000, 0, 0, 0, 0, 0, 0, 0 };
+ break;
+ default: //Use standard mode
+ focusDistances = new float[3];
+ focusDistances[0] = 1.0f/2.0f;//hyperFocalDistance;
+ focusDistances[1] = 1.0f/0.66f;
+ focusDistances[2] = 1.0f/0.40f;
+ break;
+ }
+
+ AeLock();
+ AwLock();
+
+ createRequestIDList(total_frames);
+ CameraController.captureImagesWithParams(total_frames, CameraController.YUV, pauseBetweenShots, null, null, null, focusDistances, false, true, true);
+ }
+
+ private void AeLock()
+ {
+ if (CameraController.isExposureLockSupported())
+ {
+ CameraController.setAutoExposureLock(true);
+
+ aeLocked = true;
+
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext());
+ prefs.edit().putBoolean(ApplicationScreen.sAELockPref, aeLocked).commit();
+ }
+ }
+
+ private void AwLock()
+ {
+ if (CameraController.isWhiteBalanceLockSupported())
+ {
+ CameraController.setAutoWhiteBalanceLock(true);
+
+ awLocked = true;
+
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext());
+ prefs.edit().putBoolean(ApplicationScreen.sAWBLockPref, awLocked).commit();
+ }
+ }
+
+ private void AeUnlock()
+ {
+ if (CameraController.isExposureLockSupported())
+ CameraController.setAutoExposureLock(false);
+
+ aeLocked = false;
+
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext());
+ prefs.edit().putBoolean(ApplicationScreen.sAELockPref, aeLocked).commit();
+ }
+
+
+ private void AwUnlock()
+ {
+ if (CameraController.isWhiteBalanceLockSupported())
+ CameraController.setAutoWhiteBalanceLock(false);
+
+ awLocked = false;
+
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext());
+ prefs.edit().putBoolean(ApplicationScreen.sAWBLockPref, awLocked).commit();
+ }
+
+
+ public void onAutoFocus(boolean paramBoolean)
+ {
+ if (inCapture) // disregard autofocus success (paramBoolean)
+ {
+ // Log.d("HDR", "onAutoFocus inCapture == true");
+ // on motorola xt5 cm7 this function is called twice!
+ // on motorola droid's onAutoFocus seem to be called at every
+ // startPreview,
+ // causing additional frame(s) taken after sequence is finished
+ if (aboutToTakePicture)
+ CaptureFrame();
+
+ aboutToTakePicture = false;
+ }
+ }
+
+ @Override
+ public void addToSharedMemExifTags(byte[] frameData)
+ {
+ if (frameData != null)
+ {
+ if (PluginManager.getInstance().getActiveModeID().equals("focusstackingmode"))
+ {
+ PluginManager.getInstance().addToSharedMemExifTagsFromJPEG(frameData, SessionID, -1);
+ } else
+ {
+ PluginManager.getInstance().addToSharedMemExifTagsFromJPEG(frameData, SessionID, frame_num + 1);
+ }
+ } else if (frame_num == 0)
+ {
+ PluginManager.getInstance().addToSharedMemExifTagsFromCamera(SessionID);
+ }
+ }
+
+ @Override
+ public void onImageTaken(int frame, byte[] frameData, int frame_len, int format)
+ {
+// int n = evIdx[frame_num];
+// if (cm7_crap && (total_frames == 3))
+// {
+// if (frame_num == 0)
+// n = evIdx[0];
+// else if (frame_num == 1)
+// n = evIdx[2];
+// else
+// n = evIdx[1];
+// }
+
+ float focusDistance = focusDistances[frame_num];
+
+ ++frame_num;
+
+ Log.e("FBCapture", "------- frame " + frame_num + " taken");
+ PluginManager.getInstance().addToSharedMem("frame" + frame_num + SessionID, String.valueOf(frame));
+ PluginManager.getInstance().addToSharedMem("framelen" + frame_num + SessionID, String.valueOf(frame_len));
+ PluginManager.getInstance().addToSharedMem("frameorientation" + frame_num + SessionID,
+ String.valueOf(ApplicationScreen.getGUIManager().getImageDataOrientation()));
+ PluginManager.getInstance().addToSharedMem("framemirrored" + frame_num + SessionID,
+ String.valueOf(CameraController.isFrontCamera()));
+// PluginManager.getInstance().addToSharedMem("focusdistance" + frame_num + SessionID, String.valueOf(focusDistance));
+
+ PluginManager.getInstance().addToSharedMem("amountofcapturedframes" + SessionID, String.valueOf(frame_num));
+
+
+ if (frame_num >= total_frames)
+ {
+ if(isAllCaptureResultsCompleted)
+ {
+ PluginManager.getInstance().addToSharedMem("amountofcapturedframes" + SessionID,
+ String.valueOf(frame_num));
+
+ PluginManager.getInstance().sendMessage(ApplicationInterface.MSG_CAPTURE_FINISHED, String.valueOf(SessionID));
+
+// CameraController.resetExposureCompensation();
+
+ frame_num = 0;
+ resultCompleted = 0;
+ inCapture = false;
+
+ isAllImagesTaken = false;
+
+ AeUnlock();
+ AwUnlock();
+
+ if(CameraController.getFocusMode() == CameraParameters.MF_MODE)
+ CameraController.setCameraFocusDistance(preferenceFocusDistanceValue);
+ }
+ else
+ isAllImagesTaken = true;
+ }
+ }
+
+ @TargetApi(21)
+ @Override
+ public void onCaptureCompleted(CaptureResult result)
+ {
+ isAllCaptureResultsCompleted = false;
+
+ int requestID = requestIDArray[resultCompleted];
+ resultCompleted++;
+ if (result.getSequenceId() == requestID)
+ {
+ PluginManager.getInstance().addToSharedMemExifTagsFromCaptureResult(result, SessionID, resultCompleted);
+ }
+
+ float focusDistance = focusDistances[resultCompleted-1];
+// float resFocusDistance = result.get(CaptureResult.LENS_FOCUS_DISTANCE);
+// Log.e("FocusBracketingCapture", "Init focus distance = " + focusDistance + " result focus distance = " + resFocusDistance + " frame num = " + resultCompleted);
+ PluginManager.getInstance().addToSharedMem("focusdistance" + resultCompleted + SessionID, String.valueOf(focusDistance));
+
+ if (resultCompleted >= total_frames)
+ {
+ isAllCaptureResultsCompleted = true;
+ resultCompleted = 0;
+
+ if(isAllImagesTaken)
+ {
+ PluginManager.getInstance().addToSharedMem("amountofcapturedframes" + SessionID,
+ String.valueOf(frame_num + imagesTakenRAW));
+
+ PluginManager.getInstance().sendMessage(ApplicationInterface.MSG_CAPTURE_FINISHED, String.valueOf(SessionID));
+
+ CameraController.resetExposureCompensation();
+
+ frame_num = 0;
+ resultCompleted = 0;
+ inCapture = false;
+
+ isAllImagesTaken = false;
+
+ AeUnlock();
+ AwUnlock();
+
+ if(CameraController.getFocusMode() == CameraParameters.MF_MODE)
+ CameraController.setCameraFocusDistance(preferenceFocusDistanceValue);
+ }
+ }
+ }
+
+ @Override
+ public void onExportFinished()
+ {
+
+ }
+
+ private void getPrefs()
+ {
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.getMainContext());
+
+ ModePreference = prefs.getString(sModePref, "0");
+ }
+
+ @Override
+ public void onCameraSetup()
+ {
+ // ----- Figure expo correction parameters
+ FindFocusDistanceParameters();
+ }
+
+ void FindFocusDistanceParameters()
+ {
+ //TODO: According to capture mode (standard, macro, full-range) populate focus distances for capturing.
+ }
+
+ // onPreviewFrame is used only to provide an exact delay between setExposure
+ // and takePicture
+ @Override
+ public void onPreviewFrame(byte[] data)
+ {
+ }
+
+ public boolean photoTimeLapseCaptureSupported()
+ {
+ return true;
+ }
+}
diff --git a/src/com/almalence/plugins/capture/multishot/MultiShotCapturePlugin.java b/src/com/almalence/plugins/capture/multishot/MultiShotCapturePlugin.java
index 86ec7679..46b91ac6 100755
--- a/src/com/almalence/plugins/capture/multishot/MultiShotCapturePlugin.java
+++ b/src/com/almalence/plugins/capture/multishot/MultiShotCapturePlugin.java
@@ -28,24 +28,24 @@ Portions created by Initial Developer are Copyright (C) 2013
import android.hardware.camera2.CaptureResult;
/* */
//
/***
@@ -136,7 +136,7 @@ public void takePicture()
resultCompleted = 0;
createRequestIDList(IMAGES_AMOUNT);
CameraController.captureImagesWithParams(IMAGES_AMOUNT, CameraController.YUV,
- CameraController.isCamera2Allowed()?pauseBetweenShotsCamera2:pauseBetweenShots, null, null, null, false, true, true);
+ CameraController.isCamera2Allowed()?pauseBetweenShotsCamera2:pauseBetweenShots, null, null, null, null, false, true, true);
}
@Override
diff --git a/src/com/almalence/plugins/capture/night/GLCameraPreview.java b/src/com/almalence/plugins/capture/night/GLCameraPreview.java
index ab2382ea..c356502a 100755
--- a/src/com/almalence/plugins/capture/night/GLCameraPreview.java
+++ b/src/com/almalence/plugins/capture/night/GLCameraPreview.java
@@ -30,10 +30,10 @@ Portions created by Initial Developer are Copyright (C) 2013
import android.util.Log;
/* */
//
import com.almalence.util.ImageConversion;
diff --git a/src/com/almalence/plugins/capture/night/NightCapturePlugin.java b/src/com/almalence/plugins/capture/night/NightCapturePlugin.java
index bf11c1b6..8f961bb2 100755
--- a/src/com/almalence/plugins/capture/night/NightCapturePlugin.java
+++ b/src/com/almalence/plugins/capture/night/NightCapturePlugin.java
@@ -48,24 +48,24 @@ Portions created by Initial Developer are Copyright (C) 2013
import com.almalence.SwapHeap;
/* */
//
import com.almalence.plugins.processing.night.AlmaShotNight;
@@ -625,7 +625,7 @@ public void AdjustExposureCaptureBurst()
createRequestIDList(total_frames);
// capture the burst
CameraController.captureImagesWithParams(
- total_frames, CameraController.YUV_RAW, null, null, burstGainArray, burstExposureArray, true, true, true);
+ total_frames, CameraController.YUV_RAW, null, null, burstGainArray, burstExposureArray, null, true, true, true);
}
else
{
@@ -641,7 +641,7 @@ public void AdjustExposureCaptureBurst()
createRequestIDList(total_frames);
// capture the burst
CameraController.captureImagesWithParams(
- total_frames, CameraController.YUV_RAW, null, null, null, burstExposureArray, true, true, true);
+ total_frames, CameraController.YUV_RAW, null, null, null, burstExposureArray, null, true, true, true);
}
}
@@ -799,13 +799,13 @@ public void takePicture()
Log.wtf("SUPER", "takePicture. First frame. create IDList size 1");
createRequestIDList(1);
takingImageForExposure = true;
- CameraController.captureImagesWithParams(1, CameraController.YUV_RAW, null, null, null, null, true, true, false);
+ CameraController.captureImagesWithParams(1, CameraController.YUV_RAW, null, null, null, null, null, true, true, false);
}
else
{
createRequestIDList(total_frames);
takingImageForExposure = false;
- CameraController.captureImagesWithParams(total_frames, CameraController.YUV_RAW, null, null, null, null, false, true, true);
+ CameraController.captureImagesWithParams(total_frames, CameraController.YUV_RAW, null, null, null, null, null, false, true, true);
}
}
diff --git a/src/com/almalence/plugins/capture/panoramaaugmented/AugmentedPanoramaEngine.java b/src/com/almalence/plugins/capture/panoramaaugmented/AugmentedPanoramaEngine.java
index 6990f262..5ce2087f 100755
--- a/src/com/almalence/plugins/capture/panoramaaugmented/AugmentedPanoramaEngine.java
+++ b/src/com/almalence/plugins/capture/panoramaaugmented/AugmentedPanoramaEngine.java
@@ -34,12 +34,12 @@ Portions created by Initial Developer are Copyright (C) 2013
import com.almalence.YuvImage;
/* */
//
import com.almalence.util.ImageConversion;
diff --git a/src/com/almalence/plugins/capture/panoramaaugmented/PanoramaAugmentedCapturePlugin.java b/src/com/almalence/plugins/capture/panoramaaugmented/PanoramaAugmentedCapturePlugin.java
index c5fbf1ff..f600f604 100755
--- a/src/com/almalence/plugins/capture/panoramaaugmented/PanoramaAugmentedCapturePlugin.java
+++ b/src/com/almalence/plugins/capture/panoramaaugmented/PanoramaAugmentedCapturePlugin.java
@@ -67,26 +67,26 @@ Portions created by Initial Developer are Copyright (C) 2013
import com.almalence.util.HeapUtil;
/* */
//
@@ -1137,7 +1137,7 @@ public void onAutoFocus(final boolean success)
public void run()
{
createRequestIDList(1);
- CameraController.captureImagesWithParams(1, CameraController.YUV, null, null, null, null, false, false, true);
+ CameraController.captureImagesWithParams(1, CameraController.YUV, null, null, null, null, null, false, false, true);
}
};
diff --git a/src/com/almalence/plugins/capture/preshot/PreshotCapturePlugin.java b/src/com/almalence/plugins/capture/preshot/PreshotCapturePlugin.java
index 14449581..6fcb4d22 100755
--- a/src/com/almalence/plugins/capture/preshot/PreshotCapturePlugin.java
+++ b/src/com/almalence/plugins/capture/preshot/PreshotCapturePlugin.java
@@ -34,22 +34,22 @@ Portions created by Initial Developer are Copyright (C) 2013
import android.widget.Toast;
/* */
//
import com.almalence.ui.Switch.Switch;
@@ -517,7 +517,7 @@ public void CaptureFrame()
return;
createRequestIDList(1);
- CameraController.captureImagesWithParams(1, CameraController.JPEG, null, null, null, null, false, false, true);
+ CameraController.captureImagesWithParams(1, CameraController.JPEG, null, null, null, null, null, false, false, true);
counter++;
}
}
diff --git a/src/com/almalence/plugins/capture/standard/CapturePlugin.java b/src/com/almalence/plugins/capture/standard/CapturePlugin.java
index f2fe65fe..ae5f9e7c 100644
--- a/src/com/almalence/plugins/capture/standard/CapturePlugin.java
+++ b/src/com/almalence/plugins/capture/standard/CapturePlugin.java
@@ -29,22 +29,22 @@ Portions created by Initial Developer are Copyright (C) 2013
import android.hardware.camera2.CaptureResult;
/* */
//
import com.almalence.ui.Switch.Switch;
@@ -251,11 +251,11 @@ public void takePicture()
resultCompleted = 0;
createRequestIDList(captureRAW? 2 : 1);
if (ModePreference.compareTo("0") == 0)
- CameraController.captureImagesWithParams(1, CameraController.YUV, null, null, null, null, false, true, true);
+ CameraController.captureImagesWithParams(1, CameraController.YUV, null, null, null, null, null, false, true, true);
else if(captureRAW)
- CameraController.captureImagesWithParams(1, CameraController.RAW, null, null, null, null, false, true, true);
+ CameraController.captureImagesWithParams(1, CameraController.RAW, null, null, null, null, null, false, true, true);
else
- CameraController.captureImagesWithParams(1, CameraController.JPEG, null, null, null, null, false, true, true);
+ CameraController.captureImagesWithParams(1, CameraController.JPEG, null, null, null, null, null, false, true, true);
}
diff --git a/src/com/almalence/plugins/capture/video/DROVideoEngine.java b/src/com/almalence/plugins/capture/video/DROVideoEngine.java
index 78071fd6..362322c7 100755
--- a/src/com/almalence/plugins/capture/video/DROVideoEngine.java
+++ b/src/com/almalence/plugins/capture/video/DROVideoEngine.java
@@ -21,14 +21,14 @@
import android.widget.Toast;
/* */
//
diff --git a/src/com/almalence/plugins/capture/video/TimeLapseDialog.java b/src/com/almalence/plugins/capture/video/TimeLapseDialog.java
index d00bd994..5d539fbc 100755
--- a/src/com/almalence/plugins/capture/video/TimeLapseDialog.java
+++ b/src/com/almalence/plugins/capture/video/TimeLapseDialog.java
@@ -4,10 +4,10 @@
import android.view.Window;
/* */
//
import com.almalence.ui.RotateDialog;
import com.almalence.ui.RotateLayout;
diff --git a/src/com/almalence/plugins/capture/video/VideoCapturePlugin.java b/src/com/almalence/plugins/capture/video/VideoCapturePlugin.java
index 83e5582a..195f6b74 100644
--- a/src/com/almalence/plugins/capture/video/VideoCapturePlugin.java
+++ b/src/com/almalence/plugins/capture/video/VideoCapturePlugin.java
@@ -92,25 +92,24 @@ Portions created by Initial Developer are Copyright (C) 2013
import com.almalence.util.Util;
/* */
//
+import com.almalence.focuscam.ApplicationInterface;
+import com.almalence.focuscam.ApplicationScreen;
+import com.almalence.focuscam.CameraParameters;
+import com.almalence.focuscam.PluginCapture;
+import com.almalence.focuscam.PluginManager;
+import com.almalence.focuscam.cameracontroller.CameraController;
+import com.almalence.focuscam.ui.GUI.ShutterButton;
+import com.almalence.focuscam.R;
/***
* Implements basic functionality of Video capture.
@@ -2616,7 +2615,7 @@ public void takePicture()
inCapture = true;
SessionID = System.currentTimeMillis();
createRequestIDList(1);
- CameraController.captureImagesWithParams(1, CameraController.JPEG, null, null, null, null, false, true, true);
+ CameraController.captureImagesWithParams(1, CameraController.JPEG, null, null, null, null, null, false, true, true);
}
// timelapse values
diff --git a/src/com/almalence/plugins/export/standard/ExportPlugin.java b/src/com/almalence/plugins/export/standard/ExportPlugin.java
index a326d1c7..2ededcaa 100755
--- a/src/com/almalence/plugins/export/standard/ExportPlugin.java
+++ b/src/com/almalence/plugins/export/standard/ExportPlugin.java
@@ -27,14 +27,14 @@ Portions created by Initial Developer are Copyright (C) 2013
import android.view.View;
/* */
//
import com.almalence.ui.RotateImageView;
diff --git a/src/com/almalence/plugins/processing/bestshot/BestshotProcessingPlugin.java b/src/com/almalence/plugins/processing/bestshot/BestshotProcessingPlugin.java
index 3de70ce7..b0aa3143 100755
--- a/src/com/almalence/plugins/processing/bestshot/BestshotProcessingPlugin.java
+++ b/src/com/almalence/plugins/processing/bestshot/BestshotProcessingPlugin.java
@@ -19,16 +19,16 @@ Portions created by Initial Developer are Copyright (C) 2013
package com.almalence.plugins.processing.bestshot;
/* */
//
import com.almalence.plugins.processing.bestshot.AlmaShotBestShot;
diff --git a/src/com/almalence/plugins/processing/focusstacking/ComplexBitmap.java b/src/com/almalence/plugins/processing/focusstacking/ComplexBitmap.java
new file mode 100644
index 00000000..ccc45cbd
--- /dev/null
+++ b/src/com/almalence/plugins/processing/focusstacking/ComplexBitmap.java
@@ -0,0 +1,549 @@
+package com.almalence.plugins.processing.focusstacking;
+
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+
+import android.graphics.Bitmap;
+import android.graphics.Bitmap.Config;
+import android.graphics.Canvas;
+import android.graphics.ColorFilter;
+import android.graphics.Matrix;
+import android.graphics.Matrix.ScaleToFit;
+import android.graphics.Paint;
+import android.graphics.Rect;
+import android.graphics.RectF;
+import android.graphics.drawable.Drawable;
+import android.util.Log;
+//import android.util.Log;
+
+import com.almalence.util.ImageConversion;
+
+public class ComplexBitmap extends Drawable
+{
+ public static final String TAG = "ComplexBitmap";
+
+ private static final int TILE_SIZE = 512;
+
+ private boolean abandon = true;
+
+ private final Paint paint = new Paint();
+ private final RectF rectIn = new RectF();
+ private final RectF rectOut = new RectF();
+ private final Matrix matrixRendering = new Matrix();
+
+ private final Bitmap[][][] bitmaps;
+
+ private final int width;
+ private final int height;
+
+ private final int tiles_count_x;
+ private final int tiles_count_y;
+
+ private final int dpiCount;
+
+ private float rotation = 0.0f;
+
+ /**
+ * @param address Native address of NV21 image data block
+ * @param width NV21 image width
+ * @param height NV21 image height
+ */
+ public ComplexBitmap(final int width, final int height)
+ {
+ this(0, /*-1,*/ null, width, height, 0, 0, width, height, 4); // 1);
+ }
+
+ /**
+ * @param address Native address of NV21 image data block
+ * @param width NV21 image width
+ * @param height NV21 image height
+ */
+// public ComplexBitmap(final byte[] frame, final int width, final int height)
+// {
+// this(frame, width, height, 0, 0, width, height, 4); // 1);
+// }
+
+ /**
+ * @param frame Native address of NV21 image data block
+ * @param width NV21 image width
+ * @param height NV21 image height
+ * @param crop_x Left coordinate of crop region to be contained in ComplexBitmap instance
+ * @param crop_y Top coordinate of crop region to be contained in ComplexBitmap instance
+ * @param crop_w Width of crop region to be contained ComplexBitmap instance
+ * @param crop_h Height of crop region to be contained ComplexBitmap instance
+ * @param dpiCount Quantity of downscaled copies. Can improve performance but consumes more RAM
+ */
+ public ComplexBitmap(final byte[] frame, final int width, final int height)
+ {
+
+
+ this.width = width;
+ this.height = height;
+
+ this.dpiCount = 1;
+
+ this.bitmaps = new Bitmap[1][1][1];
+
+ long t, bmc = 0;
+
+ t = System.currentTimeMillis();
+
+ Rect rect = new Rect(0, 0, width, height);
+ int[] ARGBBuffer = ImageConversion.NV21ByteArraytoARGB(frame, width, height, rect, width, height);
+
+ this.bitmaps[0][0][0] = Bitmap.createBitmap(ARGBBuffer, width, height, Config.ARGB_8888);
+
+ bmc += System.currentTimeMillis()-t;
+
+ this.tiles_count_x = 1;//(crop_w / TILE_SIZE) + ((crop_w % TILE_SIZE) > 0 ? 1 : 0);
+ this.tiles_count_y = 1;//(crop_h / TILE_SIZE) + ((crop_h % TILE_SIZE) > 0 ? 1 : 0);
+//
+// this.bitmaps = new Bitmap[dpiCount][this.tiles_count_y][this.tiles_count_x];
+//
+// long t, bmc = 0, bms = 0;
+// for (int y = 0; y < this.tiles_count_y; y++)
+// {
+// for (int x = 0; x < this.tiles_count_x; x++)
+// {
+// t = System.currentTimeMillis();
+// this.bitmaps[0][y][x] = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+// bmc += System.currentTimeMillis()-t;
+//
+//// if (frame == null)
+//// {
+//// for (int i = 1; i < dpiCount; i++)
+//// {
+//// final int scaled_size = getTileSize(i, dpiCount);
+////
+//// t = System.currentTimeMillis();
+//// this.bitmaps[i][y][x] = Bitmap.createScaledBitmap(
+//// this.bitmaps[i - 1][y][x], scaled_size, scaled_size, false);
+//// bms += System.currentTimeMillis()-t;
+//// }
+//// }
+// }
+// }
+
+ Log.e(TAG, String.format("Bitmap creation time: %d", bmc));
+// Log.e(TAG, String.format("Scaling time: %d", bms));
+// Log.e(TAG, String.format("dpiCount: %d", this.dpiCount));
+// Log.e(TAG, String.format("tiles_count_x: %d", this.tiles_count_x));
+// Log.e(TAG, String.format("tiles_count_y: %d", this.tiles_count_y));
+
+// if (frame != null)
+// {
+// this.setFromNV21(frame, width, height, width, height);
+// }
+
+ this.paint.setAntiAlias(false);
+ this.paint.setDither(false);
+
+ this.invalidateSelf();
+ }
+
+
+ /**
+ * @param frame Native address of NV21 image data block
+ * @param width NV21 image width
+ * @param height NV21 image height
+ * @param crop_x Left coordinate of crop region to be contained in ComplexBitmap instance
+ * @param crop_y Top coordinate of crop region to be contained in ComplexBitmap instance
+ * @param crop_w Width of crop region to be contained ComplexBitmap instance
+ * @param crop_h Height of crop region to be contained ComplexBitmap instance
+ * @param dpiCount Quantity of downscaled copies. Can improve performance but consumes more RAM
+ */
+ public ComplexBitmap(final int frameAddress, /*final int frame*/final byte[] frame, final int width, final int height,
+ final int crop_x, final int crop_y,
+ final int crop_w, final int crop_h, final int dpiCount)
+ {
+ if ((crop_x + crop_w > width) || (crop_y + crop_h > height))
+ {
+ throw new IndexOutOfBoundsException();
+ }
+
+ this.width = crop_w;
+ this.height = crop_h;
+
+ this.dpiCount = dpiCount;
+
+ this.tiles_count_x = (crop_w / TILE_SIZE) + ((crop_w % TILE_SIZE) > 0 ? 1 : 0);
+ this.tiles_count_y = (crop_h / TILE_SIZE) + ((crop_h % TILE_SIZE) > 0 ? 1 : 0);
+
+ this.bitmaps = new Bitmap[dpiCount][this.tiles_count_y][this.tiles_count_x];
+
+ Log.e(TAG, "ComplexBitmap. dpi = " + dpiCount + " Tiles count x = " + this.tiles_count_x + " tiles count y " + this.tiles_count_y);
+
+ long t, bmc = 0, bms = 0;
+ t = System.currentTimeMillis();
+ for (int y = 0; y < this.tiles_count_y; y++)
+ {
+ for (int x = 0; x < this.tiles_count_x; x++)
+ {
+// t = System.currentTimeMillis();
+ this.bitmaps[0][y][x] = Bitmap.createBitmap(TILE_SIZE, TILE_SIZE, Bitmap.Config.ARGB_8888);
+ //bmc += System.currentTimeMillis()-t;
+
+ if (frame == null)
+// if (frame == -1)
+ {
+ for (int i = 1; i < dpiCount; i++)
+ {
+ final int scaled_size = getTileSize(i, dpiCount);
+
+// t = System.currentTimeMillis();
+ this.bitmaps[i][y][x] = Bitmap.createScaledBitmap(
+ this.bitmaps[i - 1][y][x], scaled_size, scaled_size, false);
+
+// bms += System.currentTimeMillis()-t;
+ }
+ }
+ }
+ }
+ bmc += System.currentTimeMillis()-t;
+
+ Log.e(TAG, String.format("Bitmap creation and scaling time: %d", bmc));
+// Log.e(TAG, String.format("Scaling time: %d", bms));
+// Log.e(TAG, String.format("dpiCount: %d", this.dpiCount));
+// Log.e(TAG, String.format("tiles_count_x: %d", this.tiles_count_x));
+// Log.e(TAG, String.format("tiles_count_y: %d", this.tiles_count_y));
+
+ if (frame != null || frameAddress != 0)
+// if (frame != -1)
+ {
+ this.setFromNV21(frameAddress, frame, width, height, crop_x, crop_y);
+ }
+
+ this.paint.setAntiAlias(false);
+ this.paint.setDither(false);
+
+ this.invalidateSelf();
+ }
+
+ /**
+ * Sets content from native NV21 image data block
+ * @param frame Native address of NV21 image data block
+ * @param width NV21 image width
+ * @param height NV21 image height
+ * @param crop_x Left coordinate of crop region to be contained in ComplexBitmap instance
+ * @param crop_y Top coordinate of crop region to be contained in ComplexBitmap instance
+ */
+ public void setFromNV21(final int frameAddress, /*final int frame*/final byte[] frame, final int width,
+ final int height, final int crop_x, final int crop_y)
+ {
+ if ((crop_x + this.width > width) || (crop_y + this.height > height))
+ {
+ throw new IndexOutOfBoundsException();
+ }
+
+// try {
+// Thread.sleep(1500);
+// } catch (InterruptedException e)
+// {
+// //handle
+// }
+ Log.e(TAG, String.format("setFromNV21 -- start"));
+
+ this.release();
+
+ final long tt = System.currentTimeMillis();
+ final AtomicLong bma = new AtomicLong();
+ final AtomicLong bms = new AtomicLong();
+
+ final int cpu_count = Runtime.getRuntime().availableProcessors();
+ final int tiles_per_cpu = this.tiles_count_x / cpu_count;
+
+// try {
+// sleep(2000);
+// } catch (InterruptedException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+
+ for (int y = 0; y < this.tiles_count_y; y++)
+ {
+ int tiles_mod_offset = 0;
+ int tiles_mod = this.tiles_count_x % cpu_count;
+ final int yy = y;
+ final AtomicInteger sync = new AtomicInteger(cpu_count);
+ synchronized (sync)
+ {
+ for (int c = 0; c < cpu_count; c++)
+ {
+ final int xx0 = tiles_mod_offset + c * (this.tiles_count_x / cpu_count);
+ final int xx1;
+ if (tiles_mod > 0)
+ {
+ xx1 = tiles_mod_offset + (c + 1) * tiles_per_cpu + 1;
+ tiles_mod_offset++;
+ tiles_mod--;
+ }
+ else
+ xx1 = tiles_mod_offset + (c + 1) * tiles_per_cpu;
+// Log.i(TAG, String.format("Tiles %d-%d of %d", xx0, xx1, this.tiles_count_x));
+ new Thread()
+ {
+ @Override
+ public void run()
+ {
+// this.setPriority(Thread.NORM_PRIORITY);
+ this.setPriority(Thread.MAX_PRIORITY);
+
+ for (int x = xx0; x < xx1; x++)
+ {
+ long t = System.currentTimeMillis();
+
+ if(frameAddress != 0)
+ {
+ YuvBitmap.setFromAddress(ComplexBitmap.this.bitmaps[0][yy][x],
+ frameAddress, width, height, x * TILE_SIZE, yy * TILE_SIZE, TILE_SIZE, TILE_SIZE);
+ }
+ else
+ {
+// Log.e(TAG, "YuvBitmap.setFromByteArray -- start");
+ //This code 2 times faster than below code with setPixels to Bitmap.
+ YuvBitmap.setFromByteArray(ComplexBitmap.this.bitmaps[0][yy][x],
+ frame, width, height, x * TILE_SIZE, yy * TILE_SIZE, TILE_SIZE, TILE_SIZE);
+// Log.e(TAG, "YuvBitmap.setFromByteArray -- end");
+
+// YuvBitmap.setFromAddress(ComplexBitmap.this.bitmaps[0][yy][x],
+// frame, width, height, x * TILE_SIZE, yy * TILE_SIZE, TILE_SIZE, TILE_SIZE);
+
+// Log.e(TAG, "Set Pixels to Bitmap from NV21ByteArraytoARGB convert -- start");
+// int x0 = x * TILE_SIZE;
+// int y0 = yy * TILE_SIZE;
+// int x_w = x * TILE_SIZE + TILE_SIZE;
+// int y_h = yy * TILE_SIZE + TILE_SIZE;
+//
+// int x_w_actual = Math.min(x_w, width);
+// int tile_width_actual = x_w_actual - x0;
+// int y_h_actual = Math.min(y_h, height);
+// int tile_height_actual = y_h_actual - y0;
+//
+// Rect rect = new Rect(x0, y0, x_w_actual, y_h_actual);
+// int[] ARGBBuffer = ImageConversion.NV21ByteArraytoARGB(frame, width, height, rect, tile_width_actual, tile_height_actual);
+// ComplexBitmap.this.bitmaps[0][yy][x].setPixels(ARGBBuffer, 0, tile_width_actual, 0, 0, tile_width_actual, tile_height_actual);
+// ARGBBuffer = null;
+// Log.e(TAG, "Set Pixels to Bitmap from NV21ByteArraytoARGB convert -- end");
+
+// ImageConversion.BitmapFromNV21ByteArray(ComplexBitmap.this.bitmaps[0][yy][x], frame, width, height, rect, tile_width_actual, tile_height_actual);
+ }
+
+ bma.addAndGet(System.currentTimeMillis()-t);
+
+ for (int i = 1; i < ComplexBitmap.this.dpiCount; i++)
+ {
+ final int scaled_size = getTileSize(i, ComplexBitmap.this.dpiCount);
+
+ t = System.currentTimeMillis();
+ ComplexBitmap.this.bitmaps[i][yy][x] = Bitmap.createScaledBitmap(
+ ComplexBitmap.this.bitmaps[i - 1][yy][x], scaled_size, scaled_size, false);
+ bms.addAndGet(System.currentTimeMillis()-t);
+ }
+ }
+
+ synchronized (sync)
+ {
+ sync.decrementAndGet();
+ sync.notify();
+ }
+
+// Log.e(TAG, String.format("Scaling time (setFromNV21): %dms", bms.get()));
+// Log.e(TAG, String.format("setFromAddress (setFromNV21): %dms", bma.get()));
+// Log.e(TAG, String.format("setFromNV21 total time: %dms", System.currentTimeMillis() - tt));
+ }
+ }.start();
+ }
+
+ try
+ {
+ while (sync.get() > 0) sync.wait();
+ }
+ catch (final InterruptedException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ this.abandon = false;
+
+ Log.e(TAG, String.format("Scaling time (setFromNV21): %dms", bms.get()));
+ Log.e(TAG, String.format("setFromAddress (setFromNV21): %dms", bma.get()));
+ Log.e(TAG, String.format("setFromNV21 total time: %dms", System.currentTimeMillis() - tt));
+
+ this.invalidateSelf();
+ }
+
+ private static float getDownscalingFactor(final int mode, final int dpiCount)
+ {
+ final float scaled = ((dpiCount - mode) / (float)dpiCount);
+
+ return (float)Math.pow(scaled, 0.6f);
+ }
+
+ private static int getTileSize(final int mode, final int dpiCount)
+ {
+ return (int)(TILE_SIZE * getDownscalingFactor(mode, dpiCount));
+ }
+
+ private int getMode(final Rect bounds)
+ {
+ final float scale = Math.max(bounds.width() / (float)this.width, bounds.height() / (float)this.height);
+
+ for (int i = 0; i < this.dpiCount; i++)
+ {
+ if (getDownscalingFactor(i, this.dpiCount) < scale)
+ return Math.max(0, i - 1);
+ }
+
+ return (this.dpiCount - 1);
+ }
+
+ @Override
+ public void draw(final Canvas canvas)
+ {
+ if (this.abandon) return;
+
+ final Rect bounds = this.getBounds();
+
+ final float scale_x = bounds.width() / (float)this.width;
+ final float scale_y = bounds.height() / (float)this.height;
+
+// Log.e(TAG, "draw. bounds.width = " + bounds.width() + " bounds.height = " + bounds.height() + " scale_x = " + scale_x + " scale_y = " + scale_y);
+
+ final float scaled_size_x = (float)Math.ceil(TILE_SIZE * scale_x);
+ final float scaled_size_y = (float)Math.ceil(TILE_SIZE * scale_y);
+
+ float offset_x = bounds.left;
+ float offset_y = bounds.top;
+
+ final int mode = getMode(bounds);
+ final int tile_side = getTileSize(mode, this.dpiCount);
+
+ final Bitmap[][] bitmaps = this.bitmaps[mode];
+
+ for (int y = 0; y < this.tiles_count_y; y++)
+ {
+ for (int x = 0; x < this.tiles_count_x; x++)
+ {
+ this.rectOut.left = offset_x;
+ this.rectOut.top = offset_y;
+ this.rectOut.right = Math.min(offset_x + scaled_size_x, bounds.right);
+ this.rectOut.bottom = Math.min(offset_y + scaled_size_y, bounds.bottom);
+
+ this.rectIn.left = 0.0f;
+ this.rectIn.top = 0.0f;
+ this.rectIn.right = Math.min((float)Math.floor(this.rectOut.width() / scale_x), tile_side);
+ this.rectIn.bottom = Math.min((float)Math.floor(this.rectOut.height() / scale_y), tile_side);
+
+ this.matrixRendering.setRectToRect(this.rectIn, this.rectOut, ScaleToFit.FILL);
+ this.matrixRendering.postRotate(this.rotation, bounds.width() / 2.0f, bounds.height() / 2.0f);
+ this.matrixRendering.postScale(
+ this.getIntrinsicWidth() / (float)this.width,
+ this.getIntrinsicHeight() / (float)this.height,
+ bounds.width() / 2.0f, bounds.height() / 2.0f);
+ canvas.drawBitmap(bitmaps[y][x], this.matrixRendering, this.paint);
+
+ offset_x += scaled_size_x;
+ }
+
+ offset_x = bounds.left;
+ offset_y += scaled_size_y;
+ }
+ }
+
+ @Override
+ public int getIntrinsicWidth()
+ {
+ final double rad = Math.toRadians(this.rotation);
+
+ return (int)(this.height * Math.abs(Math.sin(rad)) + this.width * Math.abs(Math.cos(rad)));
+ }
+
+ @Override
+ public int getIntrinsicHeight()
+ {
+ final double rad = Math.toRadians(this.rotation);
+
+ return (int)(this.width * Math.abs(Math.sin(rad)) + this.height * Math.abs(Math.cos(rad)));
+ }
+
+ @Override
+ public int getOpacity()
+ {
+ return this.paint.getAlpha();
+ }
+
+ @Override
+ public void setAlpha(final int alpha)
+ {
+ this.paint.setAlpha(alpha);
+ this.invalidateSelf();
+ }
+
+ @Override
+ public void setColorFilter(final ColorFilter cf)
+ {
+ this.paint.setColorFilter(cf);
+ this.invalidateSelf();
+ }
+
+ public float getRotation()
+ {
+ return this.rotation;
+ }
+
+ public void setRotation(final float rotation)
+ {
+ this.rotation = rotation;
+ this.invalidateSelf();
+ }
+
+
+ /**
+ * Enables or disables anti-aliasing for this drawable. Anti-aliasing affects
+ * the edges of the bitmap only so it applies only when the drawable is rotated.
+ *
+ * @param aa True if the bitmap should be anti-aliased, false otherwise.
+ */
+ public void setAntiAlias(final boolean aa)
+ {
+ this.paint.setAntiAlias(aa);
+ this.invalidateSelf();
+ }
+
+ @Override
+ public void setFilterBitmap(final boolean filter)
+ {
+ this.paint.setFilterBitmap(filter);
+ this.invalidateSelf();
+ }
+
+ @Override
+ public void setDither(final boolean dither)
+ {
+ this.paint.setDither(dither);
+ this.invalidateSelf();
+ }
+
+ public void release()
+ {
+ if (!this.abandon)
+ {
+ this.abandon = true;
+
+ for (final Bitmap[][] bitmaps_of_q : this.bitmaps)
+ {
+ for (final Bitmap[] bitmaps_row : bitmaps_of_q)
+ {
+ for (final Bitmap bitmap : bitmaps_row)
+ {
+ bitmap.recycle();
+ }
+ }
+ }
+
+ System.gc();
+ }
+ }
+}
diff --git a/src/com/almalence/plugins/processing/focusstacking/FocusStackingProcessingPlugin.java b/src/com/almalence/plugins/processing/focusstacking/FocusStackingProcessingPlugin.java
new file mode 100755
index 00000000..e7ca1227
--- /dev/null
+++ b/src/com/almalence/plugins/processing/focusstacking/FocusStackingProcessingPlugin.java
@@ -0,0 +1,1497 @@
+/*
+The contents of this file are subject to the Mozilla Public License
+Version 1.1 (the "License"); you may not use this file except in
+compliance with the License. You may obtain a copy of the License at
+http://www.mozilla.org/MPL/
+
+Software distributed under the License is distributed on an "AS IS"
+basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+License for the specific language governing rights and limitations
+under the License.
+
+The Original Code is collection of files collectively known as Open Camera.
+
+The Initial Developer of the Original Code is Almalence Inc.
+Portions created by Initial Developer are Copyright (C) 2013
+by Almalence Inc. All Rights Reserved.
+ */
+
+package com.almalence.plugins.processing.focusstacking;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+import android.app.ProgressDialog;
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.graphics.Bitmap;
+import android.graphics.Point;
+import android.os.AsyncTask;
+import android.os.Build;
+import android.os.Handler;
+import android.os.Message;
+import android.preference.PreferenceFragment;
+import android.preference.PreferenceManager;
+import android.util.Log;
+import android.view.Display;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.WindowManager;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemSelectedListener;
+import android.widget.Button;
+import android.widget.ProgressBar;
+import android.widget.SeekBar;
+import android.widget.SeekBar.OnSeekBarChangeListener;
+import android.widget.TextView;
+
+import com.almalence.SwapHeap;
+import com.almalence.asynctaskmanager.OnTaskCompleteListener;
+import com.almalence.focuscam.ApplicationInterface;
+import com.almalence.focuscam.ApplicationScreen;
+import com.almalence.focuscam.ConfigParser;
+import com.almalence.focuscam.PluginManager;
+import com.almalence.focuscam.PluginProcessing;
+import com.almalence.focuscam.R;
+import com.almalence.focuscam.cameracontroller.CameraController;
+import com.almalence.focusstacking.AlmaShotFocusStacking;
+import com.almalence.util.Size;
+//import android.util.Size;
+
+/* */
+//
+/***
+ * Implements Focus stacking processing plugin.
+ ***/
+
+public class FocusStackingProcessingPlugin extends PluginProcessing implements OnClickListener,
+ OnSeekBarChangeListener, OnItemSelectedListener, OnTaskCompleteListener, OnShowOffClickListener, Handler.Callback
+{
+ private String TAG = "FStacking";
+ private byte[] allInFocusYUV; // Result
+// private int allInFocusYUV; // Result
+// private int baseFrameAddress;
+ private byte[] baseFrame;
+
+ private static boolean EditMode = false;
+ private static int SavePreference;
+
+ private static String sEditModePref;
+ private static String sSaveModePref;
+
+ private int mLayoutOrientationCurrent = 0;
+ private int mImageDataOrientation = 0;
+ private int mDisplayOrientationCurrent = 0;
+ private int mSensorOrientation = 0;
+ private boolean mCameraMirrored = false;
+
+ private boolean postProcessingRun = false;
+
+ private int mImageWidth;
+ private int mImageHeight;
+
+ private int mResultImageWidth;
+ private int mResultImageHeight;
+
+ private int mImageAmount;
+ private int[] mInputFrames;
+ private int[] mInputFramesLength;
+
+// private int mOutImageWidth;
+// private int mOutImageHeight;
+
+ protected static List ResolutionsOutputMPixList;
+ protected static List ResolutionsOutputSizeList;
+ protected static List ResolutionsOutputIdxesList;
+ protected static List ResolutionsOutputNamesList;
+
+ public static String sOutputImageSizeRearPref;
+ public static String sOutputImageSizeFrontPref;
+ public static int outputImageSizeIdxPreference;
+
+ private List focusDistances; //Focus distances for each input frame
+//
+ private int mBaseFrameIndex; //Frame around which focus depth will be changed
+ private int mCurrentFocusDepth; //How much frames to take for focus stacking process
+//
+ private byte[] mFocusAreasMap = null; //Shows on which input frame desired area is better focused
+ private byte[] mFocusAreasMapImage = null;
+// private int mFocusAreasMapAddress = 0;
+ private boolean mShowFocusAreasMap = false;
+ private boolean mKeepResultBitmap = false;
+
+ private ComplexBitmap mBitmap = null;
+
+ private long sessionID = 0;
+
+ public FocusStackingProcessingPlugin()
+ {
+ super("com.almalence.plugins.focusstackingprocessing", "focusbracketing", R.xml.preferences_processing_focusstacking,
+ 0, 0, null);
+ }
+
+ @Override
+ public void onCreate()
+ {
+ sEditModePref = ApplicationScreen.getAppResources().getString(R.string.Preference_FocusBracketingEditModePref);
+ sSaveModePref = ApplicationScreen.getAppResources().getString(R.string.Preference_FocusBracketing_Save_Pref);
+
+ sOutputImageSizeRearPref = ApplicationScreen.getAppResources().getString(R.string.Preference_OutputImageSizeRearValue);
+ sOutputImageSizeFrontPref = ApplicationScreen.getAppResources().getString(R.string.Preference_OutputImageSizeFrontValue);
+ }
+
+ @Override
+ public void onResume()
+ {
+ getPrefs();
+ }
+
+ @Override
+ public void onPause()
+ {
+ if(postProcessingRun)
+ {
+// Log.e(TAG, "PAUSE................postProcessingRun = true. Call AlmaShotFocusStacking.Release()");
+ this.imageView.setData(null);
+ postProcessingRun = false;
+ AlmaShotFocusStacking.Release();
+ }
+ }
+
+
+ private void getPrefs()
+ {
+ // Get the xml/preferences.xml preferences
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.instance
+ .getBaseContext());
+// ContrastPreference = prefs.getString("contrastPrefHDR", "1");
+// mContrastPreference = prefs.getString("mcontrastPrefHDR", "2");
+// NoisePreference = prefs.getString("noisePrefHDR", "0");
+// ExpoPreference = prefs.getString("expoPrefHDR", "1");
+// ColorPreference = prefs.getString("colorPrefHDR", "1");
+
+ EditMode = prefs.getBoolean(sEditModePref, false);
+
+ SavePreference = Integer.parseInt(prefs.getString(sSaveModePref, "0"));
+ }
+
+ @Override
+ public void onPreferenceCreate(PreferenceFragment pf)
+ {
+// CharSequence[] entries = null;
+// CharSequence[] entryValues = null;
+//
+// int idx = 0;
+// int currentIdx = -1;
+// String opt1 = "";
+// String opt2 = "";
+
+// opt1 = sOutputImageSizeRearPref;
+// opt2 = sOutputImageSizeFrontPref;
+// currentIdx = outputImageSizeIdxPreference;
+//
+// if (currentIdx == -1)
+// {
+// currentIdx = 0;
+// }
+//
+// entries = ResolutionsOutputNamesList.toArray(
+// new CharSequence[ResolutionsOutputNamesList.size()]);
+// entryValues = ResolutionsOutputIdxesList.toArray(
+// new CharSequence[ResolutionsOutputIdxesList.size()]);
+//
+// if (ResolutionsOutputIdxesList != null)
+// {
+// ListPreference lp = (ListPreference)pf.findPreference(opt1);
+// ListPreference lp2 = (ListPreference)pf.findPreference(opt2);
+//
+// if (CameraController.getCameraIndex() == 0 && lp2 != null)
+// pf.getPreferenceScreen().removePreference(lp2);
+// else if (lp != null && lp2 != null)
+// {
+// pf.getPreferenceScreen().removePreference(lp);
+// lp = lp2;
+// }
+//
+// if (lp != null)
+// {
+// lp.setEntries(entries);
+// lp.setEntryValues(entryValues);
+//
+// if (currentIdx != -1)
+// {
+// // set currently selected image size
+// for (idx = 0; idx < entryValues.length; ++idx)
+// {
+// if (Integer.valueOf(entryValues[idx].toString()) == currentIdx)
+// {
+// lp.setValueIndex(idx);
+// break;
+// }
+// }
+// } else
+// {
+// lp.setValueIndex(0);
+// }
+//
+//// lp.setOnPreferenceChangeListener(new OnPreferenceChangeListener()
+//// {
+//// public boolean onPreferenceChange(Preference preference, Object newValue)
+//// {
+//// MainActivity.outputImageSizeIdxPreference = Integer.parseInt(newValue.toString());
+//// SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(thiz.getActivity());
+//// prefs.edit()
+//// .putString(
+//// MainActivity.CAMERA_INDEX == 0 ? MainActivity.sOutputImageSizeRearPref
+//// : MainActivity.sOutputImageSizeFrontPref, String.valueOf(MainActivity.outputImageSizeIdxPreference)).commit();
+//// return true;
+//// }
+//// });
+// }
+// }
+ }
+
+
+ @Override
+ public void onCameraParametersSetup()
+ {
+// SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ApplicationScreen.instance.getBaseContext());
+//
+// populateOutputDimensions();
+// outputImageSizeIdxPreference = Integer.parseInt(prefs.getString(CameraController.getCameraIndex() == 0 ? sOutputImageSizeRearPref : sOutputImageSizeFrontPref, "0"));
+// CameraController.Size outputSize = ResolutionsOutputSizeList.get(outputImageSizeIdxPreference);
+// mOutImageWidth = outputSize.getWidth();
+// mOutImageHeight = outputSize.getHeight();
+ }
+
+// public static void populateOutputDimensions()
+// {
+// ResolutionsOutputMPixList = new ArrayList();
+// ResolutionsOutputSizeList = new ArrayList();
+// ResolutionsOutputIdxesList = new ArrayList();
+// ResolutionsOutputNamesList = new ArrayList();
+//
+// int imageSizeIdxPreference = CameraController.getCameraImageSizeIndex();
+// for (int i = imageSizeIdxPreference; i < CameraController.ResolutionsNamesList.size(); i++)
+// {
+// ResolutionsOutputMPixList.add(CameraController.ResolutionsMPixList.get(i));
+// ResolutionsOutputSizeList.add(CameraController.ResolutionsSizeList.get(i));
+// ResolutionsOutputIdxesList.add(CameraController.ResolutionsIdxesList.get(i));
+// ResolutionsOutputNamesList.add(CameraController.ResolutionsNamesList.get(i));
+// }
+// }
+
+ @Override
+ public void onStartProcessing(long SessionID)
+ {
+ if (EditMode)
+ {
+ Message msg = new Message();
+ msg.what = ApplicationInterface.MSG_PROCESSING_BLOCK_UI;
+ ApplicationScreen.getMessageHandler().sendMessage(msg);
+
+ PluginManager.getInstance().sendMessage(ApplicationInterface.MSG_BROADCAST,
+ ApplicationInterface.MSG_CONTROL_LOCKED);
+
+ ApplicationScreen.getGUIManager().lockControls = true;
+ }
+
+ sessionID = SessionID;
+
+ PluginManager.getInstance().addToSharedMem("modeSaveName" + sessionID,
+ ConfigParser.getInstance().getMode(mode).modeSaveName);
+
+ mImageDataOrientation = ApplicationScreen.getGUIManager().getImageDataOrientation();
+ mDisplayOrientationCurrent = ApplicationScreen.getGUIManager().getDisplayOrientation();
+ int orientation = ApplicationScreen.getGUIManager().getLayoutOrientation();
+ mLayoutOrientationCurrent = orientation == 0 || orientation == 180 ? orientation : (orientation + 180) % 360;
+
+ mCameraMirrored = Boolean.parseBoolean(PluginManager.getInstance().getFromSharedMem(
+ "cameraMirrored" + sessionID));
+
+ mSensorOrientation = CameraController.getSensorOrientation(mCameraMirrored);
+
+
+ mImageWidth = Integer.parseInt(PluginManager.getInstance().getFromSharedMem("imageWidth" + sessionID));
+ mImageHeight = Integer.parseInt(PluginManager.getInstance().getFromSharedMem("imageHeight" + sessionID));
+
+// Log.e(TAG, "START!!!!");
+// AlmaShotFocusStacking.AlmaShotInitialize();
+ mImageAmount = Integer.parseInt(PluginManager.getInstance().getFromSharedMem(
+ "amountofcapturedframes" + sessionID));
+
+ mInputFrames = new int[mImageAmount];
+ mInputFramesLength = new int[mImageAmount];
+
+ focusDistances = new ArrayList();
+
+// mFocusAreasMap = new byte[mImageWidth/16 * mImageHeight/16];
+
+ for (int i = 0; i < mImageAmount; i++)
+ {
+ mInputFrames[i] = Integer.parseInt(PluginManager.getInstance().getFromSharedMem(
+ "frame" + (i + 1) + sessionID));
+ mInputFramesLength[i] = Integer.parseInt(PluginManager.getInstance().getFromSharedMem(
+ "framelen" + (i + 1) + sessionID));
+
+ focusDistances.add(Float.parseFloat(PluginManager.getInstance().getFromSharedMem(
+ "focusdistance" + (i + 1) + sessionID)));
+ }
+
+ AlmaShotFocusStacking.Initialize(mInputFrames, focusDistances, mImageAmount, mImageWidth, mImageHeight);
+// Log.e(TAG, "Almashot focus stacking initialized");
+
+
+ if (!EditMode)
+ {
+ // focus stacking processing
+// FStackingReInit(0, mImageAmount);
+ this.mBaseFrameIndex = Math.round(mImageAmount/2); // initial base frame is a middle frame of frames sequence
+ this.mCurrentFocusDepth = Math.max(this.mBaseFrameIndex +1, mImageAmount - this.mBaseFrameIndex); //Initial processing result contains all input frames
+
+ FStackingProcessing(false);
+// Log.e(TAG, "FStackingProcessing finished");
+
+ saveInputAndProcessedFrames();
+
+ if(mImageDataOrientation == 90 || mImageDataOrientation == 270)
+ {
+ mResultImageWidth = mImageHeight;
+ mResultImageHeight = mImageWidth;
+ }
+ else
+ {
+ mResultImageWidth = mImageWidth;
+ mResultImageHeight = mImageHeight;
+ }
+
+ int frame_len = allInFocusYUV.length;
+ int frame = SwapHeap.SwapToHeap(allInFocusYUV);
+
+ PluginManager.getInstance().addToSharedMem("resultfromshared" + sessionID, "true");
+
+ PluginManager.getInstance().addToSharedMem("writeorientationtag" + sessionID, "true");
+ PluginManager.getInstance().addToSharedMem("resultframeorientation1" + sessionID,
+ String.valueOf(mImageDataOrientation));
+ PluginManager.getInstance().addToSharedMem("amountofresultframes" + sessionID, "1");
+ PluginManager.getInstance().addToSharedMem("resultframe1" + sessionID, String.valueOf(frame));
+ PluginManager.getInstance().addToSharedMem("resultframelen1" + sessionID, String.valueOf(frame_len));
+
+ PluginManager.getInstance().addToSharedMem("saveImageWidth" + sessionID, String.valueOf(mResultImageWidth));
+ PluginManager.getInstance().addToSharedMem("saveImageHeight" + sessionID, String.valueOf(mResultImageHeight));
+
+// int imagesAmount = Integer.parseInt(PluginManager.getInstance().getFromSharedMem(
+// "amountofcapturedframes" + sessionID));
+ AlmaShotFocusStacking.Release();
+// AlmaShotFocusStacking.AlmaShotRelease();
+// Log.e(TAG, "AlmaShotFocusStacking.Released");
+ }
+// Log.e(TAG, "FINISHED!!!");
+
+ }
+
+// private void FStackingReInit(int baseFrameIndex, int focusDepth)
+// {
+// Log.e(TAG, "FStackingPreview. baseFrameIndex = " + baseFrameIndex + " focusDepth = " + focusDepth);
+// //int[] compressed_frame = new int[focusDepth];
+// int frameAmount = mImageAmount;
+// int firstFrameIndex = 0;
+// int lastFrameIndex = mImageAmount - 1;
+//
+// if(baseFrameIndex > 0)
+// {
+// firstFrameIndex = baseFrameIndex - (focusDepth - 1);
+// lastFrameIndex = baseFrameIndex + (focusDepth - 1);
+//
+// if(firstFrameIndex < 0) firstFrameIndex = 0;
+// if(lastFrameIndex > (mImageAmount - 1)) lastFrameIndex = mImageAmount - 1;
+// }
+//
+// frameAmount = lastFrameIndex - firstFrameIndex + 1;
+// Log.e(TAG, "FStackingPreview. frameAmount = " + frameAmount);
+// int[] compressed_frame = new int[frameAmount];
+// float[] focusDist = new float[frameAmount];
+//
+// int index = 0;
+// for(int i = firstFrameIndex; i <= lastFrameIndex; i++)
+// {
+// compressed_frame[index] = mInputFrames[i];
+// focusDist[index] = focusDistances[i];
+// index++;
+// }
+//
+// AlmaShotFocusStacking.FStackingInitialize(compressed_frame, focusDist, frameAmount, mImageWidth, mImageHeight, mFocusAreasMap);
+//// Log.e(TAG, "AddYUVFrames");
+//// AlmaShotFocusStacking.AddYUVFrames(compressed_frame, focusDistances, frameAmount, mImageWidth, mImageHeight);
+//
+// //Saving input frames
+//// String fileFormat = PluginManager.getInstance().getFileFormat();
+//// for (int i = 0; i < imagesAmount; ++i)
+//// {
+//// String evmark = String.format("_%01d", i);
+//// int yuvBuffer = AlmaShotFocusStacking.getInputFrame(i);
+//// PluginManager.getInstance().saveInputFile(true, sessionID, i, null, yuvBuffer, fileFormat + evmark);
+//// }
+//
+//// Log.e(TAG, "Align");
+//// AlmaShotFocusStacking.Align(mFocusAreasMap, mImageWidth, mImageHeight, frameAmount);
+//
+//
+//// for(int i = 0; i < imagesAmount; ++i)
+//// {
+//// int alignedFrame = AlmaShotFocusStacking.getAlignedInputFrame(i);
+//// Log.e(TAG, "Aligned frame " + i + " is " + alignedFrame);
+//// }
+//// Log.e(TAG, "GetFocusAreasMap");
+//// res = AlmaShotFocusStacking.GetFocusAreasMap(mImageWidth, mImageHeight, imagesAmount, focusedAreasMap);
+//// Log.e(TAG, "GetFocusAreasMap res = " + res);
+//
+//
+//
+//// int nf = FocusStackingProcessingPlugin.getNoise();
+////
+//// if(CameraController.isNexus6 && CameraController.isUseCamera2())
+//// nf = -1;
+////
+//// AlmaShotFocusStacking.HDRPreview(imagesAmount, mImageWidth, mImageHeight, pview, FocusStackingProcessingPlugin.getExposure(true),
+//// FocusStackingProcessingPlugin.getVividness(true), FocusStackingProcessingPlugin.getContrast(true),
+//// FocusStackingProcessingPlugin.getMicrocontrast(true), 0, nf, mCameraMirrored);
+//
+// // android thing (OutOfMemory for bitmaps):
+// // http://stackoverflow.com/questions/3117429/garbage-collector-in-android
+// System.gc();
+// }
+
+ private void FStackingProcessing(boolean transformResult)
+ {
+ float focusDistance = focusDistances.get(mBaseFrameIndex);
+// if(allInFocusYUV != -1)
+// AlmaShotFocusStacking.FStackingFreeResult(allInFocusYUV);
+ allInFocusYUV = AlmaShotFocusStacking.Process(focusDistance, mCurrentFocusDepth, mImageDataOrientation, mCameraMirrored, transformResult);
+// allInFocusYUV = AlmaShotFocusStacking.FStackingProcess(mImageDataOrientation, mCameraMirrored, transformResult);
+ }
+
+
+ private void saveInputAndProcessedFrames()
+ {
+ try
+ {
+ Log.e(TAG, "saveInputAndProcessedFrames - start");
+ // 0 - save only final result
+ // 1 - save aligned input frames and final result
+ // 2 - save all: non-aligned input frames, aligned input frames and final result
+
+ if (FocusStackingProcessingPlugin.SavePreference != 0)
+ {
+ int[] alignedFrames = AlmaShotFocusStacking.GetAlignedFrames();
+ Log.e(TAG, "Aligned frames get into JAVA code");
+ //Saving aligned frames
+ String fileFormat = PluginManager.getInstance().getFileFormat();
+// for (int i = 0; i < mImageAmount; ++i)
+// {
+// String evmark = String.format("_aligned_%3.1f", focusDistances.get(i));
+// int yuvBuffer = alignedFrames[i];//AlmaShotFocusStacking.GetAlignedFrame(i);
+// PluginManager.getInstance().saveInputFile(true, sessionID, i, null, yuvBuffer, fileFormat + evmark);
+// }
+
+ String evmark = String.format("_alignedFrames");
+ PluginManager.getInstance().saveInputFileMPO(true, sessionID, mImageAmount, alignedFrames, fileFormat + evmark);
+ Log.e(TAG, "Aligned frames saved into MPO file");
+
+ if(FocusStackingProcessingPlugin.SavePreference == 2)
+ {
+ //Saving input frames
+ fileFormat = PluginManager.getInstance().getFileFormat();
+ for (int i = 0; i < mImageAmount; ++i)
+ {
+ evmark = String.format("_%3.1f", focusDistances.get(i));
+ int yuvBuffer = AlmaShotFocusStacking.GetInputFrame(i);
+ PluginManager.getInstance().saveInputFile(true, sessionID, i, null, yuvBuffer, fileFormat + evmark);
+ }
+ }
+
+
+ }
+
+ Log.e(TAG, "saveInputAndProcessedFrames - end");
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+
+
+ private class FocusStackingTask extends AsyncTask