gpt4 book ai didi

c++ - StereoBm Opencv函数报错 "object of an abstract class cannot be defined"

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:33:08 27 4
gpt4 key购买 nike

当我初始化 StereoBM 对象时,出现错误“无法定义抽象类的对象”。我检查了 calib3d.hpp,发现 StereoBM 是一个抽象类。请给我一个解决方案,如何在 StereoBM 类中定义所有这些功能

cv::Mat leftimg =cv::imread("leftimage.jpg");
cv::Mat rightimg = cv::imread("rightimage.jpg");
cv::Size imagesize = leftimg.size();

cv::Mat g1,g2,disp,disp8;
cv::cvtColor(leftimg,g1,cv::COLOR_BGR2GRAY);
cv::cvtColor(rightimg,g2,cv::COLOR_BGR2GRAY);

cv::StereoBM *sbm;
sbm->setDisp12MaxDiff(1);
sbm->setSpeckleRange(8);
sbm->setSpeckleWindowSize(0);
sbm->setUniquenessRatio(0);
sbm->setTextureThreshold(507);
sbm->setMinDisparity(-39);
sbm->setPreFilterCap(61);
sbm->setPreFilterSize(5);
sbm->compute(g1,g2,disp);
normalize(disp, disp8, 0, 255, CV_MINMAX, CV_8U);

cv::imshow("left", leftimg);
cv::imshow("right", rightimg);
cv::imshow("disp", disp8);

最佳答案

如果您使用的是 3.1 版,您将收到以下错误:

use of undeclared identifier 'createStereoBM'

对于 3.1 你可以尝试:

StereoBM *sbm = StereoBM::create(16, 2);

关于c++ - StereoBm Opencv函数报错 "object of an abstract class cannot be defined",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26069861/

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