You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jetson TX1上OpenCV StereoBM CPU与GPU版本输出差异技术问询

Hey everyone,

I’m working on a Jetson TX1 and hit a frustrating problem: the CPU and GPU implementations of OpenCV 3.2’s StereoBM are churning out wildly different disparity maps. I compiled OpenCV 3.2 with GPU support directly on the device, so let’s break down the details, code, and outputs to figure out what’s going on.

Device Specs

  • Jetson TX1 firmware version: 28.1
  • CUDA version (verified via ldd output): 8.0

GPU Version Code

Here’s the snippet I’m using for the GPU-based stereo matching (including speckle filtering):

#include <opencv2/opencv.hpp>
#include <opencv2/cudastereo.hpp>

int main() {
    // Load input stereo images (grayscale)
    cv::Mat left_img = cv::imread("left_frame.png", cv::IMREAD_GRAYSCALE);
    cv::Mat right_img = cv::imread("right_frame.png", cv::IMREAD_GRAYSCALE);

    // Upload images to GPU memory
    cv::cuda::GpuMat d_left(left_img), d_right(right_img), d_disparity;

    // Initialize StereoBM GPU
    auto sbm_gpu = cv::cuda::createStereoBM(16, 9);
    
    // Compute raw disparity
    sbm_gpu->compute(d_left, d_right, d_disparity);

    // Apply speckle filter to clean up noise
    sbm_gpu->setSpeckleRange(16);
    sbm_gpu->setSpeckleWindowSize(100);
    sbm_gpu->compute(d_left, d_right, d_disparity);

    // Download result back to CPU
    cv::Mat disparity_gpu;
    d_disparity.download(disparity_gpu);

    // Save output
    cv::imwrite("disparity_gpu_filtered.png", disparity_gpu);
    return 0;
}

Output Comparisons

CPU Version Output

The CPU-generated disparity map is smooth, with consistent depth values across the scene. Object edges are well-defined, and there’s minimal noise in flat regions—this is the "ground truth" result I’m expecting.

GPU Version Output (No Speckle Filter)

The raw GPU output is riddled with noise, large patches of incorrect depth values, and misaligned edges. It barely resembles the scene’s actual geometry.

GPU Version Output (With Speckle Filter)

StereoBM_GPU with Speckle Filter applied: The filter reduces some of the noise, but the result still has massive discrepancies compared to the CPU version. Object edges are blurred, and flat regions show inconsistent depth readings that don’t match the CPU output.

Potential Debugging Angles I’m Considering

  • Parameter Mismatch: I’m double-checking that every parameter (block size, number of disparities, speckle settings) is identical between CPU and GPU setups. It’s easy to miss a default parameter that behaves differently in the GPU backend.
  • CUDA/OpenCV Compatibility: Jetson TX1’s CUDA 8.0 paired with OpenCV 3.2 might have known quirks. I’m verifying that my OpenCV build correctly linked to the system’s CUDA 8.0 libraries and that no compile flags are causing optimization mismatches.
  • Memory Transfer Errors: I’m adding checks after uploading/downloading images to GPU memory to rule out corruption during data transfer.
  • Data Type Differences: The GPU might output a 16-bit signed disparity map by default, while the CPU uses a different format. I’m ensuring both outputs are normalized to the same data type before comparison.
  • Speckle Filter Implementation Gaps: The CPU and GPU speckle filters might process noise differently. I’m testing the GPU output without filtering first to see if the core disparity calculation is the root issue.

If anyone has run into similar issues on Jetson devices or with OpenCV 3.2’s GPU stereo matching, I’d love to hear your insights. Sharing sample input images or additional debug steps would also be a huge help!

内容的提问来源于stack exchange,提问作者Satyarth Praveen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 10:23:12