Skip to content
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

matchTemplate by matrix is not work. #632

Closed
lazy-detourer opened this issue Jun 23, 2018 · 2 comments
Closed

matchTemplate by matrix is not work. #632

lazy-detourer opened this issue Jun 23, 2018 · 2 comments

Comments

@lazy-detourer
Copy link

The following is very well:

import * as opencv from 'opencv';

opencv.readImage('img/sc1.png', (err, imWork) => {
    let result = imWork.matchTemplate('img/number/w0.png', 3);
    result[0].save('test/test.png');
});

However, the following error occurs:

import * as opencv from 'opencv';

opencv.readImage('img/sc1.png', (err, imWork) => {
    opencv.readImage('img/number/w0.png', (err, imNum) => {
        imWork.matchTemplate(imNum, 3);
    });
});
OpenCV(3.4.1) Error: Assertion failed ((depth == 0 || depth == 5) && type == _templ.type() && _img.dims() <= 2) in cv::matchTemplate, file C:\build\master_winpack-build-win64-vc14\opencv\modules\imgproc\src\templmatch.cpp, line 1102

Please tell me what I miss something.

I think the first way is to read the image file from disk every time.

I've already checked the following link:
#387

But it was not for my case.

Please help me.

@KSR-Yasuda
Copy link

KSR-Yasuda commented Jun 28, 2018

Isn't it opencv.Matrix.matchTemplateByMatrix()?

Seeing the source src/Matrix.cc,
opencv.Matrix.matchTemplate() requires (string, unsigned int) as its arguments, and
opencv.Matrix.matchTemplateByMatrix() does (opencv.Matrix, unsigned int).

@ccckblaze
Copy link

@jeemin1
grayed the image using cvtColor(cv.COLOR_BGR2GRAY) before matchTemplate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants