Blame view

stim/cuda/branch_detection.cuh 1.07 KB
84eff8b1   Pavel Govyadinov   Merged only the n...
1
2
3
4
5
6
7
  #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>
27194b56   Pavel Govyadinov   major bug fixes, ...
8
  #include <stim/cuda/filter.cuh>
84eff8b1   Pavel Govyadinov   Merged only the n...
9
  typedef unsigned int uint;
9b766f1f   Pavel Govyadinov   completed merge f...
10
  //typedef unsigned int uchar;
84eff8b1   Pavel Govyadinov   Merged only the n...
11
  
84eff8b1   Pavel Govyadinov   Merged only the n...
12
13
  
  std::vector< stim::vec<float> >
2eefb035   Pavel Govyadinov   added debugging c...
14
  find_branch(GLint texbufferID, GLenum texType, unsigned int x, unsigned int y, int iter = 0)
84eff8b1   Pavel Govyadinov   Merged only the n...
15
  {
27194b56   Pavel Govyadinov   major bug fixes, ...
16
17
  	float		sigma		= 2.0;
  	unsigned int	conn		= 7;
7f1ab3c2   Pavel Govyadinov   fixed problems wi...
18
  //	float		threshold	= 40.0;
27194b56   Pavel Govyadinov   major bug fixes, ...
19
20
  	float*		cpuCenters	= (float*) malloc(x*y*sizeof(float));
  	int		sizek		= 7;
84eff8b1   Pavel Govyadinov   Merged only the n...
21
  
7f1ab3c2   Pavel Govyadinov   fixed problems wi...
22
  	std::stringstream name;
84eff8b1   Pavel Govyadinov   Merged only the n...
23
24
  
  
7f1ab3c2   Pavel Govyadinov   fixed problems wi...
25
  	cpuCenters = stim::cuda::get_centers(texbufferID, texType, x, y, sizek, sigma, conn, iter);
84eff8b1   Pavel Govyadinov   Merged only the n...
26
  	cudaDeviceSynchronize();
84eff8b1   Pavel Govyadinov   Merged only the n...
27
28
  
  
84eff8b1   Pavel Govyadinov   Merged only the n...
29
  
27194b56   Pavel Govyadinov   major bug fixes, ...
30
  	std::vector<stim::vec<float> >  output;
84eff8b1   Pavel Govyadinov   Merged only the n...
31
32
  	
  	cudaDeviceSynchronize();
8c4f5d84   Pavel Govyadinov   fixed the issue w...
33
34
35
36
37
38
39
40
41
42
  
  	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;
8c4f5d84   Pavel Govyadinov   fixed the issue w...
43
44
45
46
47
48
49
  				output.push_back(stim::vec<float>((x_v/(float)x*360.0),
  								  (y_v), y_v/8));	
  			}
  
  		} 
  	}
  	
84eff8b1   Pavel Govyadinov   Merged only the n...
50
51
52
  	free(cpuCenters);
  	return output;
  }