Visual SLAM(単眼カメラ)

11 Ansichten (letzte 30 Tage)
ST
ST am 12 Aug. 2020
Kommentiert: Kenta am 18 Aug. 2020
Visual SLAMについての知識はまださほどない状態です.
こちらのサイト(https://qiita.com/tohruk/items/43667dbd327c3d3a5b95)にORB-SLAMを用いて動画からカメラ軌跡と点群マップの推定を行うMATLABの例が紹介されており,ひとまず実行してみたのですがいくつかエラーが出てしまい,順に解決していったものの,下記の箇所が解決できずにいる状態です.
関数 'range' の呼び出し内に、不足している引数または正しくない引数データ型がないかを確認してください。
エラー: helperCheckLoopClosure (line 53)
range(loopKeyFrameIds(1:minNumCandidates)) <= maxRange
エラー: vs (line 316)
[isDetected, validLoopCandidates] = helperCheckLoopClosure(vSetKeyFrames, currKeyFrameId, ...
  3 Kommentare
ST
ST am 15 Aug. 2020
ご回答ありがとうございます.
Kentaさんが仰る通り,補助関数helpeerCheckLoopClosureでエラーを返しています.
補助関数helpeerCheckLoopClosureの中身とエラーの位置は以下の通りです.
エラーは少しわかりにくいのですが,下から7行目の箇所です.
こういった場合,補助関数の方に問題があるのでしょうか.
もしくは,掲載されていた方に修正が必要なのでしょうか.
一度に多くの質問をしてしまい,すみません.
function [isDetected, loopKeyFrameIds] = helperCheckLoopClosure(vSetKeyFrames, ...
currKeyframeId, imageDatabase, currImg, imageDatabaseViewIds)
%helperCheckLoopClosure detect loop candidates key frames by retrieving
% visually similar images from the feature database.
%
% This is an example helper function that is subject to change or removal
% in future releases.
% Copyright 2019 The MathWorks, Inc.
% Retrieve all the visually similar key frames
[candidateIds, similarityscores] = retrieveImages(currImg, imageDatabase);
% Compute similarity between the current key frame and its strongly-connected
% key frames. The minimum similarity score is used as a baseline to find
% loop candidate key frames, which are visually similar to but not connected
% to the current key frame
covisViews = connectedViews(vSetKeyFrames, currKeyframeId);
covisViewsIds = covisViews.ViewId;
isStrong = helperSelectStrongConnections(vSetKeyFrames.Connections, ...
covisViewsIds, currKeyframeId, 50);
strongCovisViewIds = covisViewsIds(isStrong);
[~, viewIds] = intersect(imageDatabaseViewIds, strongCovisViewIds, 'stable');
% Retrieve the top 10 similar connected key frames
[~,~,scores] = evaluateImageRetrieval(currImg, imageDatabase, viewIds, 'NumResults', 10);
minScore = min(scores);
% Convert from ImageID in ImageDatabase to ViewId in imageviewset
candidateViewIds = imageDatabaseViewIds(candidateIds);
[loopKeyFrameIds,ia] = setdiff(candidateViewIds, covisViewsIds, 'stable');
% Scores of non-connected key frames
candidateScores = similarityscores(ia); % Descending
if ~isempty(ia)
bestScore = candidateScores(1);
% Score must be higher than the 75% of the best score
isValid = candidateScores > max(bestScore*0.75, minScore);
loopKeyFrameIds = loopKeyFrameIds(isValid);
else
loopKeyFrameIds = [];
end
% Loop candidates need to be consecutively detected
minNumCandidates = 3; % At least 3 candidates are found
maxRange = 10;
if size(loopKeyFrameIds,1) >= minNumCandidates && ...
range(loopKeyFrameIds(1:minNumCandidates)) <= maxRange %%%%%%%この行でエラーが発生%%%%%%%
loopKeyFrameIds = loopKeyFrameIds(1:minNumCandidates);
isDetected = true;
else
isDetected = false;
end
end
Kenta
Kenta am 15 Aug. 2020
Bearbeitet: Kenta am 15 Aug. 2020
こんにちは、詳細を教えていただき、ありがとうございます。
「こういった場合,補助関数の方に問題があるのでしょうか.
もしくは,掲載されていた方に修正が必要なのでしょうか.」
とのことですが、掲載されてた方のバージョンや環境では正しく動いていて、そこでは正しくコーディングなどがされていたのだと思います。
ただ、この例は複雑なので、今はどこかで予期せぬエラーが起きているのだと思います。
こちらのドキュメントがお試しになっている例の公式なページと思うのですが、こちらをお試しになりましたか?もしかしたらこちらでやってみるとうまくいくかもしれません。

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Kenta
Kenta am 15 Aug. 2020
KOUさん、コメントのほうありがとうございます。
こちらにある質問文中のURLの記事の作者様のファイルをそのまま保存し、実行してみてください。
コメントのほうで私が「normalize関数が入っている気がするのでしょうが」と言ってしまったのですが、
range関数の間違いです、失礼しました。range関数のエラーはもしかしたらstatistics and machine learning toolboxが
入っていないからではないでしょうか?もしそれが入っておらず、かつ手軽にインストールできる状態であればアドオンから入れてみてください。もし、ない場合はnormalize関数などで書き換えることができます。
また、normalizeを使わずとも今回の用法であれば自分で書くこともできます。
ひとまず、statistics and machine learning toolboxが手軽に入手可能な環境にあれば、そちらで試していただけると幸いです。
  4 Kommentare
ST
ST am 17 Aug. 2020
何度もコメントいただきありがとうございます.
わからないことだらけで,一度に多くのことをお尋ねしてしまいすみません.
私の認識があっているのか不安なのですが,
range(loopKeyFrameIds(1:minNumCandidates)) <= maxRange
は、loopKeyFrameIds(1)とloopKeyFrameIds(minNumCandidates)の範囲(値の大きさの違い)ということで大丈夫でしょうか.
normalizeでの書き換えがわからなかったため
(loopKeyFrameIds(minNumCandidates)-loopKeyFrameIds(1)) <= maxRange
としてしまったのですが…
再ダウンロードの箇所ですが,書き換えた場合と再ダウンロードした場合での結果が異なっていました.
もう一度こちらの(https://qiita.com/tohruk/items/43667dbd327c3d3a5b95)ものをペーストして実行したところ,先ほどの結果よりもかなり良いものが出ました.
(とても近い結果にはなったのですが,同じにはなっておりません…)
こちらのサイトのものではrng(123)となっていますが,私はrng(114)で最も近い結果が出ました.
やはりバージョンや環境によるものなのでしょうか.
以下が現在のバージョンです.
MATLAB バージョン: 9.8.0.1417392 (R2020a) Update 4
オペレーティング システム: Mac OS X Version: 10.15.6 Build: 19G73
Java バージョン: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
Kenta
Kenta am 18 Aug. 2020
こんにちは、
range(loopKeyFrameIds(1:minNumCandidates)) <= maxRange
は、loopKeyFrameIds(1)とloopKeyFrameIds(minNumCandidates)の範囲(値の大きさの違い)ということで大丈夫でしょうか.」
少し違っていそうです。まずは、rangeの方法を調べてみてはいかがでしょう。おそらくこの部分がちがうため結果があわないのだと思います。まずは、簡単な値で、normalizeを使って、rangeと同様の正規化ができるように練習してみて、それができてからここに反映してはいかがでしょうか。

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu フィルター バンク finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!