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

split channel example in test #243

Open
wants to merge 1 commit into
base: cygnet-dev
Choose a base branch
from
Open
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
8 changes: 3 additions & 5 deletions cpp/sophus2/calculus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ farm_ng_add_library(sophus2_calculus
)
target_link_libraries(sophus2_calculus INTERFACE sophus2_common)

if(${BUILD_SOPHUS_TESTS})
farm_ng_add_test(region
PARENT_LIBRARY sophus2_calculus
LABELS small)
endif()
farm_ng_add_test(region
PARENT_LIBRARY sophus2_calculus
LABELS small)
28 changes: 13 additions & 15 deletions cpp/sophus2/ceres/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,16 @@ farm_ng_add_library(sophus_ceres
)
target_link_libraries(sophus_ceres INTERFACE sophus2_lie)

if(${BUILD_SOPHUS_TESTS})
find_package(Ceres 2.1.0 REQUIRED)
foreach(test_basename
ceres
manifold
)
farm_ng_add_test(${test_basename}
PARENT_LIBRARY sophus_ceres
LINK_LIBRARIES
Ceres::ceres sophus_ceres
farm_ng_core::farm_ng_core_pipeline
sophus2_sensor
LABELS large)
endforeach()
endif()
find_package(Ceres 2.1.0 REQUIRED)
foreach(test_basename
ceres
manifold
)
farm_ng_add_test(${test_basename}
PARENT_LIBRARY sophus_ceres
LINK_LIBRARIES
Ceres::ceres sophus_ceres
farm_ng_core::farm_ng_core_pipeline
sophus2_sensor
LABELS large)
endforeach()
17 changes: 8 additions & 9 deletions cpp/sophus2/color/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ farm_ng_add_library(sophus2_color
)
target_link_libraries(sophus2_color PUBLIC sophus2_calculus)

if(${BUILD_SOPHUS_TESTS})
foreach(test_basename
color)
farm_ng_add_test(${test_basename}
PARENT_LIBRARY sophus2_color
LINK_LIBRARIES sophus2_color
LABELS small)
endforeach()
endif()
foreach(test_basename
color)
farm_ng_add_test(${test_basename}
PARENT_LIBRARY sophus2_color
LINK_LIBRARIES sophus2_color
LABELS small)
endforeach()

22 changes: 11 additions & 11 deletions cpp/sophus2/geometry/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ farm_ng_add_library(sophus2_geometry
)
target_link_libraries(sophus2_geometry INTERFACE sophus2_lie)

foreach(test_basename
fit_plane
inverse_depth
plane_conv
point_transform
ray)
farm_ng_add_test(${test_basename}
PARENT_LIBRARY sophus2_geometry
LINK_LIBRARIES sophus2_geometry
LABELS small)
endforeach()
foreach(test_basename
fit_plane
inverse_depth
plane_conv
point_transform
ray)
farm_ng_add_test(${test_basename}
PARENT_LIBRARY sophus2_geometry
LINK_LIBRARIES sophus2_geometry
LABELS small)
endforeach()
8 changes: 3 additions & 5 deletions cpp/sophus2/image/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@ target_link_libraries(sophus2_image sophus2_geometry)



if(${BUILD_SOPHUS_TESTS})
foreach(test_basename ${sophus2_image_src_prefixes})
farm_ng_add_test(${test_basename}
foreach(test_basename ${sophus2_image_src_prefixes})
farm_ng_add_test(${test_basename}
PARENT_LIBRARY sophus2_image
LINK_LIBRARIES sophus2_image
LABELS small)
endforeach()
endif()
endforeach()
38 changes: 30 additions & 8 deletions cpp/sophus2/image/dyn_image_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ using namespace sophus2;
} while (false)

TEST(AnyImage, create_access_and_extract) {
const ImageSize size64{6, 4};
ImageSize const size64{6, 4};
MutImage<float> mut_image(size64);
mut_image.fill(0.5f);
Image<float> image(std::move(mut_image));
Expand Down Expand Up @@ -58,7 +58,7 @@ TEST(AnyImage, create_access_and_extract) {
}

TEST(IntensityImage, create_access_and_extract) {
const ImageSize size64{6, 4};
ImageSize const size64{6, 4};
MutImage<float> mut_image(size64);
mut_image.fill(0.5f);
Image<float> image(std::move(mut_image));
Expand All @@ -70,7 +70,7 @@ TEST(IntensityImage, create_access_and_extract) {

TEST(AnyImage, runtime_type_info) {
{
const ImageSize size64{6, 4};
ImageSize const size64{6, 4};
MutImage<float> mut_image(size64);
AnyImage<> any_image(std::move(mut_image));

Expand All @@ -88,7 +88,7 @@ TEST(AnyImage, runtime_type_info) {
SOPHUS_ASSERT(maybe_any_image2);
}
{
const ImageSize size64{6, 4};
ImageSize const size64{6, 4};
MutImage<uint8_t> mut_image(size64);
AnyImage<> any_image(std::move(mut_image));

Expand All @@ -98,7 +98,7 @@ TEST(AnyImage, runtime_type_info) {
SOPHUS_ASSERT_EQ(any_image.pixelFormat().num_bytes_per_component, 1);
}
{
const ImageSize size64{6, 4};
ImageSize const size64{6, 4};
MutImage3F32 mut_image(size64);
AnyImage<> any_image(std::move(mut_image));

Expand All @@ -108,7 +108,7 @@ TEST(AnyImage, runtime_type_info) {
SOPHUS_ASSERT_EQ(any_image.pixelFormat().num_bytes_per_component, 4);
}
{
const ImageSize size64{6, 4};
ImageSize const size64{6, 4};
MutImage3U8 mut_image(size64);
AnyImage<> any_image(std::move(mut_image));

Expand All @@ -118,7 +118,7 @@ TEST(AnyImage, runtime_type_info) {
SOPHUS_ASSERT_EQ(any_image.pixelFormat().num_bytes_per_component, 1);
}
{
const ImageSize size64{6, 4};
ImageSize const size64{6, 4};
MutImage<Eigen::Vector4f> mut_image(size64);
AnyImage<> any_image(std::move(mut_image));

Expand All @@ -128,7 +128,7 @@ TEST(AnyImage, runtime_type_info) {
SOPHUS_ASSERT_EQ(any_image.pixelFormat().num_bytes_per_component, 4);
}
{
const ImageSize size64{6, 4};
ImageSize const size64{6, 4};
MutImage4U8 mut_image(size64);
AnyImage<> any_image(std::move(mut_image));

Expand Down Expand Up @@ -278,3 +278,25 @@ TEST(IntensityImage, visitor) {
runtime_sub);
}
}

TEST(IntensityImage, conversion) {
auto typed_rgba_image = Image4U8::makeGenerative(
ImageSize{2, 3},
[](int u, int v) { return Pixel4<uint8_t>{u, 2 * v, 3, 255}; });

auto intensity_image = IntensityImage<>(typed_rgba_image);

FARM_ASSERT(intensity_image.has<Pixel4<uint8_t>>());

auto typed_rgba_image2 = intensity_image.image<Pixel4<uint8_t>>();

auto r_channel_image = sophus2::ImageU8::makeFromTransform(
typed_rgba_image2,
[](Pixel4<uint8_t> rgba_pixel) { return rgba_pixel.x(); });

for (int v = 0; v < r_channel_image.height(); ++v) {
for (int u = 0; u < r_channel_image.width(); ++u) {
SOPHUS_ASSERT_EQ(r_channel_image(u, v), u);
}
}
}
Loading