justadudewhohacks / justadudewhohacks/opencv4nodejs

Unable to compare histograms

Open
#540 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
5.1k
Forks
826
PR merge metrics
No merged PRs in 30d

Description

I'm trying to use teh compareHist function but always get
the error:
Mat::CompareHist - OpenCV Error: (H1.type() == H2.type() && H1.depth() == CV_32F

I've tried changing it with:
grayHist.convertTo(cv.CV_32F, 0, 1);

but after grayHist.depth is still set to 6 ( which is cv.CV_64F) insead of 5 (cv.CV_32F);

Here is my complete code:
`
const img = cv.imread('../Materials/Nike - App Screenshots/mine/nike_running3.PNG');

var grayImg = img.bgrToGray();
var grayHist = cv.calcHist(grayImg, getHistAxis(0));
grayHist.convertTo(cv.CV_32F, 0, 1);
grayHist.normalize( 1, 0, cv.NORM_MINMAX, -1) ;
grayHist.compareHist(grayHist, cv.HISTCMP_CORREL);
`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.