diff options
author | Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org> | 2012-05-08 18:52:33 +0200 |
---|---|---|
committer | Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org> | 2012-11-14 13:51:02 +0100 |
commit | 872dd83a97e2dbb9df1e41aa6116c55852f25bdc (patch) | |
tree | 897c621c02e1a1a34508f20c38cb569a1772fa26 | |
parent | e8fe19eea4af15973acaada01dd56101d52988d8 (diff) | |
download | Camera-linaro_android_4.2.1.tar.gz |
Camera: ISO C++11 build fixeslinaro_android_4.2.1linaro_android_4.2
Fix build in ISO C++11 mode:
- enum typesafety
- constexpr
Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
-rw-r--r-- | jni/feature_mos/src/mosaic/AlignFeatures.h | 30 | ||||
-rw-r--r-- | jni/feature_mos/src/mosaic/Blend.h | 42 | ||||
-rw-r--r-- | jni/feature_mos/src/mosaic/ImageUtils.cpp | 2 | ||||
-rw-r--r-- | jni/feature_mos_jni.cpp | 4 |
4 files changed, 43 insertions, 35 deletions
diff --git a/jni/feature_mos/src/mosaic/AlignFeatures.h b/jni/feature_mos/src/mosaic/AlignFeatures.h index 19f39051..99fc7de6 100644 --- a/jni/feature_mos/src/mosaic/AlignFeatures.h +++ b/jni/feature_mos/src/mosaic/AlignFeatures.h @@ -29,30 +29,34 @@ #include "ImageUtils.h" #include "MatrixUtils.h" +#if __cplusplus < 201103L && !defined(__GXX_EXPERIMENTAL_CXX0X__) && !defined(constexpr) +#define constexpr const +#endif + class Align { public: // Types of alignment possible - static const int ALIGN_TYPE_PAN = 1; + static constexpr int ALIGN_TYPE_PAN = 1; // Return codes - static const int ALIGN_RET_LOW_TEXTURE = -2; - static const int ALIGN_RET_ERROR = -1; - static const int ALIGN_RET_OK = 0; - static const int ALIGN_RET_FEW_INLIERS = 1; + static constexpr int ALIGN_RET_LOW_TEXTURE = -2; + static constexpr int ALIGN_RET_ERROR = -1; + static constexpr int ALIGN_RET_OK = 0; + static constexpr int ALIGN_RET_FEW_INLIERS = 1; ///// Settings for feature-based alignment // Number of features to use from corner detection - static const int DEFAULT_NR_CORNERS=750; - static const double DEFAULT_MAX_DISPARITY=0.1;//0.4; + static constexpr int DEFAULT_NR_CORNERS=750; + static constexpr double DEFAULT_MAX_DISPARITY=0.1;//0.4; // Type of homography to model - static const int DEFAULT_MOTION_MODEL=DB_HOMOGRAPHY_TYPE_R_T; -// static const int DEFAULT_MOTION_MODEL=DB_HOMOGRAPHY_TYPE_PROJECTIVE; -// static const int DEFAULT_MOTION_MODEL=DB_HOMOGRAPHY_TYPE_AFFINE; - static const unsigned int DEFAULT_REFERENCE_UPDATE_PERIOD=1500; // Manual reference frame update so set this to a large number + static constexpr int DEFAULT_MOTION_MODEL=DB_HOMOGRAPHY_TYPE_R_T; +// static constexpr int DEFAULT_MOTION_MODEL=DB_HOMOGRAPHY_TYPE_PROJECTIVE; +// static constexpr int DEFAULT_MOTION_MODEL=DB_HOMOGRAPHY_TYPE_AFFINE; + static constexpr unsigned int DEFAULT_REFERENCE_UPDATE_PERIOD=1500; // Manual reference frame update so set this to a large number - static const int MIN_NR_REF_CORNERS = 25; - static const int MIN_NR_INLIERS = 10; + static constexpr int MIN_NR_REF_CORNERS = 25; + static constexpr int MIN_NR_INLIERS = 10; Align(); ~Align(); diff --git a/jni/feature_mos/src/mosaic/Blend.h b/jni/feature_mos/src/mosaic/Blend.h index 2c7ee5c5..c489109b 100644 --- a/jni/feature_mos/src/mosaic/Blend.h +++ b/jni/feature_mos/src/mosaic/Blend.h @@ -28,24 +28,28 @@ #define BLEND_RANGE_DEFAULT 6 #define BORDER 8 +#if __cplusplus < 201103L && !defined(__GXX_EXPERIMENTAL_CXX0X__) && !defined(constexpr) +#define constexpr const +#endif + // Percent of total mosaicing time spent on each of the following operations -const float TIME_PERCENT_ALIGN = 20.0; -const float TIME_PERCENT_BLEND = 75.0; -const float TIME_PERCENT_FINAL = 5.0; +constexpr float TIME_PERCENT_ALIGN = 20.0; +constexpr float TIME_PERCENT_BLEND = 75.0; +constexpr float TIME_PERCENT_FINAL = 5.0; // This threshold determines the minimum separation between the image centers // of the input image frames for them to be accepted for blending in the // STRIP_TYPE_WIDE mode. -const float STRIP_SEPARATION_THRESHOLD_PXLS = 10; +constexpr float STRIP_SEPARATION_THRESHOLD_PXLS = 10; // This threshold determines the number of pixels on either side of the strip // to cross-fade using the images contributing to each seam. -const float STRIP_CROSS_FADE_WIDTH_PXLS = 2; +constexpr float STRIP_CROSS_FADE_WIDTH_PXLS = 2; // This specifies the maximum pyramid level to which cross-fading is applied. // The original image resolution is Level-0, half of that size is Level-1 and // so on. BLEND_RANGE_DEFAULT specifies the number of pyramid levels used by // the blending algorithm. -const int STRIP_CROSS_FADE_MAX_PYR_LEVEL = 2; +constexpr int STRIP_CROSS_FADE_MAX_PYR_LEVEL = 2; /** * Class for pyramid blending a mosaic. @@ -54,19 +58,19 @@ class Blend { public: - static const int BLEND_TYPE_NONE = -1; - static const int BLEND_TYPE_FULL = 0; - static const int BLEND_TYPE_PAN = 1; - static const int BLEND_TYPE_CYLPAN = 2; - static const int BLEND_TYPE_HORZ = 3; + static constexpr int BLEND_TYPE_NONE = -1; + static constexpr int BLEND_TYPE_FULL = 0; + static constexpr int BLEND_TYPE_PAN = 1; + static constexpr int BLEND_TYPE_CYLPAN = 2; + static constexpr int BLEND_TYPE_HORZ = 3; - static const int STRIP_TYPE_THIN = 0; - static const int STRIP_TYPE_WIDE = 1; + static constexpr int STRIP_TYPE_THIN = 0; + static constexpr int STRIP_TYPE_WIDE = 1; - static const int BLEND_RET_ERROR = -1; - static const int BLEND_RET_OK = 0; - static const int BLEND_RET_ERROR_MEMORY = 1; - static const int BLEND_RET_CANCELLED = -2; + static constexpr int BLEND_RET_ERROR = -1; + static constexpr int BLEND_RET_OK = 0; + static constexpr int BLEND_RET_ERROR_MEMORY = 1; + static constexpr int BLEND_RET_CANCELLED = -2; Blend(); ~Blend(); @@ -119,8 +123,8 @@ protected: void CropFinalMosaic(YUVinfo &imgMos, MosaicRect &cropping_rect); private: - static const float LIMIT_SIZE_MULTIPLIER = 5.0f * 2.0f; - static const float LIMIT_HEIGHT_MULTIPLIER = 2.5f; + static constexpr float LIMIT_SIZE_MULTIPLIER = 5.0f * 2.0f; + static constexpr float LIMIT_HEIGHT_MULTIPLIER = 2.5f; int MosaicSizeCheck(float sizeMultiplier, float heightMultiplier); void RoundingCroppingSizeToMultipleOf8(MosaicRect& rect); }; diff --git a/jni/feature_mos/src/mosaic/ImageUtils.cpp b/jni/feature_mos/src/mosaic/ImageUtils.cpp index 6d0aac0c..318df547 100644 --- a/jni/feature_mos/src/mosaic/ImageUtils.cpp +++ b/jni/feature_mos/src/mosaic/ImageUtils.cpp @@ -283,7 +283,7 @@ ImageType ImageUtils::readBinaryPPM(const char *filename, int &width, int &heigh FILE *imgin = NULL; int mval=0, format=0, eret; - ImageType ret = IMAGE_TYPE_NOIMAGE; + ImageType ret = (ImageType)IMAGE_TYPE_NOIMAGE; imgin = fopen(filename, "r"); if (imgin == NULL) { diff --git a/jni/feature_mos_jni.cpp b/jni/feature_mos_jni.cpp index 0fa792a6..40d16f04 100644 --- a/jni/feature_mos_jni.cpp +++ b/jni/feature_mos_jni.cpp @@ -47,8 +47,8 @@ int tHeight[NR]; ImageType tImage[NR][MAX_FRAMES];// = {{ImageUtils::IMAGE_TYPE_NOIMAGE}}; // YVU24 format image Mosaic *mosaic[NR] = {NULL,NULL}; -ImageType resultYVU = ImageUtils::IMAGE_TYPE_NOIMAGE; -ImageType resultBGR = ImageUtils::IMAGE_TYPE_NOIMAGE; +ImageType resultYVU = (ImageType)ImageUtils::IMAGE_TYPE_NOIMAGE; +ImageType resultBGR = (ImageType)ImageUtils::IMAGE_TYPE_NOIMAGE; float gTRS[11]; // 9 elements of the transformation, 1 for frame-number, 1 for alignment error code. // Variables to keep track of the mosaic computation progress for both LR & HR. float gProgress[NR]; |