【问题标题】:accessing mat pixels in native在本机中访问 mat 像素
【发布时间】:2012-11-01 18:32:37
【问题描述】:

我正在尝试以原生方式访问和修改 mat 像素,但我无法摆脱错误。 我的功能是:

`extern "C" {
JNIEXPORT void JNICALL Java_org_opencv_samples_tutorial3_Sample3Native_FindFeatures(JNIEnv*, jobject, jlong addrGray, jlong addrRgba)
{
    Mat* pMatGr=(Mat*)addrGray;
    Mat* pMatRgb=(Mat*)addrRgba;
    vector<KeyPoint> v;
int i=0;

uchar* pixel = addrRgba.data;
for(int i = 0; i < Mat.rows * Mat.cols; ++i)
{
    // access pixel[0],pixel[1],pixel[2] here
    pixel += 3; // move to next pixel
}

}

}
`    

它被调用:

FindFeatures(mGrayMat.getNativeObjAddr(), mRgba.getNativeObjAddr());

来自java

我的错误是

"field 'data' cannot be resolved", "field 'rows' cannot be resolved"

帮助将不胜感激。 谢谢

【问题讨论】:

    标签: android c++ opencv android-ndk native


    【解决方案1】:

    Mat.rows 应该是pMatGr-&gt;rowsMat.cols 应该是pMatGr-&gt;colsaddrRgba.data 应该是pMatRgb-&gt;data

    【讨论】:

    • 好吧,我不会对此做出任何承诺。
    • 不需要保证,它与你写的更正一起工作,当然 pMatGr 应该是 pMatRgb。
    猜你喜欢
    • 2014-06-15
    • 1970-01-01
    • 2011-11-03
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    • 2016-01-07
    • 1970-01-01
    相关资源
    最近更新 更多