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

Review casts in PCL, Part B #5508

Prev Previous commit
Next Next commit
Addressed clang-tidy escapes
  • Loading branch information
gnawme committed Jan 12, 2023
commit e6cb9617ea3a7dd13c5b588eacf5beb33ac18573
4 changes: 2 additions & 2 deletions io/src/oni_grabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ pcl::PointCloud<pcl::PointXYZRGB>::Ptr ONIGrabber::convertToXYZRGBPointCloud (
const openni_wrapper::DepthImage::Ptr &depth_image) const
{
static unsigned rgb_array_size = 0;
static boost::shared_array<unsigned char> rgb_array((unsigned char*)nullptr);
static boost::shared_array<unsigned char> rgb_array(nullptr);
static unsigned char* rgb_buffer = nullptr;

pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGB>);
Expand Down Expand Up @@ -496,7 +496,7 @@ pcl::PointCloud<pcl::PointXYZRGBA>::Ptr ONIGrabber::convertToXYZRGBAPointCloud (
const openni_wrapper::DepthImage::Ptr &depth_image) const
{
static unsigned rgb_array_size = 0;
static boost::shared_array<unsigned char> rgb_array((unsigned char*)nullptr);
static boost::shared_array<unsigned char> rgb_array(nullptr);
static unsigned char* rgb_buffer = nullptr;

pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGBA>);
Expand Down
2 changes: 1 addition & 1 deletion io/src/openni2/openni2_video_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace pcl
std::ostream&
operator<< (std::ostream& stream, const OpenNI2VideoMode& video_mode)
{
stream << "Resolution: " << (int)video_mode.x_resolution_ << "x" << (int)video_mode.y_resolution_ <<
stream << "Resolution: " << static_cast<int>(video_mode.x_resolution_) << "x" << static_cast<int>(video_mode.y_resolution_) <<
"@" << video_mode.frame_rate_ <<
"Hz Format: ";

Expand Down
12 changes: 6 additions & 6 deletions io/src/openni2_grabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,8 @@ pcl::io::OpenNI2Grabber::convertToXYZPointCloud (const DepthImage::Ptr& depth_im

float constant_x = 1.0f / device_->getDepthFocalLength ();
float constant_y = 1.0f / device_->getDepthFocalLength ();
float centerX = ((float)cloud->width - 1.f) / 2.f;
float centerY = ((float)cloud->height - 1.f) / 2.f;
float centerX = (static_cast<float>(cloud->width) - 1.f) / 2.f;
float centerY = (static_cast<float>(cloud->height) - 1.f) / 2.f;

if (std::isfinite (depth_parameters_.focal_length_x))
constant_x = 1.0f / static_cast<float> (depth_parameters_.focal_length_x);
Expand Down Expand Up @@ -613,8 +613,8 @@ pcl::io::OpenNI2Grabber::convertToXYZRGBPointCloud (const Image::Ptr &image, con
// Generate default camera parameters
float fx = device_->getDepthFocalLength (); // Horizontal focal length
float fy = device_->getDepthFocalLength (); // Vertcal focal length
float cx = ((float)depth_width_ - 1.f) / 2.f; // Center x
float cy = ((float)depth_height_- 1.f) / 2.f; // Center y
float cx = (static_cast<float>depth_width_) - 1.f) / 2.f; // Center x
float cy = (static_cast<float>(depth_height_)- 1.f) / 2.f; // Center y

// Load pre-calibrated camera parameters if they exist
if (std::isfinite (depth_parameters_.focal_length_x))
Expand Down Expand Up @@ -740,8 +740,8 @@ pcl::io::OpenNI2Grabber::convertToXYZIPointCloud (const IRImage::Ptr &ir_image,

float fx = device_->getDepthFocalLength (); // Horizontal focal length
float fy = device_->getDepthFocalLength (); // Vertcal focal length
float cx = ((float)cloud->width - 1.f) / 2.f; // Center x
float cy = ((float)cloud->height - 1.f) / 2.f; // Center y
float cx = (static_cast<float>(cloud->width) - 1.f) / 2.f; // Center x
float cy = (static_cast<float>(cloud->height) - 1.f) / 2.f; // Center y

// Load pre-calibrated camera parameters if they exist
if (std::isfinite (depth_parameters_.focal_length_x))
Expand Down
4 changes: 2 additions & 2 deletions io/src/openni_grabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,8 @@ pcl::OpenNIGrabber::convertToXYZRGBPointCloud (const openni_wrapper::Image::Ptr
//float constant = 1.0f / device_->getImageFocalLength (depth_width_);
float constant_x = 1.0f / device_->getDepthFocalLength (depth_width_);
float constant_y = 1.0f / device_->getDepthFocalLength (depth_width_);
float centerX = ((float)cloud->width - 1.f) / 2.f;
float centerY = ((float)cloud->height - 1.f) / 2.f;
float centerX = (static_cast<float>(cloud->width) - 1.f) / 2.f;
float centerY = (static_cast<float>(cloud->height) - 1.f) / 2.f;

if (std::isfinite (depth_focal_length_x_))
constant_x = 1.0f / static_cast<float> (depth_focal_length_x_);
Expand Down
4 changes: 2 additions & 2 deletions io/src/real_sense_2_grabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ namespace pcl
RealSense2Grabber::getTextureIdx (const rs2::video_frame & texture, float u, float v)
{
const int w = texture.get_width (), h = texture.get_height ();
int x = std::min (std::max (int (u*w + .5f), 0), w - 1);
int y = std::min (std::max (int (v*h + .5f), 0), h - 1);
int x = std::min (std::max (static_cast<int> (u*w + .5f), 0), w - 1);
int y = std::min (std::max (static_cast<int> (v*h + .5f), 0), h - 1);
return x * texture.get_bytes_per_pixel () + y * texture.get_stride_in_bytes ();
}

Expand Down
2 changes: 1 addition & 1 deletion people/src/hog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ pcl::people::HOG::grad1 (float *I, float *Gx, float *Gy, int h, int w, int x) co
r = 1;
In -= h;
}
if( h<4 || h%4>0 || (std::size_t(I)&15) || (std::size_t(Gx)&15) )
if( h<4 || h%4>0 || (reinterpret_cast<std::size_t>(I)&15) || (reinterpret_cast<std::size_t>(Gx)&15) )
{
for( y = 0; y < h; y++ )
*Gx++ = (*In++ - *Ip++) * r;
Expand Down
2 changes: 1 addition & 1 deletion search/include/pcl/search/impl/flann_search.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ template <typename PointT, typename FlannDistance>
typename pcl::search::FlannSearch<PointT, FlannDistance>::IndexPtr
pcl::search::FlannSearch<PointT, FlannDistance>::KdTreeMultiIndexCreator::createIndex (MatrixConstPtr data)
{
return (static_cast<IndexPtr> (new flann::KDTreeIndex<FlannDistance> (*data, flann::KDTreeIndexParams (trees_))));
return (static_cast<IndexPtr> (new flann::KDTreeIndex<FlannDistance> (*data, static_cast<flann::KDTreeIndexParams> (trees_))));
}

//////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ pcl::ApproximateProgressiveMorphologicalFilter<PointT>::extract (Indices& ground
default(none) \
shared(A, global_min) \
num_threads(threads_)
for (int i = 0; i < (int)input_->size (); ++i)
for (int i = 0; i < static_cast<int>(input_->size ()); ++i)
{
// ...then test for lower points within the cell
PointT p = (*input_)[i];
Expand Down
4 changes: 2 additions & 2 deletions tools/openni2_viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,10 @@ main (int argc, char** argv)

unsigned mode;
if (pcl::console::parse (argc, argv, "-depthmode", mode) != -1)
depth_mode = pcl::io::OpenNI2Grabber::Mode (mode);
depth_mode = static_cast<pcl::io::OpenNI2Grabber::Mode> (mode);

if (pcl::console::parse (argc, argv, "-imagemode", mode) != -1)
image_mode = pcl::io::OpenNI2Grabber::Mode (mode);
image_mode = static_cast<pcl::io::OpenNI2Grabber::Mode> (mode);

if (pcl::console::find_argument (argc, argv, "-xyz") != -1)
xyz = true;
Expand Down