What are the ximgproc_DisparityWLSFilter.filter() Arguments?

北城余情 提交于 2020-07-07 08:15:08

问题


I get a ximgproc_DisparityWLSFilter from cv2.ximgproc.createDisparityWLSFilter(left_matcher), but I cannot get ximgproc_DisparityWLSFilter.filter() to work.

The error I get is

OpenCV Error: Assertion failed (!disparity_map_right.empty() && (disparity_map_right.depth() == CV_16S) && (disparity_map_right.channels() == 1)) in cv::ximgproc::DisparityWLSFilterImpl::filter, file ......\opencv_contrib\modules\ximgproc\src\disparity_filters.cpp, line 262

In general, how do I figure out how to use this, when there isn't a single google result for "ximgproc_DisparityWLSFilter"?


回答1:


I had this issue too, what you need to do is create the filter first. Then you can filter... hopefully that makes sense. Here is a code snippet of what I used tested on Python 3.6 opencv3.4.2

wls = cv2.ximgproc.createDisparityWLSFilter(left_Matcher)
filteredDisp = wls.filter(leftStereoComputeOutput, leftOriginalImage, disparity_map_right=rightStereoComputeOutput)

In order to figure out how this bit worked, I had to look at the documentation and at what other people had implemented on Github, then connect the pieces. Lots of Trial and Error.

Arguments for the filter are:

Python:
filtered_disparity_map  =   cv.ximgproc_DisparityFilter.filter( disparity_map_left, left_view[, filtered_disparity_map[, disparity_map_right[, ROI[, right_view]]]] )

Parameters:

disparity_map_left disparity map of the left view, 1 channel, CV_16S type. Implicitly assumes that disparity values are scaled by 16 (one-pixel disparity corresponds to the value of 16 in the disparity map). Disparity map can have any resolution, it will be automatically resized to fit left_view resolution.

left_view left view of the original stereo-pair to guide the filtering process, 8-bit single-channel or three-channel image.

filtered_disparity_map output disparity map.

disparity_map_right optional argument, some implementations might also use the disparity map of the right view to compute confidence maps, for instance.

ROI region of the disparity map to filter. Optional, usually it should be set automatically.

right_view optional argument, some implementations might also use the right view of the original stereo-pair.

The above Parameters were found at https://docs.opencv.org/3.4/db/d72/classcv_1_1ximgproc_1_1DisparityFilter.html




回答2:


Unlike c++, Python doesn't work well with pointers. So the arguments are

Filtered_disp = ximgproc_DisparityWLSFilter.filter(left_disp,left, None,right_disp)

Note that it's no longer a void function in Python!

I figured this out through trial and error though.



来源:https://stackoverflow.com/questions/44276962/what-are-the-ximgproc-disparitywlsfilter-filter-arguments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!