subokita / FAsT-Match

Port of Fast Affine Template Matching algorithm
125 stars 46 forks source link

issues after removing parallel_for #6

Open aopaw opened 3 years ago

aopaw commented 3 years ago

Hello, I am working on visual servo research. In order to locate an approximate position of the object, I am looking for approach related to template tracking and found your code. A few errors came during debug session possibably because of the compiler of visual studio 2013 I am using. One part is here

    if (WITHIN(cv::Point2f(affine_corners.at<float>(0, 0), affine_corners.at<float>(0, 1)), top_left, bottom_right) &&
                WITHIN(cv::Point2f(affine_corners.at<float>(1, 0), affine_corners.at<float>(1, 1)), top_left, bottom_right) &&
                WITHIN(cv::Point2f(affine_corners.at<float>(2, 0), affine_corners.at<float>(2, 1)), top_left, bottom_right) &&
                WITHIN(cv::Point2f(affine_corners.at<float>(3, 0), affine_corners.at<float>(3, 1)), top_left, bottom_right)) {

                affines[i] = affine;
                insiders[i] = true;

One other is about matrix boundary

            if (!photometric_invariance) {
                for (int j = 0; j < no_of_points; j++) {
                    int target_x = int(a11 * xs_ptr_cent[j] + a12 * ys_ptr_cent[j] + tmp_1),
                        target_y = int(a21 * xs_ptr_cent[j] + a22 * ys_ptr_cent[j] + tmp_2);

                    int rj, cj;
                    if (target_y - 1 <=0)
                        rj = 0;
                    else if (target_y > padded.size().height)
                        rj = padded.size().height-1;
                    else
                        rj = target_y-1;

                    if (target_x - 1 <= 0)
                        cj = 0;
                    else if (target_x > padded.size().width)
                        cj = padded.size().width-1;
                    else
                        cj = target_x-1;

                    score += abs(vals_i1[j] - padded.at<float>(rj,cj));

I also replace tbb::parallel_for with standard for simply because failure in using TBB which had also been compiled successfully. After such modifications, the program compiled but does not give me result within a long time.

So, I open this post to tell my question and also want to ask whether the program running takes very long time if the tbb::parallel_for was entirely removed.

Thanks in advance.

subokita commented 3 years ago

It's in essence a parallel for when it was running on a small notebook without GPU. Yes, it'd run slower, however, that was like 7 years ago, so: