gpt4 book ai didi

opencv - 如何使用 opencv.js 中的 cv.goodFeaturesToTrack?

转载 作者:行者123 更新时间:2023-12-02 17:19:57 36 4
gpt4 key购买 nike

我正在尝试的代码:

let src = cv.imread('inputImage');  // read from <img id="inputImage" />
let temp = new cv.Mat();
src.convertTo(temp, cv.CV_32FC1); // cv.CV_32FC1 === 5

let features = new cv.Mat();
cv.goodFeaturesToTrack(temp, features, 500, 0.01, 10); // These numbers are arbitrary.
我在浏览器控制台上:
OpenCV Error: Assertion failed (src.type() == (((0) & ((1 << 3) - 1)) + (((1)-1) << 3)) || src.type() == (((5) & ((1 << 3) - 1)) + (((1)-1) << 3))) in cornerEigenValsVecs, file /build/master-contrib_docs-lin64/opencv/modules/imgproc/src/corner.cpp, line 269 opencv.js:21:3644

Uncaught 6384400 - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch. opencv.js:21:1597503
(((0) & ((1 << 3) - 1)) + (((1)-1) << 3))
-> 0
cv.CV_8U
-> 0
(((5) & ((1 << 3) - 1)) + (((1)-1) << 3))
-> 5
cv.CV_32F
-> 5
cv.CV_32FC1
-> 5
cv.CV_8UC1
-> 0
使用 convertTo() 或使用 cv.cvtColor() 时是否转换到另一个 channel ?

最佳答案

输入 goodFeaturesToTrack should be an 8-bit or 32-bit single channel image .看来您实际上是在传递 3 channel 图像;问题是 convertTo可用于更改位深度,但不能更改 channel 数 -- see documentation here .
我建议这样做:

cv.cvtColor(src, src, cv.COLOR_BGR2GRAY); // convert to 1-channel
let features = new cv.Mat();
cv.goodFeaturesToTrack(src, features, 500, 0.01, 10);
换句话说, convertTo call 可以完全省略。

关于opencv - 如何使用 opencv.js 中的 cv.goodFeaturesToTrack?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62726710/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com