justadudewhohacks / justadudewhohacks/opencv4nodejs

Error: CalcHist - object has no property: ranges

Open
#865 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

使用官方进行读取图片并进行直方图计算
代码如下
```javascript
const img = cv.imread(imgPath, cv.IMREAD_GRAYSCALE);
const histSize = [256];
const channels = [0];
const ranges = [0, 256];
console.log('img',img)
const hist = cv.calcHist(img, channels, new cv.Mat([256], [1], cv.CV_32F), histSize, ranges);
return hist;
```
打印的图片数据如下
```json
img Mat {
step: 375,
elemSize: 1,
sizes: [ 3243, 375 ],
empty: false,
depth: 0,
dims: 2,
channels: 1,
type: 0,
cols: 375,
rows: 3243 }
```
报错Error: CalcHist - object has no property: ranges
at Error (native)
at calcHistogram (/app/histogram_opencv.js:30:19)
at calcImageSimilarity (/app/histogram_opencv.js:35:17)
at processImages (/app/histogram_opencv.js:60:28)
at Object. (/app/histogram_opencv.js:70:1)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)

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.