Skip to content

Commit

Permalink
fake test for initTracker
Browse files Browse the repository at this point in the history
  • Loading branch information
kalwalt committed Oct 24, 2023
1 parent 00d1595 commit 2b66c3b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ target_include_directories(webarkit_test PRIVATE
"${build_opencv_SOURCE_DIR}/libs/opencv/modules/core/include"
"${build_opencv_SOURCE_DIR}/libs/opencv/modules/features2d/include"
"${build_opencv_SOURCE_DIR}/libs/opencv/modules/flann/include"
"${build_opencv_SOURCE_DIR}/libs/opencv/modules/imgcodecs/include"
"${build_opencv_SOURCE_DIR}/libs/opencv/modules/imgproc/include"
"${build_opencv_SOURCE_DIR}/libs/opencv/modules/video/include"
"${build_opencv_SOURCE_DIR}/libs/opencv_contrib/modules/xfeatures2d/include"
Expand All @@ -60,10 +61,12 @@ target_link_libraries(
"${build_opencv_SOURCE_DIR}/lib/libopencv_calib3d.a"
"${build_opencv_SOURCE_DIR}/lib/libopencv_features2d.a"
"${build_opencv_SOURCE_DIR}/lib/libopencv_flann.a"
"${build_opencv_SOURCE_DIR}/lib/libopencv_imgcodecs.a"
"${build_opencv_SOURCE_DIR}/lib/libopencv_video.a"
"${build_opencv_SOURCE_DIR}/lib/libopencv_xfeatures2d.a"
"${build_opencv_SOURCE_DIR}/lib/libopencv_imgproc.a"
"${build_opencv_SOURCE_DIR}/lib/libopencv_core.a"
"${build_opencv_SOURCE_DIR}/3rdparty/lib/liblibopenjp2.a"
"${build_opencv_SOURCE_DIR}/3rdparty/lib/libzlib.a"
GTest::gtest_main
)
Expand Down
Binary file added tests/pinball.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions tests/webarkit_test.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <gtest/gtest.h>
#include <WebARKitManager.h>
#include <WebARKitTrackers/WebARKitOpticalTracking/WebARKitEnums.h>
#include <opencv2/imgcodecs.hpp>

class WebARKitEnumTest : public testing::TestWithParam<std::tuple<webarkit::TRACKER_TYPE, webarkit::ColorSpace>> {};

Expand Down Expand Up @@ -76,4 +77,31 @@ TEST(WebARKitTest, CheckWebARKitVersion) {
manager.initialiseBase(webarkit::TRACKER_TYPE::AKAZE_TRACKER);
// Check if the WebARKit version is correct
EXPECT_STREQ(manager.getWebARKitVersion().c_str(), "1.0.0");
}

TEST(WebARKitTest, InitTrackerTest) {
// Create a WebARKitManager object
webarkit::WebARKitManager manager;
// Init the manager with the Akaze tracker
manager.initialiseBase(webarkit::TRACKER_TYPE::AKAZE_TRACKER);
// Load the test image
cv::Mat image = cv::imread("pinball.jpg");

if(image.data == NULL) {
std::cout << "Something wrong while reading the image!" << std::endl;
}

if(image.empty()) {
image = cv::Mat(2048, 1637, CV_8UC4, cv::Scalar(0, 0, 0, 0));
}

ASSERT_FALSE(image.empty());

int width = image.cols;
int height = image.rows;
unsigned char* data = image.data;
EXPECT_EQ(image.cols, 1637);
EXPECT_EQ(image.rows, 2048);
// Check if initTracker returns sucessfully
EXPECT_TRUE(manager.initTracker(data, width, height));
}

0 comments on commit 2b66c3b

Please sign in to comment.