Ask Your Question

Revision history [back]

Hello,guys,I am begginer and working template matching in opencv c++ and I want find match using single template from multiple images,so,is there anyone who has know how in this case?

cout << "Size of Template image =" << Img_Templ.size() << endl;
Img_Result = Img_Scene.clone();//img_Scene is huge image
Mat img1 = Img_Result(Rect(0, 0, 1000, 1000));
Mat img2 = Img_Result(Rect(Img_Result.cols - 1000, 0, 1000, 1000));
vector<Mat> List_roi;
List_roi.push_back(img1);
List_roi.push_back(img2);
vector<Mat>images;
Point  Point_TemplateLocation;
for (int i = 0; i < List_roi.size(); i++)
{
    if (!FindTemplateMatching(List_roi[i], Img_Templ, Point_TemplateLocation))
    {cout << "No Match Found";
    }
    else
    {images.push_back(img1);
    images.push_back(img2);
        rectangle(images[i], Point_TemplateLocation, Point(Point_TemplateLocation.x + Img_Templ.cols, Point_TemplateLocation.y + Img_Templ.rows), Scalar(0, 0, 255), 2, 8, 0);
        putText(images[i], format("Object1 %d", i), Point(Point_TemplateLocation.x + Img_Templ.cols / 4, Point_TemplateLocation.y + Img_Templ.rows / 2), 1, 1, Scalar(255, 0, 0), 1, -1);

    }}
  // display result is here
waitKey(0);
return 0;  }

Hello,guys,I am begginer and working template Template matching in opencv c++ and I want find match using single template from multiple images,so,is there anyone who has know how in this case?images

cout << "Size of Template image =" << Img_Templ.size() << endl;
Img_Result = Img_Scene.clone();//img_Scene is huge image
Mat img1 = Img_Result(Rect(0, 0, 1000, 1000));
Mat img2 = Img_Result(Rect(Img_Result.cols - 1000, 0, 1000, 1000));
vector<Mat> List_roi;
List_roi.push_back(img1);
List_roi.push_back(img2);
vector<Mat>images;
Point  Point_TemplateLocation;
for (int i = 0; i < List_roi.size(); i++)
{
    if (!FindTemplateMatching(List_roi[i], Img_Templ, Point_TemplateLocation))
    {cout << "No Match Found";
    }
    else
    {images.push_back(img1);
    images.push_back(img2);
        rectangle(images[i], Point_TemplateLocation, Point(Point_TemplateLocation.x + Img_Templ.cols, Point_TemplateLocation.y + Img_Templ.rows), Scalar(0, 0, 255), 2, 8, 0);
        putText(images[i], format("Object1 %d", i), Point(Point_TemplateLocation.x + Img_Templ.cols / 4, Point_TemplateLocation.y + Img_Templ.rows / 2), 1, 1, Scalar(255, 0, 0), 1, -1);

    }}
  // display result is here
waitKey(0);
return 0;  }