LOCAL_CFLAGS += -DPLATFORM_ANDROID
LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_V7A_FEATURES
-#LOCAL_CFLAGS += -D__SUPPORT_TEGRA3
+LOCAL_CFLAGS += -D__SUPPORT_TEGRA3
#LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_FEATURES
LOCAL_PRELINK_MODULE := false
LOCAL_CFLAGS += -DPLATFORM_ANDROID
LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_V7A_FEATURES
-#LOCAL_CFLAGS += -D__SUPPORT_TEGRA3
+LOCAL_CFLAGS += -D__SUPPORT_TEGRA3
#LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_FEATURES
LOCAL_MODULE := libOpenCVEngine_jni
link_directories("${ANDROID_SOURCE_TREE}/out/target/product/generic/system/lib")
-INCLUDE_DIRECTORIES(BEFORE
+if (ANDROID_VERSION VERSION_LESS "4.1")
+ INCLUDE_DIRECTORIES(BEFORE
${ANDROID_SOURCE_TREE}
${ANDROID_SOURCE_TREE}/frameworks/base/include/ui
${ANDROID_SOURCE_TREE}/frameworks/base/include/surfaceflinger
${ANDROID_SOURCE_TREE}/frameworks/base/include/camera
${ANDROID_SOURCE_TREE}/frameworks/base/include/media
- ${ANDROID_SOURCE_TREE}/frameworks/base/include/camera
${ANDROID_SOURCE_TREE}/frameworks/base/include
${ANDROID_SOURCE_TREE}/system/core/include
${ANDROID_SOURCE_TREE}/hardware/libhardware/include
${ANDROID_SOURCE_TREE}/frameworks/base/native/include
)
+else()
+ INCLUDE_DIRECTORIES(BEFORE
+ ${ANDROID_SOURCE_TREE}
+ ${ANDROID_SOURCE_TREE}/frameworks/native/include
+ ${ANDROID_SOURCE_TREE}/frameworks/av/include
+ ${ANDROID_SOURCE_TREE}/system/core/include
+ ${ANDROID_SOURCE_TREE}/hardware/libhardware/include
+ )
+endif()
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
-#if !defined(ANDROID_r2_2_0) && !defined(ANDROID_r2_3_3) && !defined(ANDROID_r3_0_1) && !defined(ANDROID_r4_0_0) && !defined(ANDROID_r4_0_3)
+#if !defined(ANDROID_r2_2_0) && !defined(ANDROID_r2_3_3) && !defined(ANDROID_r3_0_1) && !defined(ANDROID_r4_0_0) && !defined(ANDROID_r4_0_3) && !defined(ANDROID_r4_1_1)
# error Building camera wrapper for your version of Android is not supported by OpenCV. You need to modify OpenCV sources in order to compile camera wrapper for your version of Android.
#endif
#include "camera_wrapper.h"
#include "../include/camera_properties.h"
-#if defined(ANDROID_r3_0_1) || defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3)
+#if defined(ANDROID_r3_0_1) || defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3) || defined(ANDROID_r4_1_1)
//Include SurfaceTexture.h file with the SurfaceTexture class
# include <gui/SurfaceTexture.h>
# define MAGIC_OPENCV_TEXTURE_ID (0x10)
#else // defined(ANDROID_r3_0_1) || defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3)
//TODO: This is either 2.2 or 2.3. Include the headers for ISurface.h access
+#if defined(ANDROID_r4_1_1)
+#include <gui/ISurface.h>
+#include <gui/BufferQueue.h>
+#else
# include <surfaceflinger/ISurface.h>
+#endif // defined(ANDROID_r4_1_1)
#endif // defined(ANDROID_r3_0_1) || defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3)
#include <string>
using namespace android;
+void debugShowFPS();
+
+#if defined(ANDROID_r4_1_1)
+class ConsumerListenerStub: public BufferQueue::ConsumerListener
+{
+public:
+ virtual void onFrameAvailable()
+ {
+ }
+ virtual void onBuffersReleased()
+ {
+ }
+};
+#endif
+
void debugShowFPS()
{
static int mFrameCount = 0;
}
virtual void postData(int32_t msgType, const sp<IMemory>& dataPtr
-#if defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3)
- ,camera_frame_metadata_t* metadata
+#if defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3) || defined(ANDROID_r4_1_1)
+ ,camera_frame_metadata_t*
#endif
)
{
pdstatus = camera->setPreviewTexture(surfaceTexture);
if (pdstatus != 0)
LOGE("initCameraConnect: failed setPreviewTexture call; camera migth not work correctly");
+#elif defined(ANDROID_r4_1_1)
+ sp<BufferQueue> bufferQueue = new BufferQueue();
+ sp<BufferQueue::ConsumerListener> queueListener = new ConsumerListenerStub();
+ bufferQueue->consumerConnect(queueListener);
+ pdstatus = camera->setPreviewTexture(bufferQueue);
+ if (pdstatus != 0)
+ LOGE("initCameraConnect: failed setPreviewTexture call; camera migth not work correctly");
#endif
-#if !(defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3))
+#if (defined(ANDROID_r2_2_0) || defined(ANDROID_r2_3_3) || defined(ANDROID_r3_0_1))
# if 1
////ATTENTION: switching between two versions: with and without copying memory inside Android OS
//// see the method CameraService::Client::copyFrameAndPostCopiedFrame and where it is used
camera->setPreviewCallbackFlags( CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK | CAMERA_FRAME_CALLBACK_FLAG_COPY_OUT_MASK);//with copy
#endif //!(defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3))
+ LOGD("Starting preview");
status_t resStart = camera->startPreview();
if (resStart != 0)
handler->closeCameraConnect();
handler = 0;
}
+ else
+ {
+ LOGD("Preview started successfully");
+ }
return handler;
}