Template matching using single template from multiple images

asked 2016-06-20 07:56:54 -0500

VA gravatar image

updated 2016-06-20 08:29:19 -0500

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;  }
edit retag flag offensive close merge delete

Comments

I'm sorry your question is unclear! Do you want to find a single template(Template) in multiple images(Scene's)? or Multiple occurrences of Template in a single image?

Balaji R gravatar imageBalaji R ( 2016-06-20 08:27:50 -0500 )edit