https://github.com/opencv/opencv/wiki

http://code.opencv.org/issues/4185

Hello,

I finally get a ride of Android build from sources.
This is built only for arm devices.

you can found the libnative_camera_r5.0.0.so here : https://svn.scolring.org/trunk/dependencies/OpenCV/SDK/android/armeabi-v7a/sdk/native/libs/armeabi-v7a/libnative_camera_r5.0.0.so

the modified camera wrapper :

 .../camera_wrapper/camera_wrapper.cpp              | 62 +++++++++++++++++++---
1 file changed, 55 insertions(+), 7 deletions(-) diff --git a/modules/androidcamera/camera_wrapper/camera_wrapper.cpp b/modules/androidcamera/camera_wrapper/camera_wrapper.cpp
index 202aa29..dafbe64 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_4_0)
+ !defined(ANDROID_r4_2_0) && !defined(ANDROID_r4_3_0) && !defined(ANDROID_r4_4_0) && !defined(ANDROID_r5_0_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
@@ -8,7 +8,7 @@
#include <camera/Camera.h>
#include <camera/CameraParameters.h> -#if defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3)
+#if defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3) || defined(ANDROID_r5_0_0)
# include <system/camera.h>
#endif //defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3) @@ -22,7 +22,7 @@
#elif defined(ANDROID_r4_1_1) || defined(ANDROID_r4_2_0)
# include <gui/ISurface.h>
# include <gui/BufferQueue.h>
-#elif defined(ANDROID_r4_3_0) || defined(ANDROID_r4_4_0)
+#elif defined(ANDROID_r4_3_0) || defined(ANDROID_r4_4_0) || defined(ANDROID_r5_0_0)
# include <gui/IGraphicBufferProducer.h>
# include <gui/BufferQueue.h>
# include <ui/GraphicBuffer.h>
@@ -95,9 +95,25 @@ public:
{
}
};
+#elif defined(ANDROID_r5_0_0)
+class ConsumerListenerStub: public android::BnConsumerListener
+{
+public:
+ virtual void onFrameAvailable()
+ {
+ }
+ virtual void onBuffersReleased()
+ {
+ }
+ virtual void onSidebandStreamChanged()
+ {
+ }
+ virtual ~ConsumerListenerStub()
+ {
+ }
+};
#endif -
std::string getProcessName()
{
std::string result;
@@ -156,6 +172,9 @@ protected:
#if defined(ANDROID_r4_1_1) || defined(ANDROID_r4_2_0) || defined(ANDROID_r4_3_0) || defined(ANDROID_r4_4_0)
sp<BufferQueue> queue;
sp<ConsumerListenerStub> listener;
+#elif defined(ANDROID_r5_0_0)
+ sp<IGraphicBufferProducer> queue;
+ sp<ConsumerListenerStub> listener;
#endif
CameraParameters* params;
CameraCallback cameraCallback;
@@ -344,7 +363,7 @@ public: virtual void postData(int32_t msgType, const sp<IMemory>& 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) || defined(ANDROID_r4_4_0)
+ || defined(ANDROID_r4_3_0) || defined(ANDROID_r4_4_0) || defined(ANDROID_r5_0_0)
,camera_frame_metadata_t*
#endif
)
@@ -689,6 +708,21 @@ CameraHandler* CameraHandler::initCameraConnect(const CameraCallback& callback,
bufferStatus = handler->camera->setPreviewTarget(handler->queue);
if (bufferStatus != 0)
LOGE("applyProperties: failed setPreviewTexture call; camera might not work correctly");
+# elif defined(ANDROID_r5_0_0)
+ void* buffer_queue_obj = operator new(sizeof(BufferQueue) + MAGIC_TAIL);
+
+ sp<IGraphicBufferProducer> producer;
+ sp<IGraphicBufferConsumer> consumer;
+ BufferQueue::createBufferQueue(&producer, &consumer);
+
+ consumer->setConsumerUsageBits(GraphicBuffer::USAGE_HW_TEXTURE);
+ void* consumer_listener_obj = operator new(sizeof(ConsumerListenerStub) + MAGIC_TAIL);
+ handler->listener = new(consumer_listener_obj) ConsumerListenerStub();
+ consumer->consumerConnect(handler->listener, true);
+ handler->queue = producer;
+ bufferStatus = handler->camera->setPreviewTarget(handler->queue);
+ 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))
@@ -730,7 +764,7 @@ 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) || defined(ANDROID_r4_4_0)
+ || defined(ANDROID_r4_3_0) || defined(ANDROID_r4_4_0) || defined(ANDROID_r5_0_0)
camera->setPreviewCallbackFlags(CAMERA_FRAME_CALLBACK_FLAG_NOOP);
#endif
camera->disconnect();
@@ -1055,7 +1089,7 @@ void CameraHandler::applyProperties(CameraHandler** ppcameraHandler)
(*ppcameraHandler)->params->setPreviewSize((*ppcameraHandler)->width, (*ppcameraHandler)->height); #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)
+ || defined(ANDROID_r4_3_0) || defined(ANDROID_r4_4_0) || defined(ANDROID_r5_0_0)
CameraHandler* handler=*ppcameraHandler; handler->camera->stopPreview();
@@ -1092,6 +1126,20 @@ void CameraHandler::applyProperties(CameraHandler** ppcameraHandler)
bufferStatus = handler->camera->setPreviewTarget(handler->queue);
if (bufferStatus != 0)
LOGE("applyProperties: failed setPreviewTexture call; camera might not work correctly");
+# elif defined(ANDROID_r5_0_0)
+ void* buffer_queue_obj = operator new(sizeof(BufferQueue) + MAGIC_TAIL);
+ sp<IGraphicBufferProducer> producer;
+ sp<IGraphicBufferConsumer> consumer;
+ BufferQueue::createBufferQueue(&producer, &consumer);
+
+ consumer->setConsumerUsageBits(GraphicBuffer::USAGE_HW_TEXTURE);
+ void* consumer_listener_obj = operator new(sizeof(ConsumerListenerStub) + MAGIC_TAIL);
+ handler->listener = new(consumer_listener_obj) ConsumerListenerStub();
+ consumer->consumerConnect(handler->listener, true);
+ handler->queue = producer;
+ bufferStatus = handler->camera->setPreviewTarget(handler->queue);
+ 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

Android Opencv NativeCameraView error in 5.0 lollipop versions (Bug #4185)的更多相关文章

  1. Android 5.0 Lollipop SDK下载地址(PASS)

    Android 5.0 ARM EABI v7a System Image https://dl-ssl.google.com/android/repository/sys-img/google_ap ...

  2. Android 5.0(Lollipop)中的SurfaceTexture,TextureView, SurfaceView和GLSurfaceView

    SurfaceView, GLSurfaceView, SurfaceTexture以及TextureView是Android当中名字比较绕,关系又比较密切的几个类.本文基于Android 5.0(L ...

  3. android 编译错误 Error:(1, 0) Plugin with id 'com.android.application' not found.

    在导入一个项目时,由于它本身的gradle版本比较高,你试用比较旧版本的gradle时就报出Plugin with id 'com.android.application' not found.的错误 ...

  4. Android OpenCV样例调试+报错处理

    1.OpenCV样例调试:<OpenCV Sample - image-manipulations>       blog+报错:E/CAMERA_ACTIVITY(17665): Cam ...

  5. Android5.0(Lollipop) BLE蓝牙4.0+浅析code(二)

    作者:Bgwan链接:https://zhuanlan.zhihu.com/p/23347612来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. Android5.0(L ...

  6. [Android]Android端ORM框架——RapidORM(v2.0)

    以下内容为原创,欢迎转载,转载请注明 来自天天博客:http://www.cnblogs.com/tiantianbyconan/p/5626716.html [Android]Android端ORM ...

  7. Vuforia Android 6 Camera Error

    环境 引擎: Unity 5.3.6f1 SDK: Vuforia 6.0.112 测试系统:Android 4.2/4.3 6.0 Android 6出错 在Android 6下Vuforia打印的 ...

  8. Android OpenCV 图像识别

    最近打算写一个android 平台opencv 的小程序,着手查找了一下资料.网络上的资料参差不齐,有一些都比较老旧,我参考了前面的方法找到了一个简单的搭建方法,分享给大家. 0,环境的搭建: jav ...

  9. Android进阶:七、Retrofit2.0原理解析之最简流程【下】

    紧接上文Android进阶:七.Retrofit2.0原理解析之最简流程[上] 一.请求参数整理 我们定义的接口已经被实现,但是我们还是不知道我们注解的请求方式,参数类型等是如何发起网络请求的呢? 这 ...

随机推荐

  1. js 数组容易弄混的那些方法

    js数组中 我们很多数组的方法都知道其中的含义 但是每一次用的都不是很顺手 下边我给大家写了一个小小的demo 来理解那些 近似”双胞胎“的东西 // splice方法 var a=[1,2,3,4, ...

  2. day17 内置函数

    一.内置函数接下来,我们就一起来看看python里的内置函数 分类图 1.作用域函数 基于字典的形式获取局部变量和全局变量 globals()——获取全局变量的字典 locals()——获取执行本方法 ...

  3. go生成xml

    package main import ( "encoding/xml" "fmt" // "os" ) type Servers stru ...

  4. Android开发:《Gradle Recipes for Android》阅读笔记(翻译)4.2——增加自定义task

    问题: 你想要在整体的构建过程中加入自定义的task. 解决方案: 使用dependOn属性将你的任务插入 directed acyclic graph 讨论: 在初始化阶段,Gradle将任务根据依 ...

  5. mysql中对应oracle中的to_char()和to_number()函数

    TO_CHAR(): CAST(123   AS   CHAR(3)) TO_NUMBER(): cast( '123 '   as   SIGNED   INTEGER)

  6. angularjs 复选框 单选框

    关于复选框,在做项目的时候,有一下几点心得 单选框 1.判断哪个单选框选中的情况 html代码 判断该复选框是否选中 $scope.agree.isChecked     判断这个值,如果等于1,代表 ...

  7. Java源码之Object

    本文出自:http://blog.csdn.net/dt235201314/article/details/78318399 一丶概述 JAVA中所有的类都继承自Object类,就从Object作为源 ...

  8. Linux下简单的多线程编程--线程池的实现

    /* 写在前面的话: 今天刚“开原”,选择了一篇关于线程池的文件与大家分享,希望能对您学习有所帮助,也希望能与大家共同学习! 选择在这个特殊的时候注册并发文章也是有一些我个人特殊的意义的,看我的id( ...

  9. make编译二

    GNU 的 make 很强大, 它可以自动推导文件以及文件依赖关系后面的命令,于是我们就没必要去在每一个[.o]文件后都写上类似的命令,因为,我们的 make 会自动识别,并自己推导命令 只要 mak ...

  10. docker快速构建oracle数据库

    1.查看可用镜像docker search oracle2.拉去想要的镜像docker pull wnameless/oracle-xe-11g3.基于wnameless/oracle-xe-11g创 ...