How to realize OpenCV's warpperspective function in OpenGL

Hello guys!I am running into a problem that i cant solve… I am trying to realize OpenCV’s warpPerspective function in OpenGL fragment shader, But I cant get expected result. The result is always a black image… Could anyone professional offer me a simple demo about this problem? Thanks a lotttttt!!!

@magnet2c-cmd I was following this buddy’s method. But it seems that it does not work…

mat3 inverseProjectMatrix2 = mat3(
	-2.69544232e+00,  7.12768849e+00, -2.42274679e+03,
	4.16355568e-01,  3.79979565e+00, -2.70127515e+03,
	4.51824274e-04,  1.40540181e-02, -8.16333507e+00
);

float c11 = inverseProjectMatrix2[0][0];
float c12 = inverseProjectMatrix2[0][1];
float c13 = inverseProjectMatrix2[0][2];
float c21 = inverseProjectMatrix2[1][0];
float c22 = inverseProjectMatrix2[1][1];
float c23 = inverseProjectMatrix2[1][2];
float c31 = inverseProjectMatrix2[2][0];
float c32 = inverseProjectMatrix2[2][1];
float c33 = inverseProjectMatrix2[2][2];

void main() {
	vec3 frameCoords = vec3(gl_FragCoord.x, gl_FragCoord.y, 1.0);
	vec3 m = inverseProjectMatrix2[2] * frameCoords;
	float zed = 1.0 / (m.x + m.y + m.z);
	frameCoords = frameCoords * zed;
	float xTrans = c11 * frameCoords.x + c12 * frameCoords.y + c13 * frameCoords.z;
	float yTrans = c21 * frameCoords.x + c22 * frameCoords.y + c23 * frameCoords.z;
	vec2 coords = vec2(xTrans / width, yTrans / height);
	gl_FragColor = texture(inputImageTexture, coords);
}

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.