虹软人脸识别,其方法要传NV21格式的byte[], github上有一个虹软的Demo,是不是虹软工作人员写的不清楚,这个Demo里bitmap转NV21格式byte[]用的是一个第三方库https://github.com/gqjjqg/android-extend,
用法如下:

ImageConverter convert = new ImageConverter();
convert.initial(mBitmap.getWidth(), mBitmap.getHeight(), ImageConverter.CP_PAF_NV21);
if (convert.convert(mBitmap, data)) {
Log.d(TAG, "convert ok!");
}
convert.destroy();

  

本来是没有问题,但是我这边需求是大量检测照片,所以会频繁多次调用这个方法,以900次为例,在某些平板上是没有问题的,但是个别平板在100次左右时会报错:

07-18 21:44:53.719 6365-6609/cn.gxh.face A/libc: invalid address or address of corrupt block 0xb80402f8 passed to dlfree
Fatal signal 11 (SIGSEGV), code 1, fault addr 0xdeadbaad in tid 6609 (pool-2-thread-2)
07-18 21:44:53.820 175-175/? E/DEBUG: Failed to find a valid tombstone, default to using tombstone 0.
failed to open tombstone file '/data/tombstones/tombstone_00': No such file or directory

  

解决方法:可以换一个转换方法。

public byte[] getNV21(int inputWidth, int inputHeight, Bitmap scaled) {

int[] argb = new int[inputWidth * inputHeight];

scaled.getPixels(argb, 0, inputWidth, 0, 0, inputWidth, inputHeight);
byte[] yuv = new byte[inputWidth * inputHeight * 3 / 2]; encodeYUV420SP(yuv, argb, inputWidth, inputHeight); return yuv;
} private void encodeYUV420SP(byte[] yuv420sp, int[] argb, int width, int height) {
int frameSize = width * height; int yIndex = 0;
int uvIndex = frameSize; int R, G, B, Y, U, V;
int index = 0; for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
R = (argb[index] & 0xff0000) >> 16;
G = (argb[index] & 0xff00) >> 8;
B = (argb[index] & 0xff); // well known RGB to YUV algorithm
Y = ((66 * R + 129 * G + 25 * B + 128) >> 8) + 16;
U = ((-38 * R - 74 * G + 112 * B + 128) >> 8) + 128;
V = ((112 * R - 94 * G - 18 * B + 128) >> 8) + 128; yuv420sp[yIndex++] = (byte) ((Y < 0) ? 0 : ((Y > 255) ? 255 : Y)); if (j % 2 == 0 && index % 2 == 0 && uvIndex < yuv420sp.length - 2) {
yuv420sp[uvIndex++] = (byte) ((V < 0) ? 0 : ((V > 255) ? 255 : V));
yuv420sp[uvIndex++] = (byte) ((U < 0) ? 0 : ((U > 255) ? 255 : U));
}
index++;
}
}
}

  

经测试,可用。

ImageConverter引起的 invalid address or address of corrupt block 0xb7feab58 passed to dlfree的更多相关文章

  1. iOS crash log 解析 symbol address = stack address - slide 运行时获取slide的api 利用dwarfdump从dsym文件中得到symbol

    概述: 为什么 crash log 内 Exception Backtrace 部分的地址(stack address)不能从 dsym 文件中查出对应的代码? 因为 ASLR(Address spa ...

  2. disabling IPv6 name/address support: Address family not supported by protocol

    禁用IPv6 后影响邮件发送设置 vim /etc/postfix/main.cf # Enable IPv4, and IPv6 if supported inet_protocols = all

  3. 基本c功能使用不当导致崩溃

    一些基本的c语言操作,使用不当也会有出其不意的问题.比如我最近的一个项目中,用到几句代码: uint8_t * out_pcm = NULL; ....... if (NULL == out_pcm) ...

  4. Lua的文件操作

    先简单介绍一下被迫使用Lua的IO的情境: 游戏支持玩家自定义上传头像,在排行榜中会显示玩家列表(包括本服.跨服),原有的做法是先检测CCUserDefault中是否存在指定图片的key以及它的状态. ...

  5. Android Tombstone 分析

    1.什么是tombstone 当一个动态库(native 程序)开始执行时,系统会注册一些连接到 debuggerd 的 signal handlers,当系统 crash 的时候,会保存一个 tom ...

  6. Virtual address cache memory, processor and multiprocessor

    An embodiment provides a virtual address cache memory including: a TLB virtual page memory configure ...

  7. Method of address space layout randomization for windows operating systems

    A system and method for address space layout randomization ("ASLR") for a Windows operatin ...

  8. Linux高级调试与优化——Address Sanitizer

    Address Sanitizer ASAN最早可以追溯到 LLVM 的 sanitizers项目(https://github.com/google/sanitizers),这个项目包含了Addre ...

  9. 用 eric6 与 PyQt5 实现python的极速GUI编程(系列04)---- PyQt5自带教程:地址簿(address book)

    [引子] 在PyQt5自带教程中,地址簿(address book)程序没有完全实现界面与业务逻辑分离. 本文我打算用eric6+PyQt5对其进行改写,以实现界面与逻辑完全分离. [概览] 1.界面 ...

随机推荐

  1. Oracle数据库的入门之一

    Oracle的介绍: Oracle Database,又名Oracle RDBMS,或简称Oracle.是甲骨文公司的一款关系数据库管理系统.它是在数据库领域一直处于领先地位的产品.可以说Oracle ...

  2. scrapy 去重 dont_filter=False

    yield Request(...... dont_filter=False)

  3. Centos部署flask项目

    必备: Python2.7(ok) MySQL(ok) git supervisor virtualenv Gunicorn 阿里云服务器(最便宜的就好) 域名(国内万网,国外goDaddy) 我的P ...

  4. MVC HTML页面使用

    解决HTML <system.webServer> <validation validateIntegratedModeConfiguration="false" ...

  5. 使用SSH框架遇到的错误总结

    1.org.hibernate.exception.ConstraintViolationException: could not insert: 如果是主键是自增序列,映射文件 指定主键生成器< ...

  6. vue学习【第三篇】:vue之node.js的简单介绍

    什么是node.js 它是可以运行JavaScript的服务平台,可以吧它当做一门后端程序,只是它的开发语言是JavaScript 安装node.js node.js的特性 - 非阻塞IO模型 - 时 ...

  7. Vistual Studio Code配置

    目录 查看版本,帮助: 修改vscode的扩展目录: 用户和工作区设置 用户设置的文件保存在如下目录: 所以有三种方式更改默认的设置: vscode同步配置: vscode启动launch.json配 ...

  8. 【做题】atc_cf17-final_E - Combination Lock——巧妙转化及图论

    题意:给出一个由26个小写字母组成的字符串,可以任意地进行若干个操作,每次操作是让指定区间内的字母变为下一个字母(z变成a).问是否存在方案使得这个字符串变为回文串. 一开始的想法是构造len/2条模 ...

  9. P3121 [USACO15FEB]审查(黄金)Censoring (Gold)

    吐槽 数据太水了吧,我AC自动机的trie建错了结果只是RE了两个点,还以为数组开小了改了好久 思路 看到多模板串,字符串匹配,且模板串总长度不长,就想到AC自动机 然后用栈维护当前的字符串位置,如果 ...

  10. P5057 [CQOI2006]简单题(线段树)

    果然简单题,5分钟紫题++ 代码 #include <cstdio> #include <algorithm> #include <cstring> using n ...