- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Android 和 OpenCV 的新手。一直在尝试实现新书《Mastering OpenCV with Practical Computer Vision Projects》中的代码。该应用程序基本上使用 OpenCV 在相机预览上渲染卡通化图像。您可以触摸屏幕保存卡通化图像。
作者的源代码位于 here .
我对 CartoonifierApp.java 文件做了一个小修改(见下文),以便我可以使用 OpenCV Manager 静态加载卡通化器库。应用程序(原始代码引发了 UnsatisfiedLinkError)。
我面临的问题是,当我将应用程序加载到我的 Galaxy Nexus (Android 4.1.1) 上时,我得到一个空白的黑屏。我的 LogCat 说:
E/BufferQueue(4744): [unnamed-4744-0] setBufferCount: SurfaceTexture has been abandoned! E/Cartoonifier::SurfaceView(4744): startPreview() failed
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
mCamera.setPreviewTexture( new SurfaceTexture(10) );
else
mCamera.setPreviewDisplay(null);
mCamera.setPreviewDisplay(mHolder);
12-22 15:33:07.966: I/CartoonifierApp(5999): Instantiated new class com.Cartoonifier.CartoonifierApp 12-22 15:33:07.966: I/CartoonifierApp(5999): called onCreate 12-22 15:33:07.966: I/CartoonifierApp(5999): Trying to load OpenCV library 12-22 15:33:07.982: I/Cartoonifier::SurfaceView(5999): Instantiated new class com.Cartoonifier.CartoonifierView 12-22 15:33:07.990: I/CartoonifierApp(5999): onResume 12-22 15:33:07.990: I/Cartoonifier::SurfaceView(5999): openCamera 12-22 15:33:07.990: I/Cartoonifier::SurfaceView(5999): releaseCamera 12-22 15:33:08.099: D/OpenCVManager/Helper(5999): Service connection created 12-22 15:33:08.099: D/OpenCVManager/Helper(5999): Trying to get library path 12-22 15:33:08.138: D/OpenCVManager/Helper(5999): Trying to get library list 12-22 15:33:08.169: D/OpenCVManager/Helper(5999): Library list: "" 12-22 15:33:08.169: D/OpenCVManager/Helper(5999): First attempt to load libs 12-22 15:33:08.169: D/OpenCVManager/Helper(5999): Trying to init OpenCV libs 12-22 15:33:08.169: D/OpenCVManager/Helper(5999): Trying to load library /data/data/org.opencv.engine/lib/libopencv_java.so 12-22 15:33:08.169:
D/dalvikvm(5999): Trying to load lib /data/data/org.opencv.engine/lib/libopencv_java.so 0x41936a40 12-22
15:33:08.193: D/dalvikvm(5999): Added shared lib /data/data/org.opencv.engine/lib/libopencv_java.so 0x41936a40 12-22
15:33:08.193: D/OpenCVManager/Helper(5999): OpenCV libs init was ok!
12-22 15:33:08.193: D/OpenCVManager/Helper(5999): First attempt to load libs is OK 12-22 15:33:08.193: D/OpenCVManager/Helper(5999): Init finished with status 0 12-22 15:33:08.193: D/OpenCVManager/Helper(5999): Unbind from service 12-22 15:33:08.200: D/OpenCVManager/Helper(5999): Calling using callback 12-22 15:33:08.200: I/CartoonifierApp(5999): OpenCV loaded successfully
12-22 15:33:08.200: D/dalvikvm(5999): Trying to load lib /data/data/com.Cartoonifier/lib/libcartoonifier.so 0x41936a40 12-22
15:33:08.200: D/dalvikvm(5999): Added shared lib /data/data/com.Cartoonifier/lib/libcartoonifier.so 0x41936a40 12-22
15:33:08.200: D/dalvikvm(5999): No JNI_OnLoad found in /data/data/com.Cartoonifier/lib/libcartoonifier.so 0x41936a40, skipping init 12-22 15:33:08.200: D/OpenCVManager/Helper(5999): Service connection created 12-22 15:33:08.200: D/OpenCVManager/Helper(5999): Trying to get library path 12-22
15:33:08.232: D/OpenCVManager/Helper(5999): Trying to get library list 12-22 15:33:08.271: D/OpenCVManager/Helper(5999): Library list: ""
12-22 15:33:08.271: D/OpenCVManager/Helper(5999): First attempt to load libs 12-22 15:33:08.271: D/OpenCVManager/Helper(5999): Trying to
init OpenCV libs 12-22 15:33:08.271: D/OpenCVManager/Helper(5999): Trying to load library /data/data/org.opencv.engine/lib/libopencv_java.so 12-22 15:33:08.271: D/dalvikvm(5999): Trying to load lib /data/data/org.opencv.engine/lib/libopencv_java.so 0x41936a40 12-22
15:33:08.271: D/dalvikvm(5999): Shared lib '/data/data/org.opencv.engine/lib/libopencv_java.so' already loaded in same CL 0x41936a40 12-22 15:33:08.271: D/OpenCVManager/Helper(5999): OpenCV libs init was ok! 12-22 15:33:08.271: D/OpenCVManager/Helper(5999): First attempt to load libs is OK
12-22 15:33:08.271: D/OpenCVManager/Helper(5999): Init finished with status 0 12-22 15:33:08.271: D/OpenCVManager/Helper(5999): Unbind from service 12-22 15:33:08.271: D/OpenCVManager/Helper(5999): Calling using callback 12-22 15:33:08.271: I/CartoonifierApp(5999): OpenCV loaded successfully 12-22 15:33:08.279: D/dalvikvm(5999): Trying to load lib /data/data/com.Cartoonifier/lib/libcartoonifier.so 0x41936a40 12-22 15:33:08.279: D/dalvikvm(5999): Shared lib '/data/data/com.Cartoonifier/lib/libcartoonifier.so' already loaded in same CL 0x41936a40 12-22 15:33:08.302: I/Cartoonifier::SurfaceView(5999): surfaceCreated 12-22 15:33:08.302: I/Cartoonifier::SurfaceView(5999): surfaceChanged(). Window size: 1196x670 12-22 15:33:08.302: I/Cartoonifier::SurfaceView(5999): setupCamera(1196x670) 12-22 15:33:08.302: I/Cartoonifier::SurfaceView(5999): Starting processing thread 12-22 15:33:08.310: I/Cartoonifier::SurfaceView(5999): Found Camera Resolution 1920x1080 12-22 15:33:08.310: I/Cartoonifier::SurfaceView(5999): Found Camera Resolution 1280x720 12-22 15:33:08.310: I/Cartoonifier::SurfaceView(5999): Found Camera Resolution 960x720 12-22 15:33:08.310: I/Cartoonifier::SurfaceView(5999): Found Camera Resolution 800x480 12-22 15:33:08.310: I/Cartoonifier::SurfaceView(5999): Found Camera Resolution 720x576 12-22 15:33:08.310: I/Cartoonifier::SurfaceView(5999): Found Camera Resolution 720x480 12-22 15:33:08.310: I/Cartoonifier::SurfaceView(5999): Found Camera Resolution 768x576 12-22 15:33:08.310: I/Cartoonifier::SurfaceView(5999): Found Camera Resolution 640x480 12-22 15:33:08.310: I/Cartoonifier::SurfaceView(5999): Found Camera Resolution 320x240 12-22 15:33:08.310: I/Cartoonifier::SurfaceView(5999): Found Camera Resolution 352x288 12-22 15:33:08.310: I/Cartoonifier::SurfaceView(5999): Found Camera Resolution 240x160 12-22 15:33:08.310: I/Cartoonifier::SurfaceView(5999): Found Camera Resolution 176x144 12-22 15:33:08.310: I/Cartoonifier::SurfaceView(5999): Found Camera Resolution 128x96 12-22 15:33:08.318: I/Cartoonifier::SurfaceView(5999): Chosen Camera Preview Size: 1280x720 12-22 15:33:08.333: D/dalvikvm(5999): GC_FOR_ALLOC freed 131K, 2% free 10807K/11011K, paused 13ms, total 13ms
12-22 15:33:08.333: I/dalvikvm-heap(5999): Grow heap (frag case) to 11.902MB for 1382416-byte allocation
12-22 15:33:08.357: D/dalvikvm(5999): GC_CONCURRENT freed 1K, 3% free 12156K/12423K, paused 12ms+1ms, total 24ms
12-22 15:33:08.357: D/dalvikvm(5999): WAIT_FOR_CONCURRENT_GC blocked 11ms
12-22 15:33:08.365: D/dalvikvm(5999): GC_FOR_ALLOC freed 0K, 3% free 12156K/12423K, paused 9ms, total 9ms
12-22 15:33:08.372: I/dalvikvm-heap(5999): Grow heap (frag case) to 13.219MB for 1382416-byte allocation
12-22 15:33:08.388: D/dalvikvm(5999): GC_CONCURRENT freed 0K, 3% free 13506K/13831K, paused 11ms+1ms, total 21ms
12-22 15:33:08.388: D/dalvikvm(5999): WAIT_FOR_CONCURRENT_GC blocked 7ms
12-22 15:33:08.404: D/dalvikvm(5999): GC_FOR_ALLOC freed <1K, 3% free 13506K/13831K, paused 9ms, total 10ms
12-22 15:33:08.411: I/dalvikvm-heap(5999): Grow heap (frag case) to 16.735MB for 3686416-byte allocation
12-22 15:33:08.427: D/dalvikvm(5999): GC_CONCURRENT freed <1K, 3% free 17106K/17479K, paused 12ms+1ms, total 22ms
12-22 15:33:08.427: D/dalvikvm(5999): WAIT_FOR_CONCURRENT_GC blocked 10ms
12-22 15:33:08.443: D/dalvikvm(5999): GC_FOR_ALLOC freed <1K, 3% free 17106K/17479K, paused 10ms, total 10ms
12-22 15:33:08.450: I/dalvikvm-heap(5999): Grow heap (frag case) to 20.250MB for 3686416-byte allocation
12-22 15:33:08.466: D/dalvikvm(5999): GC_CONCURRENT freed 0K, 2% free 20706K/21127K, paused 12ms+2ms, total 22ms
12-22 15:33:08.466: D/dalvikvm(5999): WAIT_FOR_CONCURRENT_GC blocked 5ms
12-22 15:33:08.466: I/Cartoonifier::SurfaceView(5999): start preview
12-22 15:33:08.497: E/BufferQueue(5999): [unnamed-5999-0] setBufferCount: SurfaceTexture has been abandoned!
12-22 15:33:08.505: E/Cartoonifier::SurfaceView(5999): mCamera.startPreview() failed
private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
@Override
public void onManagerConnected(int status) {
switch (status) {
case LoaderCallbackInterface.SUCCESS:
{
Log.i(TAG, "OpenCV loaded successfully");
// Load native library after(!) OpenCV initialization
System.loadLibrary("cartoonifier");
} break;
default:
{
super.onManagerConnected(status);
} break;
}
}
};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
Log.i(TAG, "called onCreate");
super.onCreate(savedInstanceState);
Log.i(TAG, "Trying to load OpenCV library");
if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback))
{
Log.e(TAG, "Cannot connect to OpenCV Manager");
}
requestWindowFeature(Window.FEATURE_NO_TITLE);
mView = new CartoonifierView(this);
setContentView(mView);
// Call our "onTouch()" callback function whenever the user touches the screen.
mView.setOnTouchListener(this);
}
@Override
protected void onPause() {
Log.i(TAG, "onPause");
super.onPause();
mView.releaseCamera();
}
@Override
public void onResume()
{
super.onResume();
Log.i(TAG, "onResume");
if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback))
{
Log.e(TAG, "Cannot connect to OpenCV Manager");
}
if( !mView.openCamera() ) {
AlertDialog ad = new AlertDialog.Builder(this).create();
ad.setCancelable(false); // This blocks the 'BACK' button
ad.setMessage("Fatal error: can't open camera!");
/*ad.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
finish();
}
}); */
ad.show();
}
}
最佳答案
前段时间在 OpenCV 中解决了这个问题。
不确定是应用程序还是操作系统错误。问题是调用 Bitmap.createBitmap
分离 SurfaceTexture
用于可视化的对象。
解决方法是修改 setupCamera基础方法View
上课和改变
try {
setPreview();
} catch (IOException e) {
Log.e(TAG, "mCamera.setPreviewDisplay/setPreviewTexture fails: " + e);
}
/* Notify that the preview is about to be started and deliver preview size */
onPreviewStarted(params.getPreviewSize().width, params.getPreviewSize().height);
/* Notify that the preview is about to be started and deliver preview size */
onPreviewStarted(params.getPreviewSize().width, params.getPreviewSize().height);
try {
setPreview();
} catch (IOException e) {
Log.e(TAG, "mCamera.setPreviewDisplay/setPreviewTexture fails: " + e);
}
关于android - OpenCV/Android BufferQueue 错误 : Surface Texture Has Been Abandoned,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14006337/
我最近在/ drawable中添加了一些.gifs,以便可以将它们与按钮一起使用。这个工作正常(没有错误)。现在,当我重建/运行我的应用程序时,出现以下错误: Error: Gradle: Execu
Android 中有返回内部存储数据路径的方法吗? 我有 2 部 Android 智能手机(Samsung s2 和 s7 edge),我在其中安装了一个应用程序。我想使用位于这条路径中的 sqlit
这个问题在这里已经有了答案: What's the difference between "?android:" and "@android:" in an android layout xml f
我只想知道 android 开发手机、android 普通手机和 android root 手机之间的实际区别。 我们不能从实体店或除 android marketplace 以外的其他地方购买开发手
自Gradle更新以来,我正在努力使这个项目达到标准。这是一个团队项目,它使用的是android-apt插件。我已经进行了必要的语法更改(编译->实现和apt->注释处理器),但是编译器仍在告诉我存在
我是android和kotlin的新手,所以请原谅要解决的一个非常简单的问题! 我已经使用导航体系结构组件创建了一个基本应用程序,使用了底部的导航栏和三个导航选项。每个导航选项都指向一个专用片段,该片
我目前正在使用 Facebook official SDK for Android . 我现在正在使用高级示例应用程序,但我不知道如何让它获取应用程序墙/流/状态而不是登录的用户。 这可能吗?在那种情
我在下载文件时遇到问题, 我可以在模拟器中下载文件,但无法在手机上使用。我已经定义了上网和写入 SD 卡的权限。 我在服务器上有一个 doc 文件,如果用户单击下载。它下载文件。这在模拟器中工作正常但
这个问题在这里已经有了答案: What is the difference between gravity and layout_gravity in Android? (22 个答案) 关闭 9
任何人都可以告诉我什么是 android 缓存和应用程序缓存,因为当我们谈论缓存清理应用程序时,它的作用是,缓存清理概念是清理应用程序缓存还是像内存管理一样主存储、RAM、缓存是不同的并且据我所知,缓
假设应用程序 Foo 和 Eggs 在同一台 Android 设备上。任一应用程序都可以获取设备上所有应用程序的列表。一个应用程序是否有可能知道另一个应用程序是否已经运行以及运行了多长时间? 最佳答案
我有点困惑,我只看到了从 android 到 pc 或者从 android 到 pc 的例子。我需要制作一个从两部手机 (android) 连接的 android 应用程序进行视频聊天。我在想,我知道
用于使用 Android 以编程方式锁定屏幕。我从 Stackoverflow 之前关于此的问题中得到了一些好主意,并且我做得很好,但是当我运行该代码时,没有异常和错误。而且,屏幕没有锁定。请在这段代
文档说: android:layout_alignParentStart If true, makes the start edge of this view match the start edge
我不知道这两个属性和高度之间的区别。 以一个TextView为例,如果我将它的layout_width设置为wrap_content,并将它的width设置为50 dip,会发生什么情况? 最佳答案
这两个属性有什么关系?如果我有 android:noHistory="true",那么有 android:finishOnTaskLaunch="true" 有什么意义吗? 最佳答案 假设您的应用中有
我是新手,正在尝试理解以下 XML 代码: 查看 developer.android.com 上的文档,它说“starStyle”是 R.attr 中的常量, public static final
在下面的代码中,为什么当我设置时单选按钮的外观会发生变化 android:layout_width="fill_parent" 和 android:width="fill_parent" 我说的是
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 9
假设我有一个函数 fun myFunction(name:String, email:String){},当我调用这个函数时 myFunction('Ali', 'ali@test.com ') 如何
我是一名优秀的程序员,十分优秀!