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

为什么我拿ncnn编译出来的.a文件编译so的时候会报类型转换错误? #256

Closed
h3clikejava opened this issue Feb 1, 2018 · 1 comment

Comments

@h3clikejava
Copy link

/Users/XXX/Downloads/squeezencnn-AH/app/src/main/jni/squeezencnn_jni.cpp:149:42: error: invalid conversion from 'void*' to 'const float*' [-fpermissive]
const float* prob = out.data + out.cstep * j;
^

这里的out.data是void类型 ,如果强行转换为float之后虽然可以编译成功,但是最后运行结果不对。

@nihui
Copy link
Member

nihui commented Feb 1, 2018

最新的ncnn有所更改,可以参照这里的写法

const float* prob = out.channel(j);

或者参照 wiki 上的使用指北

ncnn::Mat out_flatterned = out.reshape(out.w * out.h * out.c);
std::vector<float> scores;
scores.resize(out_flatterned.w);
for (int j=0; j<out_flatterned.w; j++)
{
    scores[j] = out_flatterned[j];
}

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