FAsT-Match
FAsT-Match copied to clipboard
negative index in padded image?
Hi,
I've been trying to use your code on Windows 10 (vc++12, OpenCV 2.4.9).
I'm able to compile correctly but am facing some issues when running the code.
More precisely, when I'm in the function FAsTMatch::evaluateConfigs,
when the score is computed as
score += abs(vals_i1[j] - padded.at
I also have faced problem about score += abs(vals_i1[j] - padded.at(target_y - 1, target_x - 1) ); I have negative values for target_x - 1, so the program crashes. I don't have good idea to solve it.
In addition, WITHIN(affine_corners.atcv::Point2f(0) like this , it doesn't work.
Hi I actually was able to solve the issue and it seems to work: in the current code, the image is only padded horizontally (black stripes on the top and bottom). I solved the issue by padding it vertically too. In FastMatch.cpp, I replaced the original padding by: /* Use a padded image, to avoid boundary checking */ Mat padded( image.rows * 3, image.cols + 100 , image.type(), Scalar(0.0) ); image.copyTo( Mat(padded, Rect(50, image.rows, image.cols, image.rows)) ); I also modified tmp1 definitions to take into account the new padding; double tmp_1 = (r2x + 1) + a13 + 0.5 + 50; It seems to work for me (I did this quickly so I hope I made the correct changes everywhere, but at least the program doesn't crash and it seems to find the templates where they should be).
For WITHIN(affine_corners...) I modified the code in such way in configsToAffine():
cv::Point2f point0, point1, point2, point3;
point0.x = affine_corners.at
if (WITHIN(point0, top_left, bottom_right) && WITHIN(point1, top_left, bottom_right) && WITHIN(point2, top_left, bottom_right) && WITHIN(point3, top_left, bottom_right)) {
affines[i] = affine;
insiders[i] = true;
}
Hi I actually was able to solve the issue and it seems to work: in the current code, the image is only padded horizontally (black stripes on the top and bottom). I solved the issue by padding it vertically too. In FastMatch.cpp, I replaced the original padding by: /* Use a padded image, to avoid boundary checking */ Mat padded( image.rows * 3, image.cols + 100 , image.type(), Scalar(0.0) ); image.copyTo( Mat(padded, Rect(50, image.rows, image.cols, image.rows)) ); I also modified tmp1 definitions to take into account the new padding; double tmp_1 = (r2x + 1) + a13 + 0.5 + 50; It seems to work for me (I did this quickly so I hope I made the correct changes everywhere, but at least the program doesn't crash and it seems to find the templates where they should be).
Hello, thank you for your answer, it really can run, but the speed is not particularly satisfactory, I am on the window10 i7 6 core 12 thread GTX1060 computer, it needs more time than matlab
For WITHIN(affine_corners...) I modified the code in such way in configsToAffine():
cv::Point2f point0, point1, point2, point3; point0.x = affine_corners.at(0, 0); point0.y = affine_corners.at(0, 1); point1.x = affine_corners.at(1, 0); point1.y = affine_corners.at(1, 1); point2.x = affine_corners.at(2, 0); point2.y = affine_corners.at(2, 1); point3.x = affine_corners.at(3, 0); point3.y = affine_corners.at(3, 1);
if (WITHIN(point0, top_left, bottom_right) && WITHIN(point1, top_left, bottom_right) && WITHIN(point2, top_left, bottom_right) && WITHIN(point3, top_left, bottom_right)) {
affines[i] = affine; insiders[i] = true;
}
Excuse me, after you configure it, use the author's picture, how long does it run in Release?
Hi there, I didn't look at computation time as I Just wanted to test the algorithm but indeed it took long minutes for one image (maybe 15-20?) on a somewhat powerful laptop so I was a bit disapointed about thé 'fast' title... Might be a question of parameters space tuning though, Hope it helps and I'm interested if you find à solution. Best, Sandrine
----- Mail d'origine ----- De: yangninghua [email protected] À: subokita/FAsT-Match [email protected] Cc: svoros [email protected], Author [email protected] Envoyé: Fri, 02 Nov 2018 15:06:36 +0100 (CET) Objet: Re: [subokita/FAsT-Match] negative index in padded image? (#4)
For WITHIN(affine_corners...) I modified the code in such way in configsToAffine():
cv::Point2f point0, point1, point2, point3; point0.x = affine_corners.at(0, 0); point0.y = affine_corners.at(0, 1); point1.x = affine_corners.at(1, 0); point1.y = affine_corners.at(1, 1); point2.x = affine_corners.at(2, 0); point2.y = affine_corners.at(2, 1); point3.x = affine_corners.at(3, 0); point3.y = affine_corners.at(3, 1);
if (WITHIN(point0, top_left, bottom_right) && WITHIN(point1, top_left, bottom_right) && WITHIN(point2, top_left, bottom_right) && WITHIN(point3, top_left, bottom_right)) {
affines[i] = affine; insiders[i] = true;
}
Excuse me, after you configure it, use the author's picture, how long does it run in Release?
-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/subokita/FAsT-Match/issues/4#issuecomment-435390919
Somehow I completely missed all the conversations. Anyway, I didn't come up with the name FAST, it was the original author of the code, at that point of time, for the thing it does (rotational invariance), it was fast.
Second thing, since I didn't have access to CUDA, so I the only parallelization I did was to use Intel TBB, if you know some GPU computing, that should speed it up considerably. Remember, this is 4 years old code, advancement in GPU, Tensor Flow, etc, should mean that this can be optimized way faster.
Also, avoid
affine_corners.at(0, 0);
deference it to pointer instead, if that code gets executed multiple times. Since at(x,y)
redo the calculation (at least in the older OpenCV) to find the index.
And for this
score += abs(vals_i1[j] - padded.at(target_y - 1, target_x - 1) );
There should be a part where it does the padding, maybe I missed the X-axis part?
Hello Saburo, Thanks A LOT for your implementation ans for sharing it. My tweaks were just a 'quick fix' to make your code compile on more recent versions of opencv and probably slow things down. Anyways it allowed me to quickly test the method on my data so thanks again ! Best, Sandrine ----- Mail d'origine ----- De: Saburo Okita [email protected] À: subokita/FAsT-Match [email protected] Cc: svoros [email protected], Author [email protected] Envoyé: Sun, 04 Nov 2018 23:07:43 +0100 (CET) Objet: Re: [subokita/FAsT-Match] negative index in padded image? (#4)
Somehow I completely missed all the conversations. Anyway, I didn't come up with the name FAST, it was the original author of the code, at that point of time, for the thing it does (rotational invariance), it was fast.
Second thing, since I didn't have access to CUDA, so I the only parallelization I did was to use Intel TBB, if you know some GPU computing, that should speed it up considerably. Remember, this is 4 years old code, advancement in GPU, Tensor Flow, etc, should mean that this can be optimized way faster.
Also, avoid
affine_corners.at(0, 0);
deference it to pointer instead, if that code gets executed multiple times. Since at(x,y)
redo the calculation (at least in the older OpenCV) to find the index.
And for this
score += abs(vals_i1[j] - padded.at(target_y - 1, target_x - 1) );
There should be a part where it does the padding, maybe I missed the X-axis part?
-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/subokita/FAsT-Match/issues/4#issuecomment-435712515
Hi there, I didn't look at computation time as I Just wanted to test the algorithm but indeed it took long minutes for one image (maybe 15-20?) on a somewhat powerful laptop so I was a bit disapointed about thé 'fast' title... Might be a question of parameters space tuning though, Hope it helps and I'm interested if you find à solution. Best, Sandrine ----- Mail d'origine ----- De: yangninghua [email protected] À: subokita/FAsT-Match [email protected] Cc: svoros [email protected], Author [email protected] Envoyé: Fri, 02 Nov 2018 15:06:36 +0100 (CET) Objet: Re: [subokita/FAsT-Match] negative index in padded image? (#4) For WITHIN(affine_corners...) I modified the code in such way in configsToAffine(): cv::Point2f point0, point1, point2, point3; point0.x = affine_corners.at(0, 0); point0.y = affine_corners.at(0, 1); point1.x = affine_corners.at(1, 0); point1.y = affine_corners.at(1, 1); point2.x = affine_corners.at(2, 0); point2.y = affine_corners.at(2, 1); point3.x = affine_corners.at(3, 0); point3.y = affine_corners.at(3, 1); if (WITHIN(point0, top_left, bottom_right) && WITHIN(point1, top_left, bottom_right) && WITHIN(point2, top_left, bottom_right) && WITHIN(point3, top_left, bottom_right)) {
affines[i] = affine; insiders[i] = true;
} Excuse me, after you configure it, use the author's picture, how long does it run in Release? … -- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: #4 (comment)
Thank you for your answer, my laptop configuration is, CPU: i7-8750H, GPU: GTX1060, I configured it according to your method, running time Release is more than 300 seconds, thank you for your help and advice
@subokita I can't find the tbb file when run the codes.
#include <tbb/tbb.h>
@subokita I meet the same issue, I can't find the tbb file when run the codes. #include <tbb/tbb.h>