Skip to content

Commit

Permalink
fix opencv examples compilation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Nir-Az committed Mar 3, 2021
1 parent bf7b6fc commit ad7a394
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion wrappers/opencv/depth-filter/rs-depth-filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "tiny-profiler.h"
#include "downsample.h"

rs2_intrinsics operator/(const rs2_intrinsics& i, float f)
rs2_intrinsics operator/(const rs2_intrinsics& i, int f)
{
rs2_intrinsics res = i;
res.width /= f; res.height /= f;
Expand Down
2 changes: 1 addition & 1 deletion wrappers/opencv/dnn/rs-dnn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ int main(int argc, char** argv) try
// but the color did not update, continue
static int last_frame_number = 0;
if (color_frame.get_frame_number() == last_frame_number) continue;
last_frame_number = color_frame.get_frame_number();
last_frame_number = static_cast<int>(color_frame.get_frame_number());

// Convert RealSense frame to OpenCV matrix:
auto color_mat = frame_to_mat(color_frame);
Expand Down
18 changes: 9 additions & 9 deletions wrappers/opencv/latency-tool/latency-detector.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class detector
void end_render()
{
auto duration = std::chrono::high_resolution_clock::now() - _render_start;
_render_time.add(std::chrono::duration_cast<std::chrono::milliseconds>(duration).count());
_render_time.add(static_cast<int>(std::chrono::duration_cast<std::chrono::milliseconds>(duration).count()));
}

~detector()
Expand All @@ -193,7 +193,7 @@ class detector
// to this point in time (when it is first accessible to the application)
auto toa = f.get_frame_metadata(RS2_FRAME_METADATA_TIME_OF_ARRIVAL);
rs2_error* e;
_processing_time.add(rs2_get_time(&e) - toa);
_processing_time.add(static_cast<int>(rs2_get_time(&e) - toa));

auto duration = std::chrono::high_resolution_clock::now() - _start_time;
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
Expand All @@ -212,7 +212,7 @@ class detector
{
auto now = std::chrono::high_resolution_clock::now();
auto duration = now - _start_time;
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
auto ms = static_cast<int>(std::chrono::duration_cast<std::chrono::milliseconds>(duration).count());
auto next = ms % (1 << (_digits - 2));
if (next == _next_value) next++;
_next_value = next;
Expand Down Expand Up @@ -333,8 +333,8 @@ class detector
});
if (circles.size() > 1)
{
int min_x = circles[0][0];
int max_x = circles[circles.size() - 1][0];
int min_x = static_cast<int>(circles[0][0]);
int max_x = static_cast<int>(circles[circles.size() - 1][0]);

int circle_est_size = (max_x - min_x) / (_digits + 1);
min_x += circle_est_size / 2;
Expand All @@ -343,8 +343,8 @@ class detector
_packer.reset();
for (int i = 1; i < circles.size() - 1; i++)
{
const int x = circles[i][0];
const int idx = _digits * ((float)(x - min_x) / (max_x - min_x));
const int x = static_cast<int>(circles[i][0]);
const int idx = static_cast<int>(_digits * ((float)(x - min_x) / (max_x - min_x)));
if (idx >= 0 && idx < _packer.get().size())
_packer.get()[idx] = true;
}
Expand All @@ -354,11 +354,11 @@ class detector
{
if (res == _next_value)
{
auto cropped = r.ms % (1 << (_digits - 2));
auto cropped = static_cast<int>(r.ms) % (1 << (_digits - 2));
if (cropped > res)
{
auto avg_render_time = _render_time.avg();
_latency.add((cropped - res) - avg_render_time);
_latency.add(static_cast<int>((cropped - res) - avg_render_time));
update_instructions();
}
}
Expand Down
6 changes: 3 additions & 3 deletions wrappers/opencv/rotate-pointcloud/rs-rotate-pc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ int main(int argc, char * argv[]) try

// Declare threshold filter for work with dots in range
rs2::threshold_filter threshold;
float threshold_min = 0.3;
float threshold_max = 1.5;
float threshold_min = 0.3f;
float threshold_max = 1.5f;

// Keep dots on the depth frame in range
threshold.set_option(RS2_OPTION_MIN_DISTANCE, threshold_min);
Expand All @@ -84,7 +84,7 @@ int main(int argc, char * argv[]) try
rotated = image;

if ( is_yaw ) {
int rotWidth(threshold_max * 1000);
int rotWidth(static_cast<int>(threshold_max * 1000));

rotated = cv::Mat::zeros(cv::Size(rotWidth, image.size().height), CV_16UC1 );

Expand Down

0 comments on commit ad7a394

Please sign in to comment.