branch_detection.cuh 1.05 KB
#include <iostream>
#include <fstream>
#include <cuda_runtime.h>
#include <stim/math/vector.h>
//#include <math.h>
#include <stim/visualization/colormap.h>
#include <stim/cuda/cuda_texture.cuh>
#include <stim/cuda/filter.cuh>
typedef unsigned int uint;
//typedef unsigned int uchar;


std::vector< stim::vec<float> >
find_branch(GLint texbufferID, GLenum texType, unsigned int x, unsigned int y)
{
	float		sigma		= 2.0;
	unsigned int	conn		= 7;
	float		threshold	= 40.0;
	float*		cpuCenters	= (float*) malloc(x*y*sizeof(float));
	int		sizek		= 7;

	stringstream name;


	cpuCenters = stim::cuda::get_centers(texbufferID, texType, x, y, sizek, sigma, conn, threshold);
	cudaDeviceSynchronize();



	std::vector<stim::vec<float> >  output;
	
	cudaDeviceSynchronize();

	for(int i = 0; i < x; i++)
	{
		for(int j = 0; j < y; j++)
		{
			int idx = x*j+i;
			if(cpuCenters[idx] != 0)
			{
				float x_v = (float) i;
				float y_v = (float) j;
				output.push_back(stim::vec<float>((x_v/(float)x*360.0),
								  (y_v), y_v/8));	
			}

		} 
	}
	
	free(cpuCenters);
	return output;
}