-
Notifications
You must be signed in to change notification settings - Fork 852
matchTemplate #387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Error what i received is |
@padom template's Mat and the input image should both be of same type (single channel etc) and depth (8bit etc). Make sure that's the case. |
They both are the same type and depth, template image is actually cropped copy of original. Do you have another idea? |
are they RGB or single channel? You need to convert both template and input to single channel before running matchTemplate() |
Thanks for helping, now I got another error. Assertion failed: (object->InternalFieldCount() > 0), function Unwrap, file ../node_modules/nan/nan_object_wrap.h, line 33.
|
whats the exact error? |
As a sidenote, I'm looking for the documentation on |
I've just edited post above, here is the error OpenCV Error: Assertion failed (corrsize.height <= img.rows + templ.rows - 1 && corrsize.width <= img.cols + templ.cols - 1) in crossCorr, file /tmp/opencv20160107-54198-1duzac3/opencv-2.4.12/modules/imgproc/src/templmatch.cpp, line 70 |
I just looked at the code to see what might be wrong. Here's your amended code which may work (I didn't test): cv.readImage("./test.jpg", function(err, im) {
im.convertGrayscale();
im.matchTemplate("./template.jpg", 3, function(result){
result.save('./pic.jpg');
});
}); |
Doesn't work, same error like before OpenCV Error: Assertion failed ((img.depth() == CV_8U || img.depth() == CV_32F) && img.type() == templ.type()) in matchTemplate, file /tmp/opencv20160107-54198-1duzac3/opencv-2.4.12/modules/imgproc/src/templmatch.cpp, line 249 |
there's an inherent issue which the author of this function may have overlooked. He reads the template image as: cv::imread(filename, CV_8S); which means he's reading it as 8bit signed image while it should've been 8U and not 8S. I can create a pull request with the fix though. P.S: also just checked and OpenCV's matchTemplate doesn't require image to be single channel anymore. |
@salmanulhaq does this mean we can't use the function at all or is there a workaround? I also did find this: http://stackoverflow.com/a/35727588/1501285 |
@salmanulhaq would be great if you could make the fix |
is it possible to just use an image rather than image file as template? also, how do I access the probabilities of the match (to compare with other images)? Thanks! |
@dominikdolancic you can take a look at #419 if not too late :). |
Using an image (=opencv matrix) instead image file as template: #420 Working example using node-opencv template matching |
Here is how I got this to work:
The output seems to be an array that looks like this: Ignore first element in the array, next two are coordinates of top left, last two are lengths of the bounding box. btw, before you can install opencv module, you need to run the following
|
This is cool. However I did not find any documentation mentioning finding multiple template matches on one image. |
I tried to write an example for matchTemplate but without success. Please if someone could write some example for using this function.
Thanks in advance,
Dominik
The text was updated successfully, but these errors were encountered: