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

Created on 1 Feb 2018  ·  1Comment  ·  Source: Tencent/ncnn

/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之后虽然可以编译成功,但是最后运行结果不对。

Most helpful comment

最新的ncnn有所更改,可以参照这里的写法
https://github.com/Tencent/ncnn/blob/c6abc872df35efb3604d74c6f47784cbd3035a46/examples/squeezencnn/jni/squeezencnn_jni.cpp#L149
或者参照 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];
}

>All comments

最新的ncnn有所更改,可以参照这里的写法
https://github.com/Tencent/ncnn/blob/c6abc872df35efb3604d74c6f47784cbd3035a46/examples/squeezencnn/jni/squeezencnn_jni.cpp#L149
或者参照 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];
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

lovehuanhuan picture lovehuanhuan  ·  3Comments

makaaay picture makaaay  ·  4Comments

varbegin picture varbegin  ·  3Comments

chuan298 picture chuan298  ·  3Comments

nihui picture nihui  ·  5Comments