Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Texture mapping supports more precise camera model. #352

Merged
merged 4 commits into from
Dec 14, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions surface/include/pcl/surface/impl/texture_mapping.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1042,12 +1042,29 @@ pcl::TextureMapping<PointInT>::getPointUVCoordinates(const pcl::PointXYZ &pt, co
// compute image center and dimension
double sizeX = cam.width;
double sizeY = cam.height;
double cx = sizeX / 2.0;
double cy = sizeY / 2.0;
double cx, cy;
if (cam.center_w > 0)
cx = cam.center_w;
else
cx = sizeX / 2.0;
if (cam.center_h > 0)
cy = cam.center_h;
else
cy = sizeY / 2.0;

double focal_x, focal_y;
if (cam.focal_length_w > 0)
focal_x = cam.focal_length_w;
else
focal_x = cam.focal_length;
if (cam.focal_length_h > 0)
focal_y = cam.focal_length_h;
else
focal_y = cam.focal_length;

// project point on camera's image plane
UV_coordinates.x = static_cast<float> ((cam.focal_length * (pt.x / pt.z) + cx) / sizeX); //horizontal
UV_coordinates.y = 1.0f - static_cast<float> ((cam.focal_length * (pt.y / pt.z) + cy) / sizeY); //vertical
UV_coordinates.x = static_cast<float> ((focal_x * (pt.x / pt.z) + cx) / sizeX); //horizontal
UV_coordinates.y = 1.0f - static_cast<float> ((focal_y * (pt.y / pt.z) + cy) / sizeY); //vertical

// point is visible!
if (UV_coordinates.x >= 0.0 && UV_coordinates.x <= 1.0 && UV_coordinates.y >= 0.0 && UV_coordinates.y <= 1.0)
Expand Down
42 changes: 35 additions & 7 deletions surface/include/pcl/surface/texture_mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,26 @@ namespace pcl
namespace texture_mapping
{

/** \brief Structure to store camera pose and focal length. */
/** \brief Structure to store camera pose and focal length.
*
* One can assign a value to focal_length, to be used along
* both camera axes or, optionally, axis-specific values
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why you remove the initializers here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

I used a constructor to initialize the new variables. I'll will be a
few hours before I can tend to the recommended changes.

On 13-11-08 09:32 AM, Jochen Sprickerhof wrote:

In surface/include/pcl/surface/texture_mapping.h:

@@ -53,14 +53,27 @@
/** \brief Structure to store camera pose and focal length. */
struct Camera
{

  •  Camera () : pose (), focal_length (), height (), width (), texture_file () {}
    

Any reason why you remove the initializers here?


Reply to this email directly or view it on GitHub
https://github.com/PointCloudLibrary/pcl/pull/352/files#r7525660.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted. Used original style initializer.

On 13-11-08 09:32 AM, Jochen Sprickerhof wrote:

In surface/include/pcl/surface/texture_mapping.h:

@@ -53,14 +53,27 @@
/** \brief Structure to store camera pose and focal length. */
struct Camera
{

  •  Camera () : pose (), focal_length (), height (), width (), texture_file () {}
    

Any reason why you remove the initializers here?


Reply to this email directly or view it on GitHub
https://github.com/PointCloudLibrary/pcl/pull/352/files#r7525660.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add the new parameters to the documentation above as well?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added parameter descriptions. I am not familiar with doxygen, thus
unsure if the changes will propagate properly to the online docs.

On 13-11-09 01:09 PM, Jochen Sprickerhof wrote:

In surface/include/pcl/surface/texture_mapping.h:

@@ -53,14 +53,27 @@
/** \brief Structure to store camera pose and focal length. */
struct Camera
{

  •  Camera () : pose (), focal_length (), height (), width (), texture_file () {}
    

Could you add the new parameters to the documentation above as well?


Reply to this email directly or view it on GitHub
https://github.com/PointCloudLibrary/pcl/pull/352/files#r7546067.

* (focal_length_w and focal_length_h). Optionally, one can
* also specify center-of-focus using parameters
* center_w and center_h. If the center-of-focus is not
* specified, it will be set to the geometric center of
* the camera, as defined by the width and height parameters.
*/
struct Camera
{
Camera () : pose (), focal_length (), height (), width (), texture_file () {}
Camera () : pose (), focal_length (), focal_length_w (-1), focal_length_h (-1),
center_w (-1), center_h (-1), height (), width (), texture_file () {}
Eigen::Affine3f pose;
double focal_length;
double focal_length_w; // optional
double focal_length_h; // optinoal
double center_w; // optional
double center_h; // optional
double height;
double width;
std::string texture_file;
Expand Down Expand Up @@ -187,11 +201,25 @@ namespace pcl
// compute image center and dimension
double sizeX = cam.width;
double sizeY = cam.height;
double cx = (sizeX) / 2.0;
double cy = (sizeY) / 2.0;

double focal_x = cam.focal_length;
double focal_y = cam.focal_length;
double cx, cy;
if (cam.center_w > 0)
cx = cam.center_w;
else
cx = (sizeX) / 2.0;
if (cam.center_h > 0)
cy = cam.center_h;
else
cy = (sizeY) / 2.0;

double focal_x, focal_y;
if (cam.focal_length_w > 0)
focal_x = cam.focal_length_w;
else
focal_x = cam.focal_length;
if (cam.focal_length_h>0)
focal_y = cam.focal_length_h;
else
focal_y = cam.focal_length;

// project point on image frame
UV_coordinates[0] = static_cast<float> ((focal_x * (pt.x / pt.z) + cx) / sizeX); //horizontal
Expand Down