Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.ArrayIndexOutOfBoundsException: 128 #6

Open
nettyxiong opened this issue Apr 18, 2015 · 6 comments
Open

java.lang.ArrayIndexOutOfBoundsException: 128 #6

nettyxiong opened this issue Apr 18, 2015 · 6 comments

Comments

@nettyxiong
Copy link

有的图片会报数组越界错误,请问应该如何处理这种异常?!
image

@nettyxiong
Copy link
Author

frame9248

@nettyxiong
Copy link
Author

这个就是报异常的图片,希望能给出测试解决方案

@axmanwang
Copy link
Member

非常抱歉,目前没有任何能处理所有图片格式,包括adobe photoshopbn 也存在打不开的图片,但换一种工具就能浏览,我们能做的只是改最大
努力去解析图片。但是万一解析不了,可以在捕获异常中换一种方式转换图片再试试。

在 2015年4月18日,下午4:42,sixiong notifications@github.com 写道:

这个就是报异常的图片,希望能给出测试解决方案


Reply to this email directly or view it on GitHub #6 (comment).

@nettyxiong
Copy link
Author

您提到的换一种方式转换图片指的是?
image
这个代码换一种方式进行转化吗

@axmanwang
Copy link
Member

你好,这个问题已经查明是一个float精度丢失造成的bug。

if (idxDir < 0.0) {
idxDir += directionCount;
}

directionCount = 8(int)
idxDir 是float.
结果是 idxDir 很小的负数是,idxDir < 0.0成立,但是 idxDir += 8;还是8.0,现在修改成double,问题已经解决。
原来的实现是都是用double,精度很高,准确性也很高,但是计算时太占用内存,我折中一下,将大多数的double优化成float,可以节省一半的内存空间。
但是优化后这里精度就丢失了,出现了bug。

建议如果不在意内存,将实现中所有float替换成double,这样精度高,识别准确率也很高。

在 2015年4月20日,上午9:17,axman iamaxman@hotmail.com 写道:

将BuffreadImg img转换成为其它格式,比如从jpg另存为png再重新读出来试试。

在 2015年4月19日,下午8:50,sixiong <notifications@github.com mailto:notifications@github.com> 写道:

您提到的换一种方式转换图片指的是?
https://cloud.githubusercontent.com/assets/8112710/7219488/b8563690-e6d5-11e4-807c-35c68da2d982.png
这个代码换一种方式进行转化吗


Reply to this email directly or view it on GitHub #6 (comment).

@nettyxiong
Copy link
Author

好的,谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants