1 2 /** 3 * @file IHaasImageCodec.h 4 * @author HaasAI Group 5 * @version V1.0.0 6 * @date 2021-01-10 7 * @license GNU General Public License (GPL) 8 * @brief 9 * @attention 10 * This file is part of HaasAI. \n 11 * This program is free software; you can redistribute it and/or modify \n 12 * it under the terms of the GNU General Public License version 3 as \n 13 * published by the Free Software Foundation. \n 14 * You should have received a copy of the GNU General Public License \n 15 * along with HaasAI. If not, see <http://www.gnu.org/licenses/>. \n 16 * Unless required by applicable law or agreed to in writing, software \n 17 * distributed under the License is distributed on an "AS IS" BASIS, \n 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \n 19 * See the License for the specific language governing permissions and \n 20 * limitations under the License. \n 21 * \n 22 * @htmlonly 23 * <span style="font-weight: bold">History</span> 24 * @endhtmlonly 25 * Version|Author|Date|Describe 26 * ------|----|------|-------- 27 * V1.0|HaasAI Group|2021-01-10|Create File 28 * <h2><center>©COPYRIGHT 2021 WELLCASA All Rights Reserved.</center></h2> 29 */ 30 #ifndef IHAAS_IMAGE_CODEC_H 31 #define IHAAS_IMAGE_CODEC_H 32 33 #include "base/include/base/HaasCommonImage.h" 34 #include "base/include/base/HaasImageCodecDef.h" 35 36 /** 37 * @brief image Codec class 38 * @author HaasAI Group 39 */ 40 class IHaasImageCodec 41 { 42 public: ~IHaasImageCodec()43 virtual ~IHaasImageCodec(){} 44 45 /** 46 * @brief Read A Image from Path 47 * @param[out] image : store the image infomation 48 * @param[in] filename : the path of image 49 * @note filename is the image full path. 50 * @return 51 * 0 successfully \n 52 * -1 failed \n 53 * @par Sample 54 * @code 55 * IHaasImageCodec * mIHaasImageCodec = NULL; 56 * ImageBuffer_t image; 57 * char* path = "/data/HaasAI/test.jpg"; 58 * mIHaasImageCodec = IHaasImageCodecInstance(); 59 * int res = 0; 60 * res = mIHaasImageCodec->ImgRead(&image, path.c_str()); 61 * @endcode 62 */ 63 virtual int ImgRead(ImageBuffer_t **image, char * filename) = 0; 64 /** 65 * @brief Read Multi Image from Path 66 * @param[out] images : store the images infomation 67 * @param[in] filename : the path of image 68 * @note filename is the image full path. 69 * @return 70 * 0 successfully \n 71 * -1 failed \n 72 * @par Sample 73 * @code 74 * IHaasImageCodec * mIHaasImageCodec = NULL; 75 * ImageBuffer_t *image = NULL; 76 * char* path = "/data/HaasAI"; 77 * mIHaasImageCodec = IHaasImageCodecInstance(); 78 * int res = 0; 79 * res = mIHaasImageCodec->ImgReadMulti(&image, path.c_str()); 80 * @endcode 81 */ 82 virtual int ImgReadMulti(ImageBuffer_t **images, char * filename) = 0; 83 /** 84 * @brief ImageBuffer_t A Image to Path 85 * @param[in] image : store the image infomation 86 * @param[in] filename : the path of image 87 * @note filename is the image full path. 88 * @return 89 * 0 successfully \n 90 * -1 failed \n 91 * @par Sample 92 * @code 93 * IHaasImageCodec * mIHaasImageCodec = NULL; 94 * ImageBuffer_t *image = xx; 95 * char* path = "/data/HaasAI/test.jpg"; 96 * mIHaasImageCodec = IHaasImageCodecInstance(); 97 * int res = 0; 98 * res = mIHaasImageCodec->ImgWrite(image, path.c_str()); 99 * @endcode 100 */ 101 virtual int ImgWrite(ImageBuffer_t *image, char * filename) = 0; 102 /** 103 * @brief Write Images to Path 104 * @param[in] image : store the image infomation 105 * @param[in] filename : the path of image 106 * @note filename is the image full path. 107 * @return 108 * 0 successfully \n 109 * -1 failed \n 110 * @par Sample 111 * @code 112 * IHaasImageCodec * mIHaasImageCodec = NULL; 113 * ImageBuffer_t **image = xx; 114 * char* path = "/data/HaasAI"; 115 * mIHaasImageCodec = IHaasImageCodecInstance(); 116 * int res = 0; 117 * res = mIHaasImageCodec->ImgWriteMulti(image, path.c_str()); 118 * @endcode 119 */ 120 virtual int ImgWriteMulti(ImageBuffer_t **images, char * filename) = 0; 121 /** 122 * @brief Decode image pixels to image Struct 123 * @param[in] addr : image pixels address 124 * @param[out] image : store the image infomation 125 * @note filename is the image full path. 126 * @return 127 * 0 successfully \n 128 * -1 failed \n 129 * @par Sample 130 * @code 131 * IHaasImageCodec * mIHaasImageCodec = NULL; 132 * ImageBuffer_t image; 133 * void *addr = xx; 134 * mIHaasImageCodec = IHaasImageCodecInstance(); 135 * int res = 0; 136 * res = mIHaasImageCodec->ImgWriteMulti(addr, &image); 137 * @endcode 138 */ 139 virtual int ImgDecode(void *addr, ImageBuffer_t **image) = 0; 140 /** 141 * @brief Decode image to image Struct 142 * @param[in] filename : image path 143 * @note filename is the image full path. 144 * @return 145 * !0 successfully \n 146 * NULL failed \n 147 * @par Sample 148 * @code 149 * IHaasImageCodec * mIHaasImageCodec = NULL; 150 * char* path = "/data/HaasAI/test.jpg"; 151 * ImageBuffer_t *image = NULL; 152 * mIHaasImageCodec = IHaasImageCodecInstance(); 153 * image = mIHaasImageCodec->ImgWriteMulti(path.c_str()); 154 * @endcode 155 */ 156 virtual ImageBuffer_t * ImgDecode(const char * filename) = 0; 157 /** 158 * @brief Encode image to image Struct 159 * @param[in] addr : image pixels address 160 * @param[out] filename : image path 161 * @note filename is the image full path. 162 * @return 163 * 0 successfully \n 164 * -1 failed \n 165 * @par Sample 166 * @code 167 * IHaasImageCodec * mIHaasImageCodec = NULL; 168 * ImageBuffer_t image; 169 * void *addr = NULL; 170 * mIHaasImageCodec = IHaasImageCodecInstance(); 171 * image = mIHaasImageCodec->ImgEncode(addr, &image); 172 * @endcode 173 */ 174 virtual int ImgEncode(void *addr, ImageBuffer_t ** image) = 0; 175 /** 176 * @brief check if has the encoder 177 * @param[in] filename : image path 178 * @note filename is the image full path. 179 * @return 180 * 0 successfully \n 181 * -1 failed \n 182 * @par Sample 183 * @code 184 * IHaasImageCodec * mIHaasImageCodec = NULL; 185 * mIHaasImageCodec = IHaasImageCodecInstance(); 186 * char* path = "/data/HaasAI/test.jpg"; 187 * int res = -1; 188 * res = mIHaasImageCodec->haveImageReader(path.c_str()); 189 * @endcode 190 */ 191 virtual int haveImageReader(char * filename) = 0; 192 /** 193 * @brief check if has the decoder 194 * @param[in] filename : image path 195 * @note filename is the image full path. 196 * @return 197 * 0 successfully \n 198 * -1 failed \n 199 * @par Sample 200 * @code 201 * IHaasImageCodec * mIHaasImageCodec = NULL; 202 * mIHaasImageCodec = IHaasImageCodecInstance(); 203 * char* path = "/data/HaasAI/test.jpg"; 204 * int res = -1; 205 * res = mIHaasImageCodec->haveImageWriter(path.c_str()); 206 * @endcode 207 */ 208 virtual int haveImageWriter(char * filename) = 0; 209 }; 210 211 extern "C" { 212 /** 213 * @brief Get HaasImageCodec Instance 214 * @param[in] type : CodecImageType_t 215 * @note 216 * @return 217 * !0 Open successfully \n 218 * NULL Open failed \n 219 * @par Sample 220 * @code 221 * IHaasImageCodec * mHaasImageCodec = NULL; 222 * mHaasImageCodec = IHaasImageCodecInstance(); 223 * @endcode 224 */ 225 IHaasImageCodec* IHaasImageCodecInstance(CodecImageType_t type); 226 } 227 228 #endif 229