1 /* 2 * data_types.h - data types in interface 3 * 4 * Copyright (c) 2017 Intel Corporation 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 * 18 * Author: Wind Yuan <feng.yuan@intel.com> 19 * Author: Yinhang Liu <yinhangx.liu@intel.com> 20 */ 21 22 #ifndef XCAM_INTERFACE_DATA_TYPES_H 23 #define XCAM_INTERFACE_DATA_TYPES_H 24 25 #include <xcam_std.h> 26 27 namespace XCam { 28 29 enum SurroundMode { 30 SphereView = 0, 31 BowlView = 1 32 }; 33 34 struct Rect { 35 int32_t pos_x, pos_y; 36 int32_t width, height; 37 RectRect38 Rect () : pos_x (0), pos_y (0), width (0), height (0) {} RectRect39 Rect (int32_t x, int32_t y, int32_t w, int32_t h) : pos_x (x), pos_y (y), width (w), height (h) {} 40 }; 41 42 struct ImageCropInfo { 43 uint32_t left; 44 uint32_t right; 45 uint32_t top; 46 uint32_t bottom; 47 ImageCropInfoImageCropInfo48 ImageCropInfo () : left (0), right (0), top (0), bottom (0) {} 49 }; 50 51 struct FisheyeInfo { 52 float center_x; 53 float center_y; 54 float wide_angle; 55 float radius; 56 float rotate_angle; // clockwise 57 FisheyeInfoFisheyeInfo58 FisheyeInfo () 59 : center_x (0.0f), center_y (0.0f), wide_angle (0.0f) 60 , radius (0.0f), rotate_angle (0.0f) 61 {} is_validFisheyeInfo62 bool is_valid () const { 63 return wide_angle >= 1.0f && radius >= 1.0f; 64 } 65 }; 66 67 #define XCAM_INTRINSIC_MAX_POLY_SIZE 16 68 69 // current intrinsic parameters definition from Scaramuzza's approach 70 struct IntrinsicParameter { 71 float xc; 72 float yc; 73 float c; 74 float d; 75 float e; 76 uint32_t poly_length; 77 78 float poly_coeff[XCAM_INTRINSIC_MAX_POLY_SIZE]; 79 IntrinsicParameterIntrinsicParameter80 IntrinsicParameter () 81 : xc (0.0f), yc (0.0f), c(0.0f), d (0.0f), e (0.0f), poly_length (0) 82 { 83 xcam_mem_clear (poly_coeff); 84 } 85 }; 86 87 struct ExtrinsicParameter { 88 float trans_x; 89 float trans_y; 90 float trans_z; 91 92 // angle degree 93 float roll; 94 float pitch; 95 float yaw; 96 ExtrinsicParameterExtrinsicParameter97 ExtrinsicParameter () 98 : trans_x (0.0f), trans_y (0.0f), trans_z (0.0f) 99 , roll (0.0f), pitch (0.0f), yaw (0.0f) 100 {} 101 }; 102 103 template <typename T> 104 struct Point2DT { 105 T x, y; Point2DTPoint2DT106 Point2DT () : x (0), y(0) {} Point2DTPoint2DT107 Point2DT (const T px, const T py) : x (px), y(py) {} 108 }; 109 110 template <typename T> 111 struct Point3DT { 112 T x, y, z; Point3DTPoint3DT113 Point3DT () : x (0), y(0), z(0) {} Point3DTPoint3DT114 Point3DT (const T px, const T py, const T pz) : x (px), y(py), z(pz) {} 115 }; 116 117 typedef Point2DT<int32_t> PointInt2; 118 typedef Point2DT<float> PointFloat2; 119 120 typedef Point3DT<int32_t> PointInt3; 121 typedef Point3DT<float> PointFloat3; 122 123 /* 124 * Ellipsoid model 125 * x^2 / a^2 + y^2 / b^2 + (z-center_z)^2 / c^2 = 1 126 * ground : z = 0 127 * x_axis : front direction 128 * y_axis : left direction 129 * z_axis : up direction 130 * wall_height : bowl height inside of view 131 * ground_length: left direction distance from ellipsoid bottom edge to nearest side of the car in the view 132 */ 133 struct BowlDataConfig { 134 float a, b, c; 135 float angle_start, angle_end; // angle degree 136 137 // unit mm 138 float center_z; 139 float wall_height; 140 float ground_length; 141 BowlDataConfigBowlDataConfig142 BowlDataConfig () 143 : a (6060.0f), b (4388.0f), c (3003.4f) 144 , angle_start (90.0f), angle_end (270.0f) 145 , center_z (1500.0f) 146 , wall_height (3000.0f) 147 , ground_length (2801.0f) 148 { 149 XCAM_ASSERT (fabs(center_z) <= c); 150 XCAM_ASSERT (a > 0.0f && b > 0.0f && c > 0.0f); 151 XCAM_ASSERT (wall_height >= 0.0f && ground_length >= 0.0f); 152 XCAM_ASSERT (ground_length <= b * sqrt(1.0f - center_z * center_z / (c * c))); 153 XCAM_ASSERT (wall_height <= center_z + c); 154 } 155 }; 156 157 } 158 159 #endif //XCAM_INTERFACE_DATA_TYPES_H 160