opencv convert to

opencv convert to

  • known conditions
    • source range and target range
    • to get source to target scale
    • target type
  • then convert

example

  • cv 8u1 to cv 32f1

https://stackoverflow.com/questions/12837876/opencv-convertto-returns-white-image-sometimes

When you use convertTo from CV_8U1 to CV_32F1,
a pixel value, for example, 255 becomes 255.0.
But when you try `imshow’ the resulting image,
the command expects all pixel values to be between 0.0 and 1.0.
that’s why, without rescaling the image, the image will look all white.
So this will do the trick as zzz pointed out (thanks).

input.convertTo(output, CV_32F, 1.0 / 255.0);

https://yuiwong.org/gitlab/graphics/cvdoc

CMake if

cmake if

example

message(STATUS "env costmap_2d_INCLUDE_DIR " $ENV{costmap_2d_INCLUDE_DIR})
if (x"$ENV{costmap_2d_INCLUDE_DIR}" STREQUAL x"")
  find_package(costmap_2d REQUIRED)
  message(STATUS "costmap_2d_INCLUDE_DIRS " ${costmap_2d_INCLUDE_DIRS})
  set(costmap_2d_INCLUDE_DIR ${costmap_2d_INCLUDE_DIRS})
else()
  message(STATUS "get costmap_2d_INCLUDE_DIR from env")
  set(costmap_2d_INCLUDE_DIR $ENV{costmap_2d_INCLUDE_DIR})
endif()
message(STATUS "costmap_2d_INCLUDE_DIR " ${costmap_2d_INCLUDE_DIR})

STREQUAL example 2 !!

if("${CV_SIMD128}" STREQUAL "")
  add_definitions(-DCV_SIMD128=1)
else()
  add_definitions(-DCV_SIMD128=${CV_SIMD128})
endif()

https://yuiwong.org/gitlab/documentation/compiler