【发布时间】:2018-04-12 16:15:25
【问题描述】:
Logcat 只出现在MainActivity 的onCreate 方法内部。我试图在一个类中使用Log (TAG, "msg");,但没有出现日志。为什么?在MainActivity:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.v("Test", "test");
}
有效!
但是这个类不起作用:
public class Imgpixel {
private static final String TAG = "Quicknotes";
public Imgpixel() {
}
String src="C:\\path_of_image\\img.jpg";
Mat imgRead = Imgcodecs.imread(src, IMREAD_COLOR);
int lin = imgRead.rows(); //get the number of rows
int col = imgRead.cols(); //get the number of cols
List<double[]> pixels=new ArrayList<>();//arraylist to save array rgb below
public void cor() {
for (int i = 0; i < lin; i++) {
for (int j = 0; j < col; j++) {
double [] rgb = imgRead.get(i, j);
pixels.add(0, rgb);
}
}
}
}
【问题讨论】:
-
"但在另一个班级不工作"请张贴minimal reproducible example。
-
能确认方法执行了吗?尝试在有问题的行上放置一个断点。
-
我编辑了上面的代码。
-
能否贴出负责调用“cor()”方法的代码?
-
另外,
Log.v("TAG", "test")会在 logcat 中为您提供“TAG”,而不是我希望您真正想要的“Quicknotes”。
标签: java android logcat android-studio-3.0