GuidedFilter  1.2.0
 Hosted by GitHub
algorithms.hpp
Go to the documentation of this file.
1 
32 #ifndef GF_ALGORITHMS_HPP
33 #define GF_ALGORITHMS_HPP
34 
35 #include <CLUtils.hpp>
36 #include <GuidedFilter/common.hpp>
37 #include <GuidedFilter/math.hpp>
38 
39 
43 namespace cl_algo
44 {
47 namespace GF
48 {
49 
51  enum class SeparateRGBConfig : uint8_t
52  {
53  FLOAT_FLOAT,
55  };
56 
57 
67  template <SeparateRGBConfig C>
68  class SeparateRGB;
69 
70 
98  template <>
100  {
101  public:
106  enum class Memory : uint8_t
107  {
108  H_IN,
109  H_OUT_R,
110  H_OUT_G,
111  H_OUT_B,
112  D_IN,
113  D_OUT_R,
114  D_OUT_G,
115  D_OUT_B
116  };
117 
119  SeparateRGB (clutils::CLEnv &_env, clutils::CLEnvInfo<1> _info);
121  cl::Memory& get (SeparateRGB::Memory mem);
123  void init (unsigned int _width, unsigned int _height, Staging _staging = Staging::IO);
125  void write (SeparateRGB::Memory mem = SeparateRGB::Memory::D_IN, void *ptr = nullptr, bool block = CL_FALSE,
126  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
128  void* read (SeparateRGB::Memory mem = SeparateRGB::Memory::H_OUT_R, bool block = CL_TRUE,
129  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
131  void run (const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
132 
133  cl_float *hPtrIn;
134  cl_float *hPtrOutR;
135  cl_float *hPtrOutG;
136  cl_float *hPtrOutB;
138  private:
139  clutils::CLEnv &env;
140  clutils::CLEnvInfo<1> info;
141  cl::Context context;
142  cl::CommandQueue queue;
143  cl::Kernel kernel;
144  cl::NDRange global, local;
145  Staging staging;
146  size_t wgMultiple;
147  unsigned int width, height;
148  unsigned int bufferInSize, bufferOutSize;
149  cl::Buffer hBufferIn, hBufferOutR, hBufferOutG, hBufferOutB;
150  cl::Buffer dBufferIn, dBufferOutR, dBufferOutG, dBufferOutB;
151 
152  public:
160  template <typename period>
161  double run (clutils::GPUTimer<period> &timer, const std::vector<cl::Event> *events = nullptr)
162  {
163  queue.enqueueNDRangeKernel (kernel, cl::NullRange, global, local, events, &timer.event ());
164  queue.flush (); timer.wait ();
165 
166  return timer.duration ();
167  }
168 
169  };
170 
171 
200  template <>
202  {
203  public:
208  enum class Memory : uint8_t
209  {
210  H_IN,
211  H_OUT_R,
212  H_OUT_G,
213  H_OUT_B,
214  D_IN,
215  D_OUT_R,
216  D_OUT_G,
217  D_OUT_B
218  };
219 
221  SeparateRGB (clutils::CLEnv &_env, clutils::CLEnvInfo<1> _info);
223  cl::Memory& get (SeparateRGB::Memory mem);
225  void init (unsigned int _width, unsigned int _height, Staging _staging = Staging::IO);
227  void write (SeparateRGB::Memory mem = SeparateRGB::Memory::D_IN, void *ptr = nullptr, bool block = CL_FALSE,
228  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
230  void* read (SeparateRGB::Memory mem = SeparateRGB::Memory::H_OUT_R, bool block = CL_TRUE,
231  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
233  void run (const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
234 
235  cl_uchar *hPtrIn;
236  cl_float *hPtrOutR;
237  cl_float *hPtrOutG;
238  cl_float *hPtrOutB;
240  private:
241  clutils::CLEnv &env;
242  clutils::CLEnvInfo<1> info;
243  cl::Context context;
244  cl::CommandQueue queue;
245  cl::Kernel kernel;
246  cl::NDRange global, local;
247  Staging staging;
248  size_t wgMultiple;
249  unsigned int width, height;
250  unsigned int bufferInSize, bufferOutSize;
251  cl::Buffer hBufferIn, hBufferOutR, hBufferOutG, hBufferOutB;
252  cl::Buffer dBufferIn, dBufferOutR, dBufferOutG, dBufferOutB;
253 
254  public:
262  template <typename period>
263  double run (clutils::GPUTimer<period> &timer, const std::vector<cl::Event> *events = nullptr)
264  {
265  queue.enqueueNDRangeKernel (kernel, cl::NullRange, global, local, events, &timer.event ());
266  queue.flush (); timer.wait ();
267 
268  return timer.duration ();
269  }
270 
271  };
272 
273 
275  enum class CombineRGBConfig : uint8_t
276  {
277  FLOAT_FLOAT,
278  FLOAT_UCHAR
279  };
280 
281 
291  template <CombineRGBConfig C>
292  class CombineRGB;
293 
294 
321  template <>
323  {
324  public:
329  enum class Memory : uint8_t
330  {
331  H_IN_R,
332  H_IN_G,
333  H_IN_B,
334  H_OUT,
335  D_IN_R,
336  D_IN_G,
337  D_IN_B,
338  D_OUT
339  };
340 
342  CombineRGB (clutils::CLEnv &_env, clutils::CLEnvInfo<1> _info);
344  cl::Memory& get (CombineRGB::Memory mem);
346  void init (unsigned int _width, unsigned int _height, Staging _staging = Staging::IO);
348  void write (CombineRGB::Memory mem = CombineRGB::Memory::D_IN_R, void *ptr = nullptr, bool block = CL_FALSE,
349  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
351  void* read (CombineRGB::Memory mem = CombineRGB::Memory::H_OUT, bool block = CL_TRUE,
352  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
354  void run (const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
355 
356  cl_float *hPtrInR;
357  cl_float *hPtrInG;
358  cl_float *hPtrInB;
359  cl_float *hPtrOut;
361  private:
362  clutils::CLEnv &env;
363  clutils::CLEnvInfo<1> info;
364  cl::Context context;
365  cl::CommandQueue queue;
366  cl::Kernel kernel;
367  cl::NDRange global, local;
368  Staging staging;
369  size_t wgMultiple;
370  unsigned int width, height;
371  unsigned int bufferInSize, bufferOutSize;
372  cl::Buffer hBufferInR, hBufferInG, hBufferInB, hBufferOut;
373  cl::Buffer dBufferInR, dBufferInG, dBufferInB, dBufferOut;
374 
375  public:
383  template <typename period>
384  double run (clutils::GPUTimer<period> &timer, const std::vector<cl::Event> *events = nullptr)
385  {
386  queue.enqueueNDRangeKernel (kernel, cl::NullRange, global, local, events, &timer.event ());
387  queue.flush (); timer.wait ();
388 
389  return timer.duration ();
390  }
391 
392  };
393 
394 
423  template <>
425  {
426  public:
431  enum class Memory : uint8_t
432  {
433  H_IN_R,
434  H_IN_G,
435  H_IN_B,
436  H_OUT,
437  D_IN_R,
438  D_IN_G,
439  D_IN_B,
440  D_OUT
441  };
442 
444  CombineRGB (clutils::CLEnv &_env, clutils::CLEnvInfo<1> _info);
446  cl::Memory& get (CombineRGB::Memory mem);
448  void init (unsigned int _width, unsigned int _height, Staging _staging = Staging::IO);
450  void write (CombineRGB::Memory mem = CombineRGB::Memory::D_IN_R,
451  void *ptr = nullptr, bool block = CL_FALSE,
452  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
454  void* read (CombineRGB::Memory mem = CombineRGB::Memory::H_OUT, bool block = CL_TRUE,
455  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
457  void run (const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
458 
459  cl_float *hPtrInR;
460  cl_float *hPtrInG;
461  cl_float *hPtrInB;
462  cl_uchar *hPtrOut;
464  private:
465  clutils::CLEnv &env;
466  clutils::CLEnvInfo<1> info;
467  cl::Context context;
468  cl::CommandQueue queue;
469  cl::Kernel kernel;
470  cl::NDRange global, local;
471  Staging staging;
472  size_t wgMultiple;
473  unsigned int width, height;
474  unsigned int bufferInSize, bufferOutSize;
475  cl::Buffer hBufferInR, hBufferInG, hBufferInB, hBufferOut;
476  cl::Buffer dBufferInR, dBufferInG, dBufferInB, dBufferOut;
477 
478  public:
486  template <typename period>
487  double run (clutils::GPUTimer<period> &timer, const std::vector<cl::Event> *events = nullptr)
488  {
489  queue.enqueueNDRangeKernel (kernel, cl::NullRange, global, local, events, &timer.event ());
490  queue.flush (); timer.wait ();
491 
492  return timer.duration ();
493  }
494 
495  };
496 
497 
499  enum class DepthConfig : uint8_t
500  {
501  USHORT_FLOAT
502  };
503 
504 
514  template <DepthConfig C>
515  class Depth;
516 
517 
541  template <>
543  {
544  public:
549  enum class Memory : uint8_t
550  {
551  H_IN,
552  H_OUT,
553  D_IN,
554  D_OUT
555  };
556 
558  Depth (clutils::CLEnv &_env, clutils::CLEnvInfo<1> _info);
560  cl::Memory& get (Depth::Memory mem);
562  void init (unsigned int _width, unsigned int _height, float _scaling = 1.f, Staging _staging = Staging::IO);
564  void write (Depth::Memory mem = Depth::Memory::D_IN, void *ptr = nullptr, bool block = CL_FALSE,
565  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
567  void* read (Depth::Memory mem = Depth::Memory::H_OUT, bool block = CL_TRUE,
568  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
570  void run (const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
572  float getScaling ();
574  void setScaling (float _scaling);
575 
576  cl_ushort *hPtrIn;
577  cl_float *hPtrOut;
579  private:
580  clutils::CLEnv &env;
581  clutils::CLEnvInfo<1> info;
582  cl::Context context;
583  cl::CommandQueue queue;
584  cl::Kernel kernel;
585  cl::NDRange global;
586  Staging staging;
587  unsigned int length;
588  unsigned int bufferInSize, bufferOutSize;
589  float scaling;
590  cl::Buffer hBufferIn, hBufferOut;
591  cl::Buffer dBufferIn, dBufferOut;
592 
593  public:
601  template <typename period>
602  double run (clutils::GPUTimer<period> &timer, const std::vector<cl::Event> *events = nullptr)
603  {
604  queue.enqueueNDRangeKernel (kernel, cl::NullRange, global, cl::NullRange, events, &timer.event ());
605  queue.flush (); timer.wait ();
606 
607  return timer.duration ();
608  }
609 
610  };
611 
612 
634  class DepthTo3D
635  {
636  public:
641  enum class Memory : uint8_t
642  {
643  H_IN,
644  H_OUT,
645  D_IN,
646  D_OUT
647  };
648 
650  DepthTo3D (clutils::CLEnv &_env, clutils::CLEnvInfo<1> _info);
652  cl::Memory& get (DepthTo3D::Memory mem);
654  void init (unsigned int _width, unsigned int _height,
655  float _f, float _scaling = 1.f, Staging _staging = Staging::IO);
657  void write (DepthTo3D::Memory mem = DepthTo3D::Memory::D_IN, void *ptr = nullptr, bool block = CL_FALSE,
658  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
660  void* read (DepthTo3D::Memory mem = DepthTo3D::Memory::H_OUT, bool block = CL_TRUE,
661  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
663  void run (const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
665  float getFocalLength ();
667  void setFocalLength (float _f);
669  float getScaling ();
671  void setScaling (float _scaling);
672 
673  cl_float *hPtrIn;
674  cl_float4 *hPtrOut;
676  private:
677  clutils::CLEnv &env;
678  clutils::CLEnvInfo<1> info;
679  cl::Context context;
680  cl::CommandQueue queue;
681  cl::Kernel kernel;
682  cl::NDRange global;
683  Staging staging;
684  unsigned int width, height;
685  unsigned int bufferInSize, bufferOutSize;
686  float f, scaling;
687  cl::Buffer hBufferIn, hBufferOut;
688  cl::Buffer dBufferIn, dBufferOut;
689 
690  public:
698  template <typename period>
699  double run (clutils::GPUTimer<period> &timer, const std::vector<cl::Event> *events = nullptr)
700  {
701  queue.enqueueNDRangeKernel (kernel, cl::NullRange, global, cl::NullRange, events, &timer.event ());
702  queue.flush (); timer.wait ();
703 
704  return timer.duration ();
705  }
706 
707  };
708 
709 
737  class RGBDTo8D
738  {
739  public:
744  enum class Memory : uint8_t
745  {
746  H_IN_D,
747  H_IN_R,
748  H_IN_G,
749  H_IN_B,
750  H_OUT,
751  D_IN_D,
752  D_IN_R,
753  D_IN_G,
754  D_IN_B,
755  D_OUT
756  };
757 
759  RGBDTo8D (clutils::CLEnv &_env, clutils::CLEnvInfo<1> _info);
761  cl::Memory& get (RGBDTo8D::Memory mem);
763  void init (unsigned int _width, unsigned int _height,
764  float _f, float _scaling = 1.f, int _rgbNorm = 0, Staging _staging = Staging::IO);
766  void write (RGBDTo8D::Memory mem = RGBDTo8D::Memory::D_IN_D, void *ptr = nullptr, bool block = CL_FALSE,
767  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
769  void* read (RGBDTo8D::Memory mem = RGBDTo8D::Memory::H_OUT, bool block = CL_TRUE,
770  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
772  void run (const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
774  float getFocalLength ();
776  void setFocalLength (float _f);
778  float getScaling ();
780  void setScaling (float _scaling);
782  int getRGBNorm ();
784  void setRGBNorm (int _rgbNorm);
785 
786  cl_float *hPtrInD;
787  cl_float *hPtrInR;
788  cl_float *hPtrInG;
789  cl_float *hPtrInB;
790  cl_float8 *hPtrOut;
792  private:
793  clutils::CLEnv &env;
794  clutils::CLEnvInfo<1> info;
795  cl::Context context;
796  cl::CommandQueue queue;
797  cl::Kernel kernel;
798  cl::NDRange global, local;
799  Staging staging;
800  size_t wgMultiple;
801  unsigned int width, height, points;
802  unsigned int bufferInSize, bufferOutSize;
803  float f, scaling;
804  int rgbNorm;
805  cl::Buffer hBufferInD, hBufferInR, hBufferInG, hBufferInB, hBufferOut;
806  cl::Buffer dBufferInD, dBufferInR, dBufferInG, dBufferInB, dBufferOut;
807 
808  public:
816  template <typename period>
817  double run (clutils::GPUTimer<period> &timer, const std::vector<cl::Event> *events = nullptr)
818  {
819  queue.enqueueNDRangeKernel (kernel, cl::NullRange, global, local, events, &timer.event ());
820  queue.flush (); timer.wait ();
821 
822  return timer.duration ();
823  }
824 
825  };
826 
827 
850  class SplitPC8D
851  {
852  public:
857  enum class Memory : uint8_t
858  {
859  H_IN,
860  H_OUT_PC4D,
861  H_OUT_RGBA,
862  D_IN,
863  D_OUT_PC4D,
864  D_OUT_RGBA
865  };
866 
868  SplitPC8D (clutils::CLEnv &_env, clutils::CLEnvInfo<1> _info);
870  cl::Memory& get (SplitPC8D::Memory mem);
872  void init (unsigned int _n, unsigned int _offset = 0, Staging _staging = Staging::IO);
874  void write (SplitPC8D::Memory mem = SplitPC8D::Memory::D_IN, void *ptr = nullptr, bool block = CL_FALSE,
875  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
877  void* read (SplitPC8D::Memory mem = SplitPC8D::Memory::H_OUT_PC4D, bool block = CL_TRUE,
878  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
880  void run (const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
882  unsigned int getOffset ();
884  void setOffset (unsigned int _offset);
885 
886  cl_float *hPtrIn;
887  cl_float *hPtrOutPC4D;
888  cl_float *hPtrOutRGBA;
890  private:
891  clutils::CLEnv &env;
892  clutils::CLEnvInfo<1> info;
893  cl::Context context;
894  cl::CommandQueue queue;
895  cl::Kernel kernel;
896  cl::NDRange global;
897  Staging staging;
898  unsigned int n, offset;
899  unsigned int bufferInSize, bufferOutSize;
900  cl::Buffer hBufferIn, hBufferOutPC4D, hBufferOutRGBA;
901  cl::Buffer dBufferIn, dBufferOutPC4D, dBufferOutRGBA;
902 
903  public:
911  template <typename period>
912  double run (clutils::GPUTimer<period> &timer, const std::vector<cl::Event> *events = nullptr)
913  {
914  queue.enqueueNDRangeKernel (kernel, cl::NullRange, global, cl::NullRange, events, &timer.event ());
915  queue.flush (); timer.wait ();
916 
917  return timer.duration ();
918  }
919 
920  };
921 
922 
943  class RGBNorm
944  {
945  public:
950  enum class Memory : uint8_t
951  {
952  H_IN,
953  H_OUT,
954  D_IN,
955  D_OUT
956  };
957 
959  RGBNorm (clutils::CLEnv &_env, clutils::CLEnvInfo<1> _info);
961  cl::Memory& get (RGBNorm::Memory mem);
963  void init (unsigned int _width, unsigned int _height, Staging _staging = Staging::IO);
965  void write (RGBNorm::Memory mem = RGBNorm::Memory::D_IN, void *ptr = nullptr, bool block = CL_FALSE,
966  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
968  void* read (RGBNorm::Memory mem = RGBNorm::Memory::H_OUT, bool block = CL_TRUE,
969  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
971  void run (const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
972 
973  cl_float *hPtrIn;
974  cl_float *hPtrOut;
976  private:
977  clutils::CLEnv &env;
978  clutils::CLEnvInfo<1> info;
979  cl::Context context;
980  cl::CommandQueue queue;
981  cl::Kernel kernel;
982  cl::NDRange global;
983  Staging staging;
984  unsigned int width, height, bufferSize;
985  cl::Buffer hBufferIn, hBufferOut;
986  cl::Buffer dBufferIn, dBufferOut;
987 
988  public:
996  template <typename period>
997  double run (clutils::GPUTimer<period> &timer, const std::vector<cl::Event> *events = nullptr)
998  {
999  queue.enqueueNDRangeKernel (kernel, cl::NullRange, global, cl::NullRange, events, &timer.event ());
1000  queue.flush (); timer.wait ();
1001 
1002  return timer.duration ();
1003  }
1004 
1005  };
1006 
1007 
1028  class Scan
1029  {
1030  public:
1035  enum class Memory : uint8_t
1036  {
1037  H_IN,
1038  H_OUT,
1039  D_IN,
1040  D_SUMS,
1041  D_OUT
1042  };
1043 
1045  Scan (clutils::CLEnv &_env, clutils::CLEnvInfo<1> _info);
1047  cl::Memory& get (Scan::Memory mem);
1049  void init (unsigned int _width, unsigned int _height, float _scaling = 1.f, Staging _staging = Staging::IO);
1051  void write (Scan::Memory mem = Scan::Memory::D_IN, void *ptr = nullptr, bool block = CL_FALSE,
1052  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
1054  void* read (Scan::Memory mem = Scan::Memory::H_OUT, bool block = CL_TRUE,
1055  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
1057  void run (const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
1059  float getScaling ();
1061  void setScaling (float _scaling);
1062 
1063  cl_float *hPtrIn;
1064  cl_float *hPtrOut;
1066  private:
1067  clutils::CLEnv &env;
1068  clutils::CLEnvInfo<1> info;
1069  cl::Context context;
1070  cl::CommandQueue queue;
1071  cl::Kernel kernelScan, kernelSumsScan, kernelAddSums;
1072  cl::NDRange globalScan, globalSumsScan, localScan;
1073  cl::NDRange globalAddSums, localAddSums, offsetAddSums;
1074  Staging staging;
1075  size_t wgMultiple, wgXdim;
1076  unsigned int width, height, bufferSize, bufferSumsSize;
1077  float scaling;
1078  cl::Buffer hBufferIn, hBufferOut;
1079  cl::Buffer dBufferIn, dBufferOut, dBufferSums;
1080 
1081  public:
1089  template <typename period>
1090  double run (clutils::GPUTimer<period> &timer, const std::vector<cl::Event> *events = nullptr)
1091  {
1092  double pTime;
1093 
1094  if (wgXdim == 1)
1095  {
1096  queue.enqueueNDRangeKernel (
1097  kernelScan, cl::NullRange, globalScan, localScan, events, &timer.event ());
1098  queue.flush (); timer.wait ();
1099  pTime = timer.duration ();
1100  }
1101  else
1102  {
1103  queue.enqueueNDRangeKernel (
1104  kernelScan, cl::NullRange, globalScan, localScan, events, &timer.event ());
1105  queue.flush (); timer.wait ();
1106  pTime = timer.duration ();
1107 
1108  queue.enqueueNDRangeKernel (
1109  kernelSumsScan, cl::NullRange, globalSumsScan, localScan, nullptr, &timer.event ());
1110  queue.flush (); timer.wait ();
1111  pTime += timer.duration ();
1112 
1113  queue.enqueueNDRangeKernel (
1114  kernelAddSums, offsetAddSums, globalAddSums, localAddSums, nullptr, &timer.event ());
1115  queue.flush (); timer.wait ();
1116  pTime += timer.duration ();
1117  }
1118 
1119  return pTime;
1120  }
1121 
1122  };
1123 
1124 
1146  {
1147  public:
1152  enum class Memory : uint8_t
1153  {
1154  H_IN,
1155  H_OUT,
1156  D_IN,
1157  D_OUT
1158  };
1159 
1161  Transpose (clutils::CLEnv &_env, clutils::CLEnvInfo<1> _info);
1163  cl::Memory& get (Transpose::Memory mem);
1165  void init (unsigned int _width, unsigned int _height, Staging _staging = Staging::IO);
1167  void write (Transpose::Memory mem = Transpose::Memory::D_IN, void *ptr = nullptr, bool block = CL_FALSE,
1168  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
1170  void* read (Transpose::Memory mem = Transpose::Memory::H_OUT, bool block = CL_TRUE,
1171  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
1173  void run (const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
1174 
1175  cl_float *hPtrIn;
1176  cl_float *hPtrOut;
1178  private:
1179  clutils::CLEnv &env;
1180  clutils::CLEnvInfo<1> info;
1181  cl::Context context;
1182  cl::CommandQueue queue;
1183  cl::Kernel kernel;
1184  cl::NDRange global, local;
1185  Staging staging;
1186  unsigned int width, height, bufferSize;
1187  cl::Buffer hBufferIn, hBufferOut;
1188  cl::Buffer dBufferIn, dBufferOut;
1189 
1190  public:
1198  template <typename period>
1199  double run (clutils::GPUTimer<period> &timer, const std::vector<cl::Event> *events = nullptr)
1200  {
1201  queue.enqueueNDRangeKernel (kernel, cl::NullRange, global, local, events, &timer.event ());
1202  queue.flush (); timer.wait ();
1203 
1204  return timer.duration ();
1205  }
1206 
1207  };
1208 
1209 
1231  class SAT
1232  {
1233  public:
1238  enum class Memory : uint8_t
1239  {
1240  H_IN,
1241  H_OUT,
1242  D_IN,
1243  D_OUT
1244  };
1245 
1247  SAT (clutils::CLEnv &_env, clutils::CLEnvInfo<1> _info, bool _transposed = true);
1249  cl::Memory& get (SAT::Memory mem);
1251  void init (unsigned int _width, unsigned int _height, float _scaling = 1.f, Staging _staging = Staging::IO);
1253  void write (SAT::Memory mem = SAT::Memory::D_IN, void *ptr = nullptr, bool block = CL_FALSE,
1254  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
1256  void* read (SAT::Memory mem = SAT::Memory::H_OUT, bool block = CL_TRUE,
1257  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
1259  void run (const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
1261  float getScaling ();
1263  void setScaling (float _scaling);
1264 
1265  cl_float *hPtrIn;
1266  cl_float *hPtrOut;
1268  private:
1269  clutils::CLEnv &env;
1270  clutils::CLEnvInfo<1> info;
1271  cl::Context context;
1272  cl::CommandQueue queue;
1273  Scan scanRows, scanColumns;
1274  Transpose transpose1, transpose2;
1275  Staging staging;
1276  unsigned int width, height, bufferSize;
1277  float scaling;
1278  bool transposed;
1279  cl::Buffer hBufferIn, hBufferOut;
1280 
1281  public:
1289  template <typename period>
1290  double run (clutils::GPUTimer<period> &timer, const std::vector<cl::Event> *events = nullptr)
1291  {
1292  double pTime;
1293 
1294  pTime = scanRows.run (timer, events);
1295  pTime += transpose1.run (timer);
1296  pTime += scanColumns.run (timer);
1297 
1298  if (!transposed)
1299  pTime += transpose2.run (timer);
1300 
1301  return pTime;
1302  }
1303 
1304  };
1305 
1306 
1328  {
1329  public:
1334  enum class Memory : uint8_t
1335  {
1336  H_IN,
1337  H_OUT,
1338  D_IN,
1339  D_OUT
1340  };
1341 
1343  BoxFilterSAT (clutils::CLEnv &_env, clutils::CLEnvInfo<1> _info);
1345  cl::Memory& get (BoxFilterSAT::Memory mem);
1347  void init (unsigned int _width, unsigned int _height,
1348  int _radius, float _scaling = 1e-4f, Staging _staging = Staging::IO);
1350  void write (BoxFilterSAT::Memory mem = BoxFilterSAT::Memory::D_IN, void *ptr = nullptr, bool block = CL_FALSE,
1351  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
1353  void* read (BoxFilterSAT::Memory mem = BoxFilterSAT::Memory::H_OUT, bool block = CL_TRUE,
1354  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
1356  void run (const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
1358  int getRadius ();
1360  void setRadius (int _radius);
1362  float getScaling ();
1364  void setScaling (float _scaling);
1365 
1366  cl_float *hPtrIn;
1367  cl_float *hPtrOut;
1369  private:
1370  static const unsigned int lXdim = 16;
1371  static const unsigned int lYdim = 16;
1372  clutils::CLEnv &env;
1373  clutils::CLEnvInfo<1> info;
1374  cl::Context context;
1375  cl::CommandQueue queue;
1376  cl::Kernel kernel;
1377  cl::NDRange global, local;
1378  Staging staging;
1379  unsigned int width, height, bufferSize;
1380  int radius;
1381  float scaling;
1382  SAT sat;
1383  cl::Buffer hBufferIn, hBufferOut;
1384  cl::Buffer dBufferOut;
1385 
1386  public:
1394  template <typename period>
1395  double run (clutils::GPUTimer<period> &timer, const std::vector<cl::Event> *events = nullptr)
1396  {
1397  double pTime;
1398 
1399  pTime = sat.run (timer, events);
1400 
1401  queue.enqueueNDRangeKernel (
1402  kernel, cl::NullRange, global, local, nullptr, &timer.event ());
1403  queue.flush (); timer.wait ();
1404  pTime += timer.duration ();
1405 
1406  return pTime;
1407  }
1408 
1409  };
1410 
1411 
1433  {
1434  public:
1439  enum class Memory : uint8_t
1440  {
1441  H_IN,
1442  H_OUT,
1443  D_IN,
1444  D_OUT
1445  };
1446 
1448  BoxFilter (clutils::CLEnv &_env, clutils::CLEnvInfo<1> _info);
1450  cl::Memory& get (BoxFilter::Memory mem);
1452  void init (unsigned int _width, unsigned int _height, int _radius, Staging _staging = Staging::IO);
1454  void write (BoxFilter::Memory mem = BoxFilter::Memory::D_IN, void *ptr = nullptr, bool block = CL_FALSE,
1455  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
1457  void* read (BoxFilter::Memory mem = BoxFilter::Memory::H_OUT, bool block = CL_TRUE,
1458  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
1460  void run (const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
1462  int getRadius ();
1464  void setRadius (int _radius);
1465 
1466  cl_float *hPtrIn;
1467  cl_float *hPtrOut;
1469  private:
1470  static const unsigned int lXdim = 16;
1471  static const unsigned int lYdim = 16;
1472  clutils::CLEnv &env;
1473  clutils::CLEnvInfo<1> info;
1474  cl::Context context;
1475  cl::CommandQueue queue;
1476  cl::Kernel kernel;
1477  cl::NDRange global, local;
1478  Staging staging;
1479  unsigned int width, height, bufferSize;
1480  int radius;
1481  cl::Buffer hBufferIn, hBufferOut;
1482  cl::Buffer dBufferIn, dBufferOut;
1483 
1484  public:
1492  template <typename period>
1493  double run (clutils::GPUTimer<period> &timer, const std::vector<cl::Event> *events = nullptr)
1494  {
1495  queue.enqueueNDRangeKernel (
1496  kernel, cl::NullRange, global, local, nullptr, &timer.event ());
1497  queue.flush (); timer.wait ();
1498 
1499  return timer.duration ();
1500  }
1501 
1502  };
1503 
1504 
1506  enum class GuidedFilterConfig : uint8_t
1507  {
1508  I_NEQ_P,
1509  I_EQ_P
1510  };
1511 
1512 
1525  template <GuidedFilterConfig Ip>
1527 
1528 
1550  template <>
1552  {
1553  public:
1558  enum class Memory : uint8_t
1559  {
1560  H_IN,
1561  H_OUT,
1562  D_IN,
1563  D_OUT,
1564  D_A,
1565  D_B
1566  };
1567 
1569  GuidedFilter (clutils::CLEnv &_env, clutils::CLEnvInfo<2> _info);
1571  cl::Memory& get (GuidedFilter::Memory mem);
1573  void init (unsigned int _width, unsigned int _height, int _radius, float _eps, int _zero_out = 0,
1574  float _boxScaling = 1e-4f, float _outputScaling = 1.f, Staging _staging = Staging::IO);
1576  void write (GuidedFilter::Memory mem = GuidedFilter::Memory::D_IN, void *ptr = nullptr, bool block = CL_FALSE,
1577  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
1579  void* read (GuidedFilter::Memory mem = GuidedFilter::Memory::H_OUT, bool block = CL_TRUE,
1580  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
1582  void run (const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
1584  int getRadius ();
1586  void setRadius (int _radius);
1588  float getEps ();
1590  void setEps (float _eps);
1592  float getBoxScaling ();
1594  void setBoxScaling (float _boxScaling);
1596  float getOutputScaling ();
1598  void setOutputScaling (float _outputScaling);
1600  int getZeroing ();
1602  void setZeroing (int _zero_out);
1603 
1604  cl_float *hPtrIn;
1605  cl_float *hPtrOut;
1607  private:
1608  clutils::CLEnv &env;
1609  clutils::CLEnvInfo<2> info;
1610  cl::Context context;
1611  cl::CommandQueue queue0;
1612  BoxFilterSAT mean_p, mean_p2, mean_a, mean_b;
1613  Math::Pown squared;
1614  cl::Kernel ab, q;
1615  cl::NDRange global;
1616  Staging staging;
1617  unsigned int width, height, bufferSize;
1618  int radius; float eps;
1619  int zero_out;
1620  float boxScaling, outputScaling;
1621  cl::Buffer hBufferIn, hBufferOut;
1622  cl::Buffer dBufferIn, dBufferOut;
1623  cl::Buffer dBufferOutA, dBufferOutB;
1624  cl::Event p2Event, abEvent, mbEvent;
1625  std::vector<cl::Event> waitListAB, waitListMB, waitListQ;
1626 
1627  public:
1642  template <typename period>
1643  double run (clutils::GPUTimer<period> &timer, const std::vector<cl::Event> *events = nullptr)
1644  {
1645  double pTime;
1646 
1647  pTime = mean_p.run (timer, events);
1648  pTime += squared.run (timer);
1649  pTime += mean_p2.run (timer);
1650 
1651  queue0.enqueueNDRangeKernel (ab, cl::NullRange, global, cl::NullRange, nullptr, &timer.event ());
1652  queue0.flush (); timer.wait ();
1653  pTime += timer.duration ();
1654 
1655  pTime += mean_a.run (timer);
1656  pTime += mean_b.run (timer);
1657 
1658  queue0.enqueueNDRangeKernel (q, cl::NullRange, global, cl::NullRange, nullptr, &timer.event ());
1659  queue0.flush (); timer.wait ();
1660  pTime += timer.duration ();
1661 
1662  return pTime;
1663  }
1664 
1665  };
1666 
1667 
1691  template <>
1693  {
1694  public:
1699  enum class Memory : uint8_t
1700  {
1701  H_IN_I,
1702  H_IN_P,
1703  H_OUT,
1704  D_IN_I,
1705  D_IN_P,
1706  D_OUT,
1707  D_VAR_I,
1708  D_COV_IP,
1709  D_A,
1710  D_B
1711  };
1712 
1714  GuidedFilter (clutils::CLEnv &_env, clutils::CLEnvInfo<2> _info);
1716  cl::Memory& get (GuidedFilter::Memory mem);
1718  void init (unsigned int _width, unsigned int _height, int _radius, float _eps,
1719  int _zero_out = 0, float _boxScaling = 1e-4f, Staging _staging = Staging::IO);
1721  void write (GuidedFilter::Memory mem = GuidedFilter::Memory::D_IN_I, void *ptr = nullptr, bool block = CL_FALSE,
1722  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
1724  void* read (GuidedFilter::Memory mem = GuidedFilter::Memory::H_OUT, bool block = CL_TRUE,
1725  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
1727  void run (const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
1729  int getRadius ();
1731  void setRadius (int _radius);
1733  float getEps ();
1735  void setEps (float _eps);
1737  float getBoxScaling ();
1739  void setBoxScaling (float _boxScaling);
1741  int getZeroing ();
1743  void setZeroing (int _zero_out);
1744 
1745  cl_float *hPtrInI;
1746  cl_float *hPtrInP;
1747  cl_float *hPtrOut;
1749  private:
1750  clutils::CLEnv &env;
1751  clutils::CLEnvInfo<2> info;
1752  cl::Context context;
1753  cl::CommandQueue queue0;
1754  BoxFilterSAT mean_I, mean_p, corr_I, corr_Ip, mean_a, mean_b;
1755  Math::Mult mult_II, mult_Ip;
1756  cl::Kernel var, ab, q;
1757  cl::NDRange global;
1758  Staging staging;
1759  unsigned int width, height, bufferSize;
1760  int radius; float eps;
1761  int zero_out;
1762  float boxScaling;
1763  cl::Buffer hBufferInI, hBufferInP, hBufferOut;
1764  cl::Buffer dBufferInI, dBufferInP, dBufferOut;
1765  cl::Buffer dBufferOutVarI, dBufferOutCovIp;
1766  cl::Buffer dBufferOutA, dBufferOutB;
1767  cl::Event corrIpEvent, abEvent, mbEvent;
1768  std::vector<cl::Event> waitListVar, waitListMB, waitListQ;
1769 
1770  public:
1785  template <typename period>
1786  double run (clutils::GPUTimer<period> &timer, const std::vector<cl::Event> *events = nullptr)
1787  {
1788  double pTime;
1789 
1790  pTime = mean_I.run (timer, events);
1791  pTime += mean_p.run (timer, events);
1792  pTime += mult_II.run (timer, events);
1793  pTime += mult_Ip.run (timer, events);
1794  pTime += corr_I.run (timer);
1795  pTime += corr_Ip.run (timer);
1796 
1797  queue0.enqueueNDRangeKernel (var, cl::NullRange, global, cl::NullRange, nullptr, &timer.event ());
1798  queue0.flush (); timer.wait ();
1799  pTime += timer.duration ();
1800 
1801  queue0.enqueueNDRangeKernel (ab, cl::NullRange, global, cl::NullRange, nullptr, &timer.event ());
1802  queue0.flush (); timer.wait ();
1803  pTime += timer.duration ();
1804 
1805  pTime += mean_a.run (timer);
1806  pTime += mean_b.run (timer);
1807 
1808  queue0.enqueueNDRangeKernel (q, cl::NullRange, global, cl::NullRange, nullptr, &timer.event ());
1809  queue0.flush (); timer.wait ();
1810  pTime += timer.duration ();
1811 
1812  return pTime;
1813  }
1814 
1815  };
1816 
1817 
1821  namespace Kinect
1822  {
1823 
1825  enum class GuidedFilterRGBConfig : uint8_t
1826  {
1829  SEPARATED
1831  };
1832 
1833 
1841  template <GuidedFilterRGBConfig C>
1843 
1844 
1871  template <>
1873  {
1874  public:
1879  enum class Memory : uint8_t
1880  {
1881  H_IN,
1882  H_OUT_R,
1883  H_OUT_G,
1884  H_OUT_B,
1885  D_IN,
1886  D_INTR_R,
1887  D_INTR_G,
1888  D_INTR_B,
1889  D_OUT_R,
1890  D_OUT_G,
1891  D_OUT_B
1892  };
1893 
1895  GuidedFilterRGB (clutils::CLEnv &_env, clutils::CLEnvInfo<2> _info);
1897  cl::Memory& get (GuidedFilterRGB::Memory mem);
1899  void init (unsigned int _width, unsigned int _height,
1900  int _radius, float _eps, Staging _staging = Staging::IO);
1902  void write (GuidedFilterRGB::Memory mem = GuidedFilterRGB::Memory::D_IN, void *ptr = nullptr,
1903  bool block = CL_FALSE, const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
1905  void* read (GuidedFilterRGB::Memory mem = GuidedFilterRGB::Memory::H_OUT_R, bool block = CL_TRUE,
1906  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
1908  void run (const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
1910  int getRadius ();
1912  void setRadius (int _radius);
1914  float getEps ();
1916  void setEps (float _eps);
1917 
1918  cl_uchar *hPtrIn;
1919  cl_float *hPtrOutR;
1920  cl_float *hPtrOutG;
1921  cl_float *hPtrOutB;
1923  private:
1924  clutils::CLEnv &env;
1925  clutils::CLEnvInfo<2> info;
1926  cl::Context context;
1927  cl::CommandQueue queue0;
1930  Staging staging;
1931  unsigned int width, height;
1932  unsigned int bufferInSize, bufferOutSize;
1933  int radius; float eps;
1934  cl::Buffer hBufferIn, hBufferOutR, hBufferOutG, hBufferOutB;
1935  cl::Buffer dBufferIn, dBufferOutR, dBufferOutG, dBufferOutB;
1936  cl::Event sEvent; std::vector<cl::Event> waitList;
1937 
1938  public:
1946  template <typename period>
1947  double run (clutils::GPUTimer<period> &timer, const std::vector<cl::Event> *events = nullptr)
1948  {
1949  double pTime;
1950 
1951  pTime = sRGB.run (timer, events);
1952  pTime += gfR.run (timer);
1953  pTime += gfG.run (timer);
1954  pTime += gfB.run (timer);
1955 
1956  return pTime;
1957  }
1958 
1959  };
1960 
1961 
1984  template <>
1986  {
1987  public:
1992  enum class Memory : uint8_t
1993  {
1994  H_IN,
1995  H_OUT,
1996  D_IN,
1997  D_INTR_R,
1998  D_INTR_G,
1999  D_INTR_B,
2000  D_OUT
2001  };
2002 
2004  GuidedFilterRGB (clutils::CLEnv &_env, clutils::CLEnvInfo<2> _info);
2006  cl::Memory& get (GuidedFilterRGB::Memory mem);
2008  void init (unsigned int _width, unsigned int _height,
2009  int _radius, float _eps, Staging _staging = Staging::IO);
2011  void write (GuidedFilterRGB::Memory mem = GuidedFilterRGB::Memory::D_IN, void *ptr = nullptr,
2012  bool block = CL_FALSE, const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
2014  void* read (GuidedFilterRGB::Memory mem = GuidedFilterRGB::Memory::H_OUT, bool block = CL_TRUE,
2015  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
2017  void run (const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
2019  int getRadius ();
2021  void setRadius (int _radius);
2023  float getEps ();
2025  void setEps (float _eps);
2026 
2027  cl_uchar *hPtrIn;
2028  cl_float *hPtrOut;
2030  private:
2031  clutils::CLEnv &env;
2032  clutils::CLEnvInfo<2> info;
2033  cl::Context context;
2034  cl::CommandQueue queue0;
2038  Staging staging;
2039  unsigned int width, height;
2040  unsigned int bufferInSize, bufferOutSize;
2041  int radius; float eps;
2042  cl::Buffer hBufferIn, hBufferOut;
2043  cl::Buffer dBufferIn, dBufferOut;
2044  cl::Event sEvent; std::vector<cl::Event> waitList;
2045 
2046  public:
2054  template <typename period>
2055  double run (clutils::GPUTimer<period> &timer, const std::vector<cl::Event> *events = nullptr)
2056  {
2057  double pTime;
2058 
2059  pTime = sRGB.run (timer, events);
2060  pTime += gfR.run (timer);
2061  pTime += gfG.run (timer);
2062  pTime += gfB.run (timer);
2063  pTime = cRGB.run (timer);
2064 
2065  return pTime;
2066  }
2067 
2068  };
2069 
2070 
2091  {
2092  public:
2097  enum class Memory : uint8_t
2098  {
2099  H_IN,
2100  H_OUT,
2101  D_IN,
2102  D_OUT
2103  };
2104 
2106  GuidedFilterDepth (clutils::CLEnv &_env, clutils::CLEnvInfo<2> _info);
2108  cl::Memory& get (GuidedFilterDepth::Memory mem);
2110  void init (unsigned int _width, unsigned int _height,
2111  int _radius, float _eps, float _dScaling = 1e-3f, Staging _staging = Staging::IO);
2114  void *ptr = nullptr, bool block = CL_FALSE,
2115  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
2117  void* read (GuidedFilterDepth::Memory mem = GuidedFilterDepth::Memory::H_OUT, bool block = CL_TRUE,
2118  const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
2120  void run (const std::vector<cl::Event> *events = nullptr, cl::Event *event = nullptr);
2122  int getRadius ();
2124  void setRadius (int _radius);
2126  float getEps ();
2128  void setEps (float _eps);
2130  float getDScaling ();
2132  void setDScaling (float _dScaling);
2133 
2134  cl_ushort *hPtrIn;
2135  cl_float *hPtrOut;
2137  private:
2138  clutils::CLEnv &env;
2139  clutils::CLEnvInfo<2> info;
2140  cl::Context context;
2141  cl::CommandQueue queue0;
2144  Staging staging;
2145  unsigned int width, height;
2146  unsigned int bufferInSize, bufferOutSize;
2147  int radius; float eps; float dScaling;
2148  cl::Buffer hBufferIn, hBufferOut;
2149  cl::Buffer dBufferIn, dBufferOut;
2150  cl::Event dEvent; std::vector<cl::Event> waitList;
2151 
2152  public:
2160  template <typename period>
2161  double run (clutils::GPUTimer<period> &timer, const std::vector<cl::Event> *events = nullptr)
2162  {
2163  double pTime;
2164 
2165  pTime = depth.run (timer, events);
2166  pTime += gf.run (timer);
2167 
2168  return pTime;
2169  }
2170 
2171  };
2172 
2173  }
2174 
2175 }
2176 }
2177 
2178 #endif // GF_ALGORITHMS_HPP
void init(unsigned int _width, unsigned int _height, Staging _staging=Staging::IO)
Configures kernel execution parameters.
Definition: algorithms.cpp:2489
Transpose(clutils::CLEnv &_env, clutils::CLEnvInfo< 1 > _info)
Configures an OpenCL environment as specified by _info.
Definition: algorithms.cpp:2450
cl_uchar * hPtrIn
Definition: algorithms.hpp:235
void run(const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Executes the necessary kernels.
Definition: algorithms.cpp:1700
cl_float * hPtrOutPC4D
Definition: algorithms.hpp:887
int getRadius()
Gets the filter window radius.
Definition: algorithms.cpp:3138
cl_float * hPtrIn
Definition: algorithms.hpp:973
void * read(GuidedFilterDepth::Memory mem=GuidedFilterDepth::Memory::H_OUT, bool block=CL_TRUE, const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Performs a data transfer to a staging buffer.
Definition: algorithms.cpp:4893
cl_float * hPtrOutG
Definition: algorithms.hpp:237
unsigned int getOffset()
Gets the offset.
Definition: algorithms.cpp:1968
Memory
Enumerates the memory objects handled by the class.
Definition: algorithms.hpp:1879
Interface class for the Guided Filter pipeline.
Definition: algorithms.hpp:1551
cl_float * hPtrOut
Definition: algorithms.hpp:1467
GuidedFilterConfig
Enumerates configurations for the Guided Filter algorithm.
Definition: algorithms.hpp:1506
cl_float * hPtrInB
Definition: algorithms.hpp:358
void run(const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Executes the necessary kernels.
Definition: algorithms.cpp:3677
cl_float * hPtrOut
Definition: algorithms.hpp:1064
void * read(Scan::Memory mem=Scan::Memory::H_OUT, bool block=CL_TRUE, const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Performs a data transfer to a staging buffer.
Definition: algorithms.cpp:2384
void setRadius(int _radius)
Sets the filter window radius.
Definition: algorithms.cpp:3431
Interface class for the rgbNorm kernel.
Definition: algorithms.hpp:943
void * read(SAT::Memory mem=SAT::Memory::H_OUT, bool block=CL_TRUE, const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Performs a data transfer to a staging buffer.
Definition: algorithms.cpp:2823
void write(GuidedFilterDepth::Memory mem=GuidedFilterDepth::Memory::D_IN, void *ptr=nullptr, bool block=CL_FALSE, const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Performs a data transfer to a device buffer.
Definition: algorithms.cpp:4864
double run(clutils::GPUTimer< period > &timer, const std::vector< cl::Event > *events=nullptr)
Executes the necessary kernels.
Definition: algorithms.hpp:1493
void run(const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Executes the necessary kernels.
Definition: algorithms.cpp:2162
float getScaling()
Gets the scaling factor.
Definition: algorithms.cpp:3156
void write(BoxFilterSAT::Memory mem=BoxFilterSAT::Memory::D_IN, void *ptr=nullptr, bool block=CL_FALSE, const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Performs a data transfer to a device buffer.
Definition: algorithms.cpp:3077
Scan(clutils::CLEnv &_env, clutils::CLEnvInfo< 1 > _info)
Configures an OpenCL environment as specified by _info.
Definition: algorithms.cpp:2171
void write(Transpose::Memory mem=Transpose::Memory::D_IN, void *ptr=nullptr, bool block=CL_FALSE, const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Performs a data transfer to a device buffer.
Definition: algorithms.cpp:2598
void init(unsigned int _width, unsigned int _height, float _scaling=1.f, Staging _staging=Staging::IO)
Configures kernel execution parameters.
Definition: algorithms.cpp:2708
cl_float * hPtrInB
Definition: algorithms.hpp:789
double run(clutils::GPUTimer< period > &timer, const std::vector< cl::Event > *events=nullptr)
Executes the necessary kernels.
Definition: algorithms.hpp:1395
void run(const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Executes the necessary kernels.
Definition: algorithms.cpp:515
void run(const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Executes the necessary kernels.
Definition: algorithms.cpp:1960
Interface class for the splitPC8D kernel.
Definition: algorithms.hpp:850
cl_float * hPtrOut
Definition: algorithms.hpp:1605
Interface class for the mult kernel.
Definition: math.hpp:73
Interface class for the transpose kernel.
Definition: algorithms.hpp:1145
cl_float * hPtrOutB
Definition: algorithms.hpp:136
void run(const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Executes the necessary kernels.
Definition: algorithms.cpp:3129
double run(clutils::GPUTimer< period > &timer, const std::vector< cl::Event > *events=nullptr)
Executes the necessary kernels.
Definition: algorithms.hpp:1643
Interface class for the Guided Filter algorithm.
Definition: algorithms.hpp:1526
Interface class for the pown_ kernel.
Definition: math.hpp:160
void write(RGBNorm::Memory mem=RGBNorm::Memory::D_IN, void *ptr=nullptr, bool block=CL_FALSE, const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Performs a data transfer to a device buffer.
Definition: algorithms.cpp:2111
void write(SAT::Memory mem=SAT::Memory::D_IN, void *ptr=nullptr, bool block=CL_FALSE, const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Performs a data transfer to a device buffer.
Definition: algorithms.cpp:2794
void * read(BoxFilter::Memory mem=BoxFilter::Memory::H_OUT, bool block=CL_TRUE, const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Performs a data transfer to a staging buffer.
Definition: algorithms.cpp:3390
cl_float * hPtrOutB
Definition: algorithms.hpp:238
cl_float * hPtrIn
Definition: algorithms.hpp:1604
Staging
Enumerates staging buffer configurations.
Definition: common.hpp:43
void init(unsigned int _width, unsigned int _height, int _radius, float _scaling=1e-4f, Staging _staging=Staging::IO)
Configures kernel execution parameters.
Definition: algorithms.cpp:2975
Memory
Enumerates the memory objects handled by the class.
Definition: algorithms.hpp:1035
cl_ushort * hPtrIn
Definition: algorithms.hpp:576
void setEps(float _eps)
Sets the regularization parameter .
Definition: algorithms.cpp:4954
cl_float * hPtrInG
Definition: algorithms.hpp:357
BoxFilter(clutils::CLEnv &_env, clutils::CLEnvInfo< 1 > _info)
Configures an OpenCL environment as specified by _info.
Definition: algorithms.cpp:3177
void * read(DepthTo3D::Memory mem=DepthTo3D::Memory::H_OUT, bool block=CL_TRUE, const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Performs a data transfer to a staging buffer.
Definition: algorithms.cpp:1371
GuidedFilterRGBConfig
Enumerates configurations for the GuidedFilterRGB class.
Definition: algorithms.hpp:1825
void init(unsigned int _width, unsigned int _height, int _radius, Staging _staging=Staging::IO)
Configures kernel execution parameters.
Definition: algorithms.cpp:3262
void setScaling(float _scaling)
Sets the scaling factor.
Definition: algorithms.cpp:3166
cl_float * hPtrIn
Definition: algorithms.hpp:886
cl_float * hPtrIn
Definition: algorithms.hpp:1175
Offers classes which set up kernel execution parameters and provide interfaces for the handling of me...
Definition: algorithms.hpp:43
Interface class for the separateRGBChannels kernels.
Definition: algorithms.hpp:68
void setScaling(float _scaling)
Sets the scaling factor.
Definition: algorithms.cpp:1431
float getEps()
Gets the regularization parameter .
Definition: algorithms.cpp:4944
float getScaling()
Gets the scaling factor.
Definition: algorithms.cpp:1725
Memory
Enumerates the memory objects handled by the class.
Definition: algorithms.hpp:2097
void setScaling(float _scaling)
Sets the scaling factor.
Definition: algorithms.cpp:1735
cl_float * hPtrOut
Definition: algorithms.hpp:974
CombineRGBConfig
Enumerates configurations for the CombineRGB class.
Definition: algorithms.hpp:275
cl_float * hPtrInB
Definition: algorithms.hpp:461
Declares classes used by the OpenCL interface classes in cl_algo.
double run(clutils::GPUTimer< period > &timer, const std::vector< cl::Event > *events=nullptr)
Executes the necessary kernels.
Definition: algorithms.hpp:1947
void init(unsigned int _n, unsigned int _offset=0, Staging _staging=Staging::IO)
Configures kernel execution parameters.
Definition: algorithms.cpp:1810
cl_float * hPtrOut
Definition: algorithms.hpp:1266
double run(clutils::GPUTimer< period > &timer, const std::vector< cl::Event > *events=nullptr)
Executes the necessary kernels.
Definition: algorithms.hpp:1786
void write(BoxFilter::Memory mem=BoxFilter::Memory::D_IN, void *ptr=nullptr, bool block=CL_FALSE, const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Performs a data transfer to a device buffer.
Definition: algorithms.cpp:3362
cl_float * hPtrInI
Definition: algorithms.hpp:1745
void run(const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Executes the necessary kernels.
Definition: algorithms.cpp:2407
void setScaling(float _scaling)
Sets the scaling factor.
Definition: algorithms.cpp:2440
void init(unsigned int _width, unsigned int _height, Staging _staging=Staging::IO)
Configures kernel execution parameters.
Definition: algorithms.cpp:2027
double run(clutils::GPUTimer< period > &timer, const std::vector< cl::Event > *events=nullptr)
Executes the necessary kernels.
Definition: algorithms.hpp:699
Memory
Enumerates the memory objects handled by the class.
Definition: algorithms.hpp:106
double run(clutils::GPUTimer< period > &timer, const std::vector< cl::Event > *events=nullptr)
Executes the necessary kernels.
Definition: algorithms.hpp:1199
Memory
Enumerates the memory objects handled by the class.
Definition: algorithms.hpp:329
void * read(RGBDTo8D::Memory mem=RGBDTo8D::Memory::H_OUT, bool block=CL_TRUE, const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Performs a data transfer to a staging buffer.
Definition: algorithms.cpp:1677
void run(const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Executes the necessary kernels.
Definition: math.cpp:442
Memory
Enumerates the memory objects handled by the class.
Definition: algorithms.hpp:641
void * read(BoxFilterSAT::Memory mem=BoxFilterSAT::Memory::H_OUT, bool block=CL_TRUE, const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Performs a data transfer to a staging buffer.
Definition: algorithms.cpp:3106
cl_ushort * hPtrIn
Definition: algorithms.hpp:2134
Interface class for the combineRGBChannels_Float2Float kernel.
Definition: algorithms.hpp:322
void init(unsigned int _width, unsigned int _height, int _radius, float _eps, float _dScaling=1e-3f, Staging _staging=Staging::IO)
Configures kernel execution parameters.
Definition: algorithms.cpp:4785
void setDScaling(float _dScaling)
Sets the depth scaling factor.
Definition: algorithms.cpp:4973
void setRGBNorm(int _rgbNorm)
Sets the flag for RGB normalization.
Definition: algorithms.cpp:1753
cl_float * hPtrInG
Definition: algorithms.hpp:460
void run(const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Executes the necessary kernels.
Definition: algorithms.cpp:756
Interface class for the scan kernel.
Definition: algorithms.hpp:1028
double run(clutils::GPUTimer< period > &timer, const std::vector< cl::Event > *events=nullptr)
Executes the necessary kernels.
Definition: algorithms.hpp:817
Declares classes that organize the execution of OpenCL math kernels.
Memory
Enumerates the memory objects handled by the class.
Definition: algorithms.hpp:1992
double run(clutils::GPUTimer< period > &timer, const std::vector< cl::Event > *events=nullptr)
Executes the necessary kernels.
Definition: algorithms.hpp:487
Memory
Enumerates the memory objects handled by the class.
Definition: algorithms.hpp:857
cl_float * hPtrInR
Definition: algorithms.hpp:459
void setOffset(unsigned int _offset)
Sets the offset.
Definition: algorithms.cpp:1978
Memory
Enumerates the memory objects handled by the class.
Definition: algorithms.hpp:1334
Memory
Enumerates the memory objects handled by the class.
Definition: algorithms.hpp:549
cl_float * hPtrOutR
Definition: algorithms.hpp:134
void * read(RGBNorm::Memory mem=RGBNorm::Memory::H_OUT, bool block=CL_TRUE, const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Performs a data transfer to a staging buffer.
Definition: algorithms.cpp:2139
cl_float * hPtrOut
Definition: algorithms.hpp:359
void setScaling(float _scaling)
Sets the scaling factor.
Definition: algorithms.cpp:2874
cl_float * hPtrOut
Definition: algorithms.hpp:577
void setRadius(int _radius)
Sets the filter window radius.
Definition: algorithms.cpp:3148
void init(unsigned int _width, unsigned int _height, float _scaling=1.f, Staging _staging=Staging::IO)
Configures kernel execution parameters.
Definition: algorithms.cpp:2219
cl_float * hPtrIn
Definition: algorithms.hpp:1265
void setFocalLength(float _f)
Sets the focal length.
Definition: algorithms.cpp:1412
Interface class for the combineRGBChannels kernels.
Definition: algorithms.hpp:292
cl_float * hPtrOut
Definition: algorithms.hpp:1176
cl_float * hPtrIn
Definition: algorithms.hpp:1466
Interface class for the depth_Ushort2Float kernel.
Definition: algorithms.hpp:542
void run(const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Executes the necessary kernels.
Definition: algorithms.cpp:2851
double run(clutils::GPUTimer< period > &timer, const std::vector< cl::Event > *events=nullptr)
Executes the necessary kernels.
Definition: algorithms.hpp:161
void run(const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Executes the necessary kernels.
Definition: algorithms.cpp:3413
cl_float * hPtrOutRGBA
Definition: algorithms.hpp:888
Interface class for the boxFilter kernel.
Definition: algorithms.hpp:1432
Interface class for the depthTo3D kernel.
Definition: algorithms.hpp:634
RGBNorm(clutils::CLEnv &_env, clutils::CLEnvInfo< 1 > _info)
Configures an OpenCL environment as specified by _info.
Definition: algorithms.cpp:1988
Memory
Enumerates the memory objects handled by the class.
Definition: algorithms.hpp:744
double run(clutils::GPUTimer< period > &timer, const std::vector< cl::Event > *events=nullptr)
Executes the necessary kernels.
Definition: algorithms.hpp:2055
Interface class for the Summed Area Table operation.
Definition: algorithms.hpp:1231
void run(const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Executes the necessary kernels.
Definition: algorithms.cpp:1394
Interface class for performing Guided Image Filtering on a Depth image from Kinect.
Definition: algorithms.hpp:2090
Memory
Enumerates the memory objects handled by the class.
Definition: algorithms.hpp:1699
cl_float * hPtrOut
Definition: algorithms.hpp:1747
int getRadius()
Gets the filter window radius.
Definition: algorithms.cpp:4925
cl_float4 * hPtrOut
Definition: algorithms.hpp:674
void init(unsigned int _width, unsigned int _height, float _f, float _scaling=1.f, int _rgbNorm=0, Staging _staging=Staging::IO)
Configures kernel execution parameters.
Definition: algorithms.cpp:1497
cl_float * hPtrInD
Definition: algorithms.hpp:786
double run(clutils::GPUTimer< period > &timer, const std::vector< cl::Event > *events=nullptr)
Executes the necessary kernels.
Definition: algorithms.hpp:2161
Memory
Enumerates the memory objects handled by the class.
Definition: algorithms.hpp:208
double run(clutils::GPUTimer< period > &timer, const std::vector< cl::Event > *events=nullptr)
Executes the necessary kernels.
Definition: algorithms.hpp:384
GuidedFilterDepth(clutils::CLEnv &_env, clutils::CLEnvInfo< 2 > _info)
Configures an OpenCL environment as specified by _info.
Definition: algorithms.cpp:4738
cl_uchar * hPtrOut
Definition: algorithms.hpp:462
Interface class for the rgbdTo8D kernel.
Definition: algorithms.hpp:737
cl_float * hPtrOut
Definition: algorithms.hpp:1367
Interface class for the boxFilterSAT{_Tr} kernel.
Definition: algorithms.hpp:1327
float getFocalLength()
Gets the focal length.
Definition: algorithms.cpp:1707
int getRGBNorm()
Gets the flag for RGB normalization.
Definition: algorithms.cpp:1743
void run(const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Executes the necessary kernels.
Definition: algorithms.cpp:4916
Interface class for performing Guided Image Filtering on an RGB image from Kinect.
Definition: algorithms.hpp:1842
SplitPC8D(clutils::CLEnv &_env, clutils::CLEnvInfo< 1 > _info)
Configures an OpenCL environment as specified by _info.
Definition: algorithms.cpp:1763
void setRadius(int _radius)
Sets the filter window radius.
Definition: algorithms.cpp:4935
cl_float * hPtrOutR
Definition: algorithms.hpp:236
Memory
Enumerates the memory objects handled by the class.
Definition: algorithms.hpp:1238
void init(unsigned int _width, unsigned int _height, float _f, float _scaling=1.f, Staging _staging=Staging::IO)
Configures kernel execution parameters.
Definition: algorithms.cpp:1256
cl_float * hPtrInG
Definition: algorithms.hpp:788
float getFocalLength()
Gets the focal length.
Definition: algorithms.cpp:1402
cl_float * hPtrIn
Definition: algorithms.hpp:673
void run(const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Executes the necessary kernels.
Definition: algorithms.cpp:2649
float getDScaling()
Gets the depth scaling factor.
Definition: algorithms.cpp:4963
float getScaling()
Gets the scaling factor.
Definition: algorithms.cpp:1421
void * read(Transpose::Memory mem=Transpose::Memory::H_OUT, bool block=CL_TRUE, const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Performs a data transfer to a staging buffer.
Definition: algorithms.cpp:2626
int getRadius()
Gets the filter window radius.
Definition: algorithms.cpp:3421
Memory
Enumerates the memory objects handled by the class.
Definition: algorithms.hpp:950
Definition: helper_funcs.hpp:41
float getScaling()
Gets the scaling factor.
Definition: algorithms.cpp:2864
Memory
Enumerates the memory objects handled by the class.
Definition: algorithms.hpp:1439
BoxFilterSAT(clutils::CLEnv &_env, clutils::CLEnvInfo< 1 > _info)
Configures an OpenCL environment as specified by _info.
Definition: algorithms.cpp:2884
Memory
Enumerates the memory objects handled by the class.
Definition: algorithms.hpp:1558
Memory
Enumerates the memory objects handled by the class.
Definition: algorithms.hpp:431
float getScaling()
Gets the scaling factor.
Definition: algorithms.cpp:2430
DepthConfig
Enumerates configurations for the Depth class.
Definition: algorithms.hpp:499
void run(const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Executes the necessary kernels.
Definition: math.cpp:253
cl_float * hPtrInP
Definition: algorithms.hpp:1746
cl_float * hPtrIn
Definition: algorithms.hpp:133
void setFocalLength(float _f)
Sets the focal length.
Definition: algorithms.cpp:1717
cl_float * hPtrIn
Definition: algorithms.hpp:1366
cl_float * hPtrIn
Definition: algorithms.hpp:1063
SAT(clutils::CLEnv &_env, clutils::CLEnvInfo< 1 > _info, bool _transposed=true)
Configures an OpenCL environment as specified by _info.
Definition: algorithms.cpp:2663
void write(RGBDTo8D::Memory mem=RGBDTo8D::Memory::D_IN_D, void *ptr=nullptr, bool block=CL_FALSE, const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Performs a data transfer to a device buffer.
Definition: algorithms.cpp:1634
double run(clutils::GPUTimer< period > &timer, const std::vector< cl::Event > *events=nullptr)
Executes the necessary kernels.
Definition: algorithms.hpp:997
void write(SplitPC8D::Memory mem=SplitPC8D::Memory::D_IN, void *ptr=nullptr, bool block=CL_FALSE, const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Performs a data transfer to a device buffer.
Definition: algorithms.cpp:1906
Memory
Enumerates the memory objects handled by the class.
Definition: algorithms.hpp:1152
cl_float * hPtrInR
Definition: algorithms.hpp:787
void write(Scan::Memory mem=Scan::Memory::D_IN, void *ptr=nullptr, bool block=CL_FALSE, const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Performs a data transfer to a device buffer.
Definition: algorithms.cpp:2356
cl_float8 * hPtrOut
Definition: algorithms.hpp:790
void write(DepthTo3D::Memory mem=DepthTo3D::Memory::D_IN, void *ptr=nullptr, bool block=CL_FALSE, const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Performs a data transfer to a device buffer.
Definition: algorithms.cpp:1343
cl_float * hPtrOutG
Definition: algorithms.hpp:135
double run(clutils::GPUTimer< period > &timer, const std::vector< cl::Event > *events=nullptr)
Executes the necessary kernels.
Definition: algorithms.hpp:1290
double run(clutils::GPUTimer< period > &timer, const std::vector< cl::Event > *events=nullptr)
Executes the necessary kernels.
Definition: algorithms.hpp:912
double run(clutils::GPUTimer< period > &timer, const std::vector< cl::Event > *events=nullptr)
Executes the necessary kernels.
Definition: algorithms.hpp:263
double run(clutils::GPUTimer< period > &timer, const std::vector< cl::Event > *events=nullptr)
Executes the necessary kernels.
Definition: algorithms.hpp:1090
void * read(SplitPC8D::Memory mem=SplitPC8D::Memory::H_OUT_PC4D, bool block=CL_TRUE, const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Performs a data transfer to a staging buffer.
Definition: algorithms.cpp:1934
void run(const std::vector< cl::Event > *events=nullptr, cl::Event *event=nullptr)
Executes the necessary kernels.
Definition: algorithms.cpp:1187
DepthTo3D(clutils::CLEnv &_env, clutils::CLEnvInfo< 1 > _info)
Configures an OpenCL environment as specified by _info.
Definition: algorithms.cpp:1215
cl_float * hPtrInR
Definition: algorithms.hpp:356
Interface class for the separateRGBChannels_Uchar2Float kernel.
Definition: algorithms.hpp:201
Interface class for the depth kernels.
Definition: algorithms.hpp:515
double run(clutils::GPUTimer< period > &timer, const std::vector< cl::Event > *events=nullptr)
Executes the necessary kernels.
Definition: algorithms.hpp:602
SeparateRGBConfig
Enumerates configurations for the SeparateRGB class.
Definition: algorithms.hpp:51
cl_float * hPtrOut
Definition: algorithms.hpp:2135
RGBDTo8D(clutils::CLEnv &_env, clutils::CLEnvInfo< 1 > _info)
Configures an OpenCL environment as specified by _info.
Definition: algorithms.cpp:1441