00001 // **************************************************************************** 00002 // This file is part of the Integrating Vision Toolkit (IVT). 00003 // 00004 // The IVT is maintained by the Karlsruhe Institute of Technology (KIT) 00005 // (www.kit.edu) in cooperation with the company Keyetech (www.keyetech.de). 00006 // 00007 // Copyright (C) 2014 Karlsruhe Institute of Technology (KIT). 00008 // All rights reserved. 00009 // 00010 // Redistribution and use in source and binary forms, with or without 00011 // modification, are permitted provided that the following conditions are met: 00012 // 00013 // 1. Redistributions of source code must retain the above copyright 00014 // notice, this list of conditions and the following disclaimer. 00015 // 00016 // 2. Redistributions in binary form must reproduce the above copyright 00017 // notice, this list of conditions and the following disclaimer in the 00018 // documentation and/or other materials provided with the distribution. 00019 // 00020 // 3. Neither the name of the KIT nor the names of its contributors may be 00021 // used to endorse or promote products derived from this software 00022 // without specific prior written permission. 00023 // 00024 // THIS SOFTWARE IS PROVIDED BY THE KIT AND CONTRIBUTORS “AS IS” AND ANY 00025 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00026 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00027 // DISCLAIMED. IN NO EVENT SHALL THE KIT OR CONTRIBUTORS BE LIABLE FOR ANY 00028 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00029 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00030 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00031 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00032 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00033 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 // **************************************************************************** 00035 // **************************************************************************** 00036 // Filename: helpers.h 00037 // Author: Pedram Azad 00038 // Date: 2004 00039 // **************************************************************************** 00040 00041 00042 #ifndef _HELPERS_H_ 00043 #define _HELPERS_H_ 00044 00045 #if defined(__hppa__) || \ 00046 defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ 00047 (defined(__MIPS__) && defined(__MISPEB__)) || \ 00048 defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \ 00049 defined(__sparc__) 00050 00051 #ifndef IVT_BIG_ENDIAN 00052 #define IVT_BIG_ENDIAN 1 00053 #endif 00054 00055 #endif 00056 00057 00058 00059 // **************************************************************************** 00060 // Defines 00061 // **************************************************************************** 00062 00063 #define MY_MAX(a, b) (((a) > (b)) ? (a) : (b)) 00064 #define MY_MIN(a, b) (((a) < (b)) ? (a) : (b)) 00065 00066 00067 // **************************************************************************** 00068 // Declarations 00069 // **************************************************************************** 00070 00071 extern float invert_byte_order_float(float x); 00072 extern unsigned long invert_byte_order_long(unsigned long x); 00073 extern unsigned int invert_byte_order_int(unsigned int x); 00074 extern unsigned short invert_byte_order_short(unsigned short x); 00075 extern long invert_byte_order_long(long x); 00076 extern int invert_byte_order_int(int x); 00077 extern short invert_byte_order_short(short x); 00078 extern void get_timer_value(unsigned int &sec, unsigned int &usec); 00079 extern unsigned int get_timer_value(bool bResetTimer = false); 00080 extern int my_round(double x); 00081 extern int my_round(float x); 00082 extern double uniform_random(); 00083 extern double gaussian_random(); 00084 extern float uniform_random_float(); 00085 extern float gaussian_random_float(); 00086 extern void sleep_ms(unsigned int ms); 00087 extern void hsv2rgb(int h, int s, int v, int &r, int &g, int &b); 00088 extern void rgb2hsv(int r, int g, int b, int &h, int &s, int &v); 00089 extern void *aligned_malloc(unsigned int size, unsigned int align_size = 16); 00090 extern void aligned_free(void *ptr); 00091 extern const char *GetVersionIVT(); 00092 00093 00094 00095 #endif /* _HELPERS_H_ */