Blame view

tira/cuda/branch_detection.cuh 1.07 KB
ce6381d7   David Mayerich   updating to TIRA
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
  #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, int iter = 0)
  {
  	float		sigma		= 2.0;
  	unsigned int	conn		= 7;
  //	float		threshold	= 40.0;
  	float*		cpuCenters	= (float*) malloc(x*y*sizeof(float));
  	int		sizek		= 7;
  
  	std::stringstream name;
  
  
  	cpuCenters = stim::cuda::get_centers(texbufferID, texType, x, y, sizek, sigma, conn, iter);
  	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;
  }