1 /*
2  * surview_fisheye_dewarp.h - dewarp fisheye image for surround view
3  *
4  *  Copyright (c) 2016-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: Junkai Wu <junkai.wu@intel.com>
19  */
20 
21 #ifndef XCAM_SURVIEW_FISHEYE_DEWARP_H
22 #define XCAM_SURVIEW_FISHEYE_DEWARP_H
23 
24 #include <xcam_std.h>
25 #include <vec_mat.h>
26 #include <interface/data_types.h>
27 
28 namespace XCam {
29 
30 class SurViewFisheyeDewarp
31 {
32 
33 public:
34     typedef std::vector<PointFloat2> MapTable;
35 
36     explicit SurViewFisheyeDewarp ();
37     virtual ~SurViewFisheyeDewarp ();
38 
39     void fisheye_dewarp(MapTable &map_table, uint32_t table_w, uint32_t table_h, uint32_t image_w, uint32_t image_h, const BowlDataConfig &bowl_config);
40 
41     void set_intrinsic_param(const IntrinsicParameter &intrinsic_param);
42     void set_extrinsic_param(const ExtrinsicParameter &extrinsic_param);
43 
44     IntrinsicParameter get_intrinsic_param();
45     ExtrinsicParameter get_extrinsic_param();
46 
47 private:
48     XCAM_DEAD_COPY (SurViewFisheyeDewarp);
49 
50     virtual void cal_image_coord (const PointFloat3 &cam_coord, PointFloat2 &image_coord);
51 
52     void cal_cam_world_coord (const PointFloat3 &world_coord, PointFloat3 &cam_world_coord);
53     void world_coord2cam (const PointFloat3 &cam_world_coord, PointFloat3 &cam_coord);
54 
55     Mat4f generate_rotation_matrix(float roll, float pitch, float yaw);
56 
57 private:
58     IntrinsicParameter _intrinsic_param;
59     ExtrinsicParameter _extrinsic_param;
60 };
61 
62 class PolyFisheyeDewarp : public SurViewFisheyeDewarp
63 {
64 
65 public:
66     explicit PolyFisheyeDewarp ();
67 
68 private:
69     void cal_image_coord (const PointFloat3 &cam_coord, PointFloat2 &image_coord);
70 
71 };
72 
73 } // Adopt Scaramuzza's approach to calculate image coordinates from camera coordinates
74 
75 #endif // XCAM_SURVIEW_FISHEYE_DEWARP_H
76