aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzongwave <wei.zong@intel.com>2017-12-16 04:11:46 +0800
committerwindyuan <feng.yuan@intel.com>2017-12-18 13:08:02 +0800
commit24b1d88ea25117db2d923bbf9114897397bb25c0 (patch)
tree9305bf60817519b249033155a039589b70faa67f
parentea29510d8d51265cd75aa5d6257405504cec5813 (diff)
downloadlibxcam-24b1d88ea25117db2d923bbf9114897397bb25c0.tar.gz
stitcher: add bowlview vertex model to support opengl render
-rw-r--r--xcore/interface/stitcher.cpp49
-rw-r--r--xcore/interface/stitcher.h5
2 files changed, 39 insertions, 15 deletions
diff --git a/xcore/interface/stitcher.cpp b/xcore/interface/stitcher.cpp
index 6a5a718..9f99b7a 100644
--- a/xcore/interface/stitcher.cpp
+++ b/xcore/interface/stitcher.cpp
@@ -27,6 +27,8 @@
#define constraint_margin (2 * _alignment_x)
+#define XCAM_GL_RESTART_FIXED_INDEX 0xFFFF
+
namespace XCam {
static inline bool
@@ -597,29 +599,50 @@ BowlModel::get_topview_vertex_map (
}
bool
-BowlModel::get_bowlview_vertex_map (
- VertexMap &vertices, PointMap &texture_points,
+BowlModel::get_bowlview_vertex_model (
+ VertexMap &vertices, PointMap &texture_points, IndexVector &indeices,
uint32_t res_width, uint32_t res_height)
{
- vertices.resize (res_width * res_height);
- texture_points.resize (res_width * res_height);
+ vertices.reserve (2 * (res_width + 1) * (res_height + 1));
+ texture_points.reserve (2 * (res_width + 1) * (res_height + 1));
+ indeices.reserve (2 * (res_width + 1) * (res_height + 1) + (res_height + 1));
float step_x = (float)_bowl_img_width / res_width;
float step_y = (float)_bowl_img_height / res_height;
- for(uint32_t row = 0; row < res_height; row++) {
- PointFloat2 texture_pos;
- texture_pos.y = row * step_y;
- for(uint32_t col = 0; col < res_width; col++) {
- texture_pos.x = col * step_x;
+ int32_t indicator = 0;
+
+ for (uint32_t row = 0; row <= res_height; row++) {
+ PointFloat2 texture_pos0;
+ texture_pos0.y = row * step_y;
+
+ PointFloat2 texture_pos1;
+ if (row + 1 <= res_height) {
+ texture_pos1.y = (row + 1) * step_y;
+ }
+
+ for (uint32_t col = 0; col <= res_width; col++) {
+ texture_pos0.x = col * step_x;
+ texture_pos1.x = col * step_x;
- PointFloat3 world_pos =
+ PointFloat3 world_pos0 =
bowl_view_image_to_world (
- _config, _bowl_img_width, _bowl_img_height, texture_pos);
+ _config, _bowl_img_width, _bowl_img_height, texture_pos0);
- vertices [res_width * row + col] = world_pos;
- texture_points [res_width * row + col] = texture_pos;
+ vertices.push_back (PointFloat3(world_pos0.x / _config.a, world_pos0.y / _config.b, world_pos0.z / _config.c));
+ indeices.push_back (indicator++);
+ texture_points.push_back (PointFloat2(texture_pos0.x / _bowl_img_width, (_bowl_img_height - texture_pos0.y) / _bowl_img_height));
+
+ PointFloat3 world_pos1 =
+ bowl_view_image_to_world (
+ _config, _bowl_img_width, _bowl_img_height, texture_pos1);
+
+ vertices.push_back (PointFloat3(world_pos1.x / _config.a, world_pos1.y / _config.b, world_pos1.z / _config.c));
+ indeices.push_back (indicator++);
+ texture_points.push_back (PointFloat2(texture_pos1.x / _bowl_img_width, (_bowl_img_height - texture_pos1.y) / _bowl_img_height));
}
+
+ indeices.push_back (XCAM_GL_RESTART_FIXED_INDEX);
}
return true;
}
diff --git a/xcore/interface/stitcher.h b/xcore/interface/stitcher.h
index 39b875e..24a9ee8 100644
--- a/xcore/interface/stitcher.h
+++ b/xcore/interface/stitcher.h
@@ -215,6 +215,7 @@ class BowlModel {
public:
typedef std::vector<PointFloat3> VertexMap;
typedef std::vector<PointFloat2> PointMap;
+ typedef std::vector<int32_t> IndexVector;
public:
BowlModel (const BowlDataConfig &config, const uint32_t image_width, const uint32_t image_height);
@@ -224,8 +225,8 @@ public:
uint32_t res_width, uint32_t res_height,
float length_mm = 0.0f, float width_mm = 0.0f);
- bool get_bowlview_vertex_map (
- VertexMap &vertices, PointMap &texture_points,
+ bool get_bowlview_vertex_model (
+ VertexMap &vertices, PointMap &texture_points, IndexVector &indeices,
uint32_t res_width, uint32_t res_height);
private: