Point Cloud Library (PCL)  1.8.1
debayering.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Willow Garage, Inc. nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *
34  * $Id$
35  *
36  */
37 
38 #ifndef PCL_CUDA_DEBAYERING_H_
39 #define PCL_CUDA_DEBAYERING_H_
40 
41 #include <pcl/cuda/point_cloud.h>
42 #include <pcl/io/openni_camera/openni_image.h>
43 
44 namespace pcl
45 {
46  namespace cuda
47  {
48 
50  {
52  : width (width), height (height), stride (stride)
53  {}
54 
56 
57  __host__ __device__
58  bool operator () (int i)
59  {
60  int xIdx = i % width;
61  int yIdx = i / width;
62 
63  return ((xIdx % stride == 0) & (yIdx % stride == 0));
64  }
65  };
66 
67  template <template <typename> class Storage>
69  {
70  unsigned width;
71  unsigned height;
72  //static unsigned dataSize;
73  //static unsigned char* global_data; // has to be initialized only once!
74  //unsigned char* data;
75  unsigned char *data;
76  DebayerBilinear (unsigned char *bayer_image, unsigned width, unsigned height);
77  //DebayerBilinear (const boost::shared_ptr<openni_wrapper::Image>& bayer_image);
78 
79  __inline__ __host__ __device__ OpenNIRGB operator () (int index) const;
80  };
81  /*
82  struct DebayerEdgeAware
83  {
84  unsigned width;
85  unsigned height;
86  static unsigned dataSize;
87  static unsigned char* global_data; // has to be initialized only once!
88  unsigned char* data;
89  DebayerEdgeAware (const boost::shared_ptr<openni_wrapper::Image>& bayer_image);
90  ~DebayerEdgeAware ();
91 
92  __inline__ __host__ __device__ OpenNIRGB operator () (int index) const;
93  };
94  */
95  template<template <typename> class Storage>
97  {
98  public:
99  typedef typename Storage<OpenNIRGB>::type RGBImageType;
100  void
101  compute (const boost::shared_ptr<openni_wrapper::Image>& bayer_image, RGBImageType& rgb_image) const;
102  };
103 
104  template <template <typename> class Storage>
106  {
107  unsigned width;
108  unsigned height;
109  unsigned char *data;
110  YUV2RGBKernel (unsigned char *yuv_image, unsigned width, unsigned height);
111 
112  __inline__ __host__ __device__ OpenNIRGB operator () (int index) const;
113  };
114 
115  template<template <typename> class Storage>
116  class YUV2RGB
117  {
118  public:
119  typedef typename Storage<OpenNIRGB>::type RGBImageType;
120  void
121  compute (const boost::shared_ptr<openni_wrapper::Image>& yuv_image, RGBImageType& rgb_image) const;
122  };
123 
124  template<template <typename> class Storage>
126  {
127  public:
128  typedef typename Storage<OpenNIRGB>::type RGBImageType;
129  void
130  computeBilinear (const boost::shared_ptr<openni_wrapper::Image>& bayer_image, RGBImageType& rgb_image) const;
131 
132  //void
133  //computeEdgeAware (const boost::shared_ptr<openni_wrapper::Image>& bayer_image, thrust::host_vector<OpenNIRGB>& rgb_image) const;
134 
135  //void
136  //computeEdgeAware (const boost::shared_ptr<openni_wrapper::Image>& bayer_image, thrust::device_vector<OpenNIRGB>& rgb_image) const;
137  };
138 
139  } // namespace
140 } // namespace
141 
142 #endif
unsigned char * data
Definition: debayering.h:75
__host__ __device__ bool operator()(int i)
Definition: debayering.h:58
Storage< OpenNIRGB >::type RGBImageType
Definition: debayering.h:119
unsigned char * data
Definition: debayering.h:109
downsampleIndices(int width, int height, int stride)
Definition: debayering.h:51
Storage< OpenNIRGB >::type RGBImageType
Definition: debayering.h:99
Storage< OpenNIRGB >::type RGBImageType
Definition: debayering.h:128
Simple structure holding RGB data.
Definition: point_cloud.h:56