Comparing an image with a pattern one

Can you explain your actual application – do you want it to recognize a banana or a car, or identify which chess piece you are holding, or follow a red ball or a marker? Your actual specific need matters a lot with these kinds of problems.

BoofCV can do template matching – but it method probably not going to work for your needs (depending on what they are)

If you want robust general object detection based on YOLO, then you could try using this tutorial for Processing+opencv:

http://www.magicandlove.com/blog/2018/08/08/darknet-yolo-v3-testing-in-processing-with-the-opencv-dnn-module/

see for example: Conflicting libraries (YOLO comp vision) - #7 by TTG