Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if equal to opencv-sgbm Dynamic Programming of cost aggregation ? #83

Open
PrinceDouble opened this issue Nov 28, 2024 · 0 comments
Open

Comments

@PrinceDouble
Copy link

PrinceDouble commented Nov 28, 2024

hi, the cuda kenel of cost aggregation is pretty hard understand for me, i am writting the cuda version of opencv sgbm, i find your project so well! i am trying to confirm if the cost aggregation of libsgm is equal implement opencv-sgbm, the latter's cost aggregation is Dynamic Programming,i found the test instance of libsgm cost aggregation is not, the minLp is Minimum along disp dim !https://github.com/fixstars/libSGM/blob/master/test/cost_aggregation_test.cpp line 94

can you give some advice to implement the cost aggregation of opencv-sgbm, the paper is the same with libsgm in term of cost aggregation? Thx

Embedded_ real-time stereo estimation via Semi-Global Matching on the GPU D. Hernandez-Juarez, A. Chacón, A. Espinosa, D. Vázquez, J. C. Moure, and A. M. López ICCS2016 – International Conference on Computational Science 2016**

for (int vc = v0; vc != v1; vc += dv) {

	const CENSUS_TYPE* censusL = srcL.ptr<CENSUS_TYPE>(vc);
	const CENSUS_TYPE* censusR = srcR.ptr<CENSUS_TYPE>(vc);
	for (int uc = u0; uc != u1; uc += du) {

		const int vp = vc - rv;
		const int up = uc - ru;
		const bool inside = vp >= 0 && vp < h&& up >= 0 && up < w;

		const CENSUS_TYPE cL = censusL[uc];
		COST_TYPE* Lc = dst.ptr<COST_TYPE>(vc * w + uc);
		COST_TYPE* Lp = inside ? dst.ptr<COST_TYPE>(vp * w + up) : zero.data();

		COST_TYPE minLp = std::numeric_limits<COST_TYPE>::max();
		for (int d = 0; d < n; d++)
			minLp = std::min(minLp, Lp[d]);

		const COST_TYPE _P1 = P1 - minLp;
		for (int d = 0; d < n; d++) {
			const int uR = uc - d - min_disp;
			const CENSUS_TYPE cR = uR >= 0 && uR < w ? censusR[uR] : 0;
			const COST_TYPE MC = HammingDistance(cL, cR);
			const COST_TYPE Lp0 = Lp[d] - minLp;
			const COST_TYPE Lp1 = d > 0 ?     Lp[d - 1] + _P1 : 0xFF;
			const COST_TYPE Lp2 = d < n - 1 ? Lp[d + 1] + _P1 : 0xFF;
			const COST_TYPE Lp3 = P2;
			Lc[d] = static_cast<COST_TYPE>(MC + min4(Lp0, Lp1, Lp2, Lp3));
		}
	}
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant