私はAndroid用の拡張現実感アプリで作業しています。私はTom Gibaraのcanny edge detector classを実装しており、AndroidでサポートされていないBufferedImageをBitmapに置き換えました。Android用のCannyエッジ検出 - 再帰関数のStackOverflow
"follow"(以下に掲載)メソッドが私にStackOverflowエラーを引き起こしています。それは再帰的な機能ですが、私にとっては、デバイス上でクラッシュする前に約10〜15秒間正しく動作するということは間違いありません。
Googleからは、このクラスがJavaで正常に実装されているようですが、何らかの理由でAndroid上で動作しないかどうかは疑問です。 Gibaraのコードでは、シングルスレッドの使用のみを指定しています。これは問題の一部になる可能性がありますか?そうでなければ、私の誤りは誰にも明らかですか?
ありがとうございました!
private void follow(int x1, int y1, int i1, int threshold) {
int x0 = x1 == 0 ? x1 : x1 - 1;
int x2 = x1 == width - 1 ? x1 : x1 + 1;
int y0 = y1 == 0 ? y1 : y1 - 1;
int y2 = y1 == height -1 ? y1 : y1 + 1;
data[i1] = magnitude[i1];
for (int x = x0; x <= x2; x++) {
for (int y = y0; y <= y2; y++) {
int i2 = x + y * width;
if ((y != y1 || x != x1) && data[i2] == 0
&& magnitude[i2] >= threshold) {
follow(x, y, i2, threshold);
return;
}
}
}
}
ありがとうございました!私は、Androidの携帯電話に適したスタックの深さを見つけるために掘り下げていきます。ソリューションに興味のある人は、このプロジェクトのAndroidソースをチェックしてください:http://www.jarkman.co.uk/catalog/robots/sketchy.htm 彼のfollow関数にこのコード行を追加しました。それが呼び出されるたびに深度変数を渡します。 if(深さ> mFlowStackDepth) \t \t \t return; – Allison