I have to understand if an image contains another similar image. Here 2 example:
Inside this image: I need to find this image:
The idea is: given an input image and a set of icons find which icon is present in the input image.
I've tried using MatchTemplate
and feature matching with ORB and SIFT but I couldn't find any valid matches.
Here my try with MatchTemplate
in Go:
package main
import (
"fmt"
"image/color"
"gocv.io/x/gocv"
)
func main() {
matImage := gocv.IMRead("/Users/pioz/Desktop/samplex.jpg", gocv.IMReadGrayScale)
// gocv.Canny(matImage, &matImage, 200, 400)
matTemplate := gocv.IMRead("/Users/pioz/Desktop/eld.jpg", gocv.IMReadGrayScale)
// gocv.Canny(matTemplate, &matTemplate, 20, 40)
matResult := gocv.NewMat()
mask := gocv.NewMat()
gocv.MatchTemplate(matImage, matTemplate, &matResult, gocv.TmCcoeffNormed, mask)
mask.Close()
minConfidence, maxConfidence, minLoc, maxLoc := gocv.MinMaxLoc(matResult)
fmt.Println(minConfidence, maxConfidence, minLoc, maxLoc)
gocv.Circle(&matImage, minLoc, 10, color.RGBA{0, 0, 255, 1}, 10)
gocv.Circle(&matImage, maxLoc, 10, color.RGBA{0, 0, 255, 1}, 10)
gocv.IMWrite("out/out.jpg", matImage)
}
Do you have any advice or snippet to solve this kind of problem?
Off the bat, template matching doesn't directly help you match things that are scaled, rotated, or warped. Template matching is strictly concerned with measuring the similarity of two images exactly as they appear.