Pedro Leite

words – an empty shell, a lack of meaning

OpenStereo Plugin using CUDA

Of course I wouldn’t let OpenStereo apart from my CUDA studies. I’ve implemented an OpenStereo plugin that uses CUDA to do the fusion process. Below is the preliminary kernel code:

#include <stdlib.h>
#include <stdio.h>
#include <math.h>


#define BLOCK_SIZE 16


__global__ void fuse_images(float* left_tex, float* right_tex, float* stereo_tex,
float* matrix_left, float* matrix_right, int width, int height) {
int ix = __mul24(blockIdx.x, BLOCK_SIZE) + threadIdx.x;
int iy = __mul24(blockIdx.y, BLOCK_SIZE) + threadIdx.y;
int i = 0, j = 0, k = 0;
float c = 0.0f;

if (ix >= width || iy >= height)
return;


// rows
for (; i < 3; i++) {
// columns
k = (ix + __mul24(iy, width)) * 3;
for (j = 0; j < 3; j++) {
c += matrix_left[j + __mul24(3, i)] * left_tex[k + j];
c += matrix_right[j + __mul24(3, i)] * right_tex[k + j];
}
stereo_tex[k + i] = c;
c = 0.0f;
}
}

That function runs on the device (GPU) while the host side does the OpenGL stuff, besides calling the kernel code. A call to that function is done this way:

// executes the kernel
fuse_images<<< grid, threads >>>(cuda_left_tex, cuda_right_tex, cuda_stereo_tex,
getCudaMatrixFromMethod(method, isLeft), getCudaMatrixFromMethod(method, !isLeft), width, height);

I need to test this plugin in a CUDA device, since its emulation is working almost perfectly.
P.S.: Yeah, posting source code in wordpress sucks =/

Advertisements

October 30, 2007 - Posted by | cuda, development, open source, opengl, openstereo, stereoscopy

1 Comment »

  1. […] is wrong… My OpenStereo CUDA plugin did not directly benefit from a huge performance improve. Worst, with a 512×512 texture, his […]

    Pingback by Something is wrong… « ab initio… vel non… | October 31, 2007


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: