I\'m trying to match this image
in this image
However, I can\'t find more than one boss enemy. What do I need to do to find the others? >
I didn't debug your code, but since it doesn't work (probably floodfill
is messing up your result matrix), this is a simple working sample.
I iterate over the maximum points in the result matrix finding the blobs where values are over a threshold, and finding the highest value within each blob (used as a mask to retrieve actual values in the result matrix).
#include
#include
using namespace std;
using namespace cv;
int main()
{
Mat3b img = imread("path_to_image");
Mat3b templ = imread("path_to_template");
Mat1b img_gray;
Mat1b templ_gray;
cvtColor(img, img_gray, COLOR_BGR2GRAY);
cvtColor(templ, templ_gray, COLOR_BGR2GRAY);
Mat1f result;
matchTemplate(img, templ, result, TM_CCOEFF_NORMED);
double thresh = 0.7;
threshold(result, result, thresh, 1., THRESH_BINARY);
Mat1b resb;
result.convertTo(resb, CV_8U, 255);
vector> contours;
findContours(resb, contours, RETR_LIST, CHAIN_APPROX_SIMPLE);
for (int i=0; i
Result: