Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std::vector<KeyPoint>の参照渡し問題 #118

Closed
yukoba opened this issue Aug 19, 2015 · 2 comments
Closed

std::vector<KeyPoint>の参照渡し問題 #118

yukoba opened this issue Aug 19, 2015 · 2 comments
Labels

Comments

@yukoba
Copy link
Contributor

yukoba commented Aug 19, 2015

すいません、話がややこしいので、日本語で失礼します。

現状 3.0 ブランチ の 2D feature がバグってます。
cv::Feature2D::compute() は std::vector &keypoints で渡すのですが、
このvectorを参照渡しで渡す所が大事です。

現状の 3.0 ブランチ、キーポイント数が少ない時は正常に動作するのですが、
多い時に、参照渡しをしてないことが問題となって、メモリが破壊されます。

https://github.com/shimat/opencvsharp/blob/3.0/src/OpenCvSharp/modules/features2d/Feature2D.cs#L106
var keypoints = new VectorOfKeyPoint(10000);
のように、あらかじめ大きな数字を入れておくと正常に動作します。

少し格闘してみたのですが、解決策が良く分からなく、
vector の参照渡し、どのように解決すれば良いのでしょうか?

@shimat shimat added the problem label Aug 19, 2015
@shimat
Copy link
Owner

shimat commented Aug 19, 2015

今のFeature2D実装でDetectComputeを取り違えているというか変になっている感じでして、どのようなコードでそれが再現するのか確認させて頂けますか。

Detect -> Computeの流れで使うらしいので、ついさっきpushした版で動くコードですが、このように使ったということでよろしいでしょうか。

Mat img = new Mat("hoge.png", LoadMode.GrayScale);
KAZE kaze = KAZE.Create();

KeyPoint[] keyPoints = kaze.Detect(img);

Mat descriptors = new Mat();
kaze.Compute(img, ref keyPoints, descriptors);

@yukoba
Copy link
Contributor Author

yukoba commented Aug 19, 2015

ごめんなさい!!

僕が Visual Studio 2015 でビルドしていて、元々の shimat さんのが Visual Studio 2013 でビルドしていて、その2つが混在すると、std::vector がおかしくなるという不具合でした。僕の勘違いでした。Visual Studio 2013 も入れておかないと駄目ですね。お騒がせしました。

残りの特徴点もラッパー実装して頂いて、ありがとうございます。

@yukoba yukoba closed this as completed Aug 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants