00001 /* 00002 * This file is part of the rc_genicam_api package. 00003 * 00004 * Copyright (c) 2017 Roboception GmbH 00005 * All rights reserved 00006 * 00007 * Author: Heiko Hirschmueller 00008 * 00009 * Redistribution and use in source and binary forms, with or without 00010 * modification, are permitted provided that the following conditions are met: 00011 * 00012 * 1. Redistributions of source code must retain the above copyright notice, 00013 * this list of conditions and the following disclaimer. 00014 * 00015 * 2. Redistributions in binary form must reproduce the above copyright notice, 00016 * this list of conditions and the following disclaimer in the documentation 00017 * and/or other materials provided with the distribution. 00018 * 00019 * 3. Neither the name of the copyright holder nor the names of its contributors 00020 * may be used to endorse or promote products derived from this software without 00021 * specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00024 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00025 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00026 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 00027 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00028 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00029 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00030 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00031 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00032 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00033 * POSSIBILITY OF SUCH DAMAGE. 00034 */ 00035 00036 #ifndef RC_GENICAM_API_IMAGE 00037 #define RC_GENICAM_API_IMAGE 00038 00039 #include "buffer.h" 00040 00041 #include <memory> 00042 00043 namespace rcg 00044 { 00045 00055 class Image 00056 { 00057 public: 00058 00066 Image(const Buffer *buffer, std::uint32_t part); 00067 00074 const uint8_t *getPixels() const { return pixel.get(); } 00075 00076 uint64_t getTimestampNS() const { return timestamp; } 00077 00078 size_t getWidth() const { return width; } 00079 size_t getHeight() const { return height; } 00080 size_t getXOffset() const { return xoffset; } 00081 size_t getYOffset() const { return yoffset; } 00082 size_t getXPadding() const { return xpadding; } 00083 size_t getYPadding() const { return ypadding; } 00084 uint64_t getFrameID() const { return frameid; } 00085 uint64_t getPixelFormat() const { return pixelformat; } 00086 bool isBigEndian() const { return bigendian; } 00087 00088 private: 00089 00090 Image(class Image &); // forbidden 00091 Image &operator=(const Image &); // forbidden 00092 00093 std::unique_ptr<uint8_t []> pixel; 00094 00095 uint64_t timestamp; 00096 size_t width; 00097 size_t height; 00098 size_t xoffset; 00099 size_t yoffset; 00100 size_t xpadding; 00101 size_t ypadding; 00102 uint64_t frameid; 00103 uint64_t pixelformat; 00104 bool bigendian; 00105 }; 00106 00116 void convYCbCr411toRGB(uint8_t rgb[3], const uint8_t *row, int i); 00117 00129 void convYCbCr411toQuadRGB(uint8_t rgb[12], const uint8_t *row, int i); 00130 00143 void getColor(uint8_t rgb[3], const std::shared_ptr<const rcg::Image> &img, 00144 uint32_t ds, uint32_t i, uint32_t k); 00145 00146 } 00147 00148 #endif