It's been a long time since I'v used Java, and I've never used arguments before. So I am using OpenCV Template Matching. I am following this example. You can look at the link if you want to. I do not think it is necessary to copy and past the whole thing.
When I run the project, it prints;
Not enough parameters
Program arguments:
<image_name> <template_name> [<mask_name>]
So the program needs least 2 parameters: Source and template image files. But I don't know how pass files to the program. Does it need the file-path or the file itself?
This is the method:
public void run(String[] args) {
if (args.length < 2) {
System.out.println("Not enough parameters");
System.out.println("Program arguments:\n<image_name> <template_name> [<mask_name>]");
System.exit(-1);
}
img = Imgcodecs.imread(args[0], Imgcodecs.IMREAD_COLOR);
templ = Imgcodecs.imread(args[1], Imgcodecs.IMREAD_COLOR);
if (args.length > 2) {
use_mask = true;
mask = Imgcodecs.imread(args[2], Imgcodecs.IMREAD_COLOR);
}
if (img.empty() || templ.empty() || (use_mask && mask.empty())) {
System.out.println("Can't read one of the images");
System.exit(-1);
}
matchingMethod();
createJFrame();
}
This is the main method:
public class MatchTemplateDemo {
public static void main(String[] args) {
// load the native OpenCV library
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
// run code
new MatchTemplateDemoRun().run(args);
}
}