异步变量和动态变量的类型不同

时间:2015-08-26 08:53:06

标签: java android opencv

我有一个名为grayVal的变量,它告诉我一个像素的灰度值,我的相机指向的是什么。当我移动相机时,显然这个数字会不断变化。我的问题是,当我在一个带有循环的异步中传递grayVal来测试grayVal传递阈值所需的时间时,无论我指向相机的是什么,数字都不会改变。有人告诉我,grayVal(在onCameraFrame中)和grayVal(在doInBackground中)并不是同一类型。我已将它们改为双打,但结果相同。

UI线程中的

volatile double [] grayVal;


@Override
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
    grayMat = inputFrame.gray();
    double [] grayPixel = grayMat.get(100,100);
    grayVal = grayPixel;
    Log.i("Mat Value", String.valueOf(grayVal[0]));
    return grayMat;
}

的AsyncTask

public class startTestAsync extends AsyncTask<Double, Void, Void> {       
int testAmount;
@Override
protected Void doInBackground(Double...grayVal) {
    for (testAmount = 0; testAmount < 5000; testAmount++) {
        Log.i("Mat Value Async", String.valueOf(grayVal[0]));
    }
    return null;
}
protected void onPostExecute(Long result) {
}
}

logcat的

08-26 04:51:21.873  19683-20612/bluemage.systems.displaylatencytester I/Mat Value Async﹕ 234.0
08-26 04:51:21.873  19683-20612/bluemage.systems.displaylatencytester I/Mat Value Async﹕ 234.0
08-26 04:51:21.873  19683-20379/bluemage.systems.displaylatencytester I/Mat Value﹕ 25.0
08-26 04:51:21.873  19683-20612/bluemage.systems.displaylatencytester I/Mat Value Async﹕ 234.0
08-26 04:51:21.873  19683-20612/bluemage.systems.displaylatencytester I/Mat Value Async﹕ 234.0

0 个答案:

没有答案