Point Cloud Library (PCL)  1.14.0-dev
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 #pragma once
39 
40 #include <pcl/cuda/point_cloud.h>
41 #include <pcl/io/openni_camera/openni_image.h>
42 
43 namespace pcl
44 {
45  namespace cuda
46  {
47 
49  {
52  {}
53 
55 
56  __host__ __device__
57  bool operator () (int i)
58  {
59  int xIdx = i % width;
60  int yIdx = i / width;
61 
62  return ((xIdx % stride == 0) & (yIdx % stride == 0));
63  }
64  };
65 
66  template <template <typename> class Storage>
68  {
69  unsigned width;
70  unsigned height;
71  //static unsigned dataSize;
72  //static unsigned char* global_data; // has to be initialized only once!
73  //unsigned char* data;
74  unsigned char *data;
75  DebayerBilinear (unsigned char *bayer_image, unsigned width, unsigned height);
76  //DebayerBilinear (const openni_wrapper::Image::Ptr& bayer_image);
77 
78  __inline__ __host__ __device__ OpenNIRGB operator () (int index) const;
79  };
80  /*
81  struct DebayerEdgeAware
82  {
83  unsigned width;
84  unsigned height;
85  static unsigned dataSize;
86  static unsigned char* global_data; // has to be initialized only once!
87  unsigned char* data;
88  DebayerEdgeAware (const openni_wrapper::Image::Ptr& bayer_image);
89  ~DebayerEdgeAware ();
90 
91  __inline__ __host__ __device__ OpenNIRGB operator () (int index) const;
92  };
93  */
94  template<template <typename> class Storage>
96  {
97  public:
98  using RGBImageType = typename Storage<OpenNIRGB>::type;
99  void
100  compute (const openni_wrapper::Image::Ptr& bayer_image, RGBImageType& rgb_image) const;
101  };
102 
103  template <template <typename> class Storage>
105  {
106  unsigned width;
107  unsigned height;
108  unsigned char *data;
109  YUV2RGBKernel (unsigned char *yuv_image, unsigned width, unsigned height);
110 
111  __inline__ __host__ __device__ OpenNIRGB operator () (int index) const;
112  };
113 
114  template<template <typename> class Storage>
115  class YUV2RGB
116  {
117  public:
118  using RGBImageType = typename Storage<OpenNIRGB>::type;
119  void
120  compute (const openni_wrapper::Image::Ptr& yuv_image, RGBImageType& rgb_image) const;
121  };
122 
123  template<template <typename> class Storage>
125  {
126  public:
127  using RGBImageType = typename Storage<OpenNIRGB>::type;
128  void
129  computeBilinear (const openni_wrapper::Image::Ptr& bayer_image, RGBImageType& rgb_image) const;
130 
131  //void
132  //computeEdgeAware (const openni_wrapper::Image::Ptr& bayer_image, thrust::host_vector<OpenNIRGB>& rgb_image) const;
133 
134  //void
135  //computeEdgeAware (const openni_wrapper::Image::Ptr& bayer_image, thrust::device_vector<OpenNIRGB>& rgb_image) const;
136  };
137 
138  } // namespace
139 } // namespace
pcl::shared_ptr< Image > Ptr
Definition: openni_image.h:61
void compute(const openni_wrapper::Image::Ptr &bayer_image, RGBImageType &rgb_image) const
typename Storage< OpenNIRGB >::type RGBImageType
Definition: debayering.h:98
typename Storage< OpenNIRGB >::type RGBImageType
Definition: debayering.h:127
void computeBilinear(const openni_wrapper::Image::Ptr &bayer_image, RGBImageType &rgb_image) const
typename Storage< OpenNIRGB >::type RGBImageType
Definition: debayering.h:118
void compute(const openni_wrapper::Image::Ptr &yuv_image, RGBImageType &rgb_image) const
DebayerBilinear(unsigned char *bayer_image, unsigned width, unsigned height)
unsigned char * data
Definition: debayering.h:74
__inline__ __host__ __device__ OpenNIRGB operator()(int index) const
Simple structure holding RGB data.
Definition: point_cloud.h:56
unsigned char * data
Definition: debayering.h:108
YUV2RGBKernel(unsigned char *yuv_image, unsigned width, unsigned height)
__inline__ __host__ __device__ OpenNIRGB operator()(int index) const
__host__ __device__ bool operator()(int i)
Definition: debayering.h:57
downsampleIndices(int width, int height, int stride)
Definition: debayering.h:50