diff --git a/modules/androidcamera/camera_wrapper/camera_wrapper.cpp b/modules/androidcamera/camera_wrapper/camera_wrapper.cpp index ca631fc21e..03796d1ec8 100644 --- a/modules/androidcamera/camera_wrapper/camera_wrapper.cpp +++ b/modules/androidcamera/camera_wrapper/camera_wrapper.cpp @@ -1,6 +1,6 @@ #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) && \ - !defined(ANDROID_r4_2_0) && !defined(ANDROID_r4_3_0) + !defined(ANDROID_r4_2_0) && !defined(ANDROID_r4_3_0) && !defined(ANDROID_r4_4_0) # 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 @@ -22,7 +22,7 @@ #elif defined(ANDROID_r4_1_1) || defined(ANDROID_r4_2_0) # include # include -#elif defined(ANDROID_r4_3_0) +#elif defined(ANDROID_r4_3_0) || defined(ANDROID_r4_4_0) # include # include #else @@ -74,6 +74,20 @@ public: { } }; +#elif defined(ANDROID_r4_4_0) +class ConsumerListenerStub: public android::BnConsumerListener +{ +public: + virtual void onFrameAvailable() + { + } + virtual void onBuffersReleased() + { + } + virtual ~ConsumerListenerStub() + { + } +}; #endif std::string getProcessName() @@ -306,7 +320,8 @@ public: } virtual void postData(int32_t msgType, const sp& dataPtr - #if defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3) || defined(ANDROID_r4_1_1) || defined(ANDROID_r4_2_0) || defined(ANDROID_r4_3_0) +#if defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3) || defined(ANDROID_r4_1_1) || defined(ANDROID_r4_2_0) \ + || defined(ANDROID_r4_3_0) || defined(ANDROID_r4_4_0) ,camera_frame_metadata_t* #endif ) @@ -623,7 +638,14 @@ CameraHandler* CameraHandler::initCameraConnect(const CameraCallback& callback, bufferStatus = camera->setPreviewTexture(bufferQueue); if (bufferStatus != 0) LOGE("initCameraConnect: failed setPreviewTexture call; camera might not work correctly"); -#endif +# elif defined(ANDROID_r4_4_0) + sp bufferQueue = new BufferQueue(); + sp queueListener = new ConsumerListenerStub(); + bufferQueue->consumerConnect(queueListener, true); + bufferStatus = handler->camera->setPreviewTarget(bufferQueue); + if (bufferStatus != 0) + LOGE("applyProperties: failed setPreviewTexture call; camera might not work correctly"); +# endif #if (defined(ANDROID_r2_2_0) || defined(ANDROID_r2_3_3) || defined(ANDROID_r3_0_1)) # if 1 @@ -663,7 +685,8 @@ void CameraHandler::closeCameraConnect() } camera->stopPreview(); -#if defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3) || defined(ANDROID_r4_1_1) || defined(ANDROID_r4_2_0) || defined(ANDROID_r4_3_0) +#if defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3) || defined(ANDROID_r4_1_1) || defined(ANDROID_r4_2_0) \ + || defined(ANDROID_r4_3_0) || defined(ANDROID_r4_3_0) camera->setPreviewCallbackFlags(CAMERA_FRAME_CALLBACK_FLAG_NOOP); #endif camera->disconnect(); @@ -914,7 +937,8 @@ void CameraHandler::applyProperties(CameraHandler** ppcameraHandler) CameraParameters curCameraParameters((*ppcameraHandler)->params.flatten()); -#if defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3) || defined(ANDROID_r4_1_1) || defined(ANDROID_r4_2_0) || defined(ANDROID_r4_3_0) +#if defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3) || defined(ANDROID_r4_1_1) || defined(ANDROID_r4_2_0) \ + || defined(ANDROID_r4_3_0) || defined(ANDROID_r4_4_0) CameraHandler* handler=*ppcameraHandler; handler->camera->stopPreview(); @@ -943,6 +967,13 @@ void CameraHandler::applyProperties(CameraHandler** ppcameraHandler) bufferStatus = handler->camera->setPreviewTexture(bufferQueue); if (bufferStatus != 0) LOGE("applyProperties: failed setPreviewTexture call; camera might not work correctly"); +# elif defined(ANDROID_r4_4_0) + sp bufferQueue = new BufferQueue(); + sp queueListener = new ConsumerListenerStub(); + bufferQueue->consumerConnect(queueListener, true); + bufferStatus = handler->camera->setPreviewTarget(bufferQueue); + if (bufferStatus != 0) + LOGE("applyProperties: failed setPreviewTexture call; camera might not work correctly"); # endif handler->camera->setPreviewCallbackFlags( CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK | CAMERA_FRAME_CALLBACK_FLAG_COPY_OUT_MASK);//with copy diff --git a/platforms/scripts/camera_build.conf b/platforms/scripts/camera_build.conf index fb79cacc21..e41dbcf4c0 100644 --- a/platforms/scripts/camera_build.conf +++ b/platforms/scripts/camera_build.conf @@ -25,3 +25,7 @@ native_camera_r4.3.0; armeabi; 14; $ANDROID_STUB_ROOT/4.3.0 native_camera_r4.3.0; armeabi-v7a; 14; $ANDROID_STUB_ROOT/4.3.0 native_camera_r4.3.0; x86; 14; $ANDROID_STUB_ROOT/4.3.0 native_camera_r4.3.0; mips; 14; $ANDROID_STUB_ROOT/4.3.0 +native_camera_r4.4.0; armeabi; 14; $ANDROID_STUB_ROOT/4.4.0 +native_camera_r4.4.0; armeabi-v7a; 14; $ANDROID_STUB_ROOT/4.4.0 +native_camera_r4.4.0; x86; 14; $ANDROID_STUB_ROOT/4.4.0 +native_camera_r4.4.0; mips; 14; $ANDROID_STUB_ROOT/4.4.0