#include #include #include "../image.h" #include "../streamingview.hpp" #include "../util.h" #include #ifdef __cplusplus #include #endif // __cplusplus #define STRLEN 2048 typedef Frame CFrame; FILE *imageHandle = NULL; char frame1Path[STRLEN]; char frame2Path[STRLEN]; #define HERE __FILE__ int setUp(void) { char framesDir[STRLEN]; size_t length; cwk_path_get_dirname(HERE, &length); // archimedes_mobile_lib/src/tests cwk_path_join(HERE, "../../../assets/test/frames", framesDir, STRLEN); cwk_path_join(framesDir, "0001.png", frame1Path, STRLEN); cwk_path_join(framesDir, "0002.png", frame2Path, STRLEN); printf("Opening file %s\n", frame1Path); return 0; } CFrame *get_first_frame() { imageHandle = fopen(frame1Path, "rw+"); CFrame *f = new_frame_from_handle( imageHandle, 768, 768, 64); return f; } CFrame *get_second_frame() { imageHandle = fopen(frame2Path, "rw+"); CFrame *f = new_frame_from_handle( imageHandle, 768, 768, 64); return f; } int tearDown(void) { if (imageHandle) { fclose(imageHandle); } return 0; } void test_calculate_fetures(void) { Frame *f = get_first_frame(); DartOpenMvg::Frame frame(f); frame.calculateFeatures(); CU_ASSERT_TRUE(frame.mRegions.get()->RegionCount() > 0); } void test_compute_matches(void) { Frame *f1 = get_first_frame(); Frame *f2 = get_second_frame(); DartOpenMvg::Frame frame1(f1), frame2(f2); openMVG::sfm::Bundle_Adjustment_Ceres::BA_Ceres_options opts; DartOpenMvg::Frames frames(opts); frames.insert(frame1); frames.insert(frame2); } int main() { CU_pSuite pSuite = NULL; /* initialize the CUnit test registry */ if (CUE_SUCCESS != CU_initialize_registry()) return CU_get_error(); /* add a suite to the registry */ pSuite = CU_add_suite("FrameSuite", setUp, tearDown); if (NULL == pSuite) { CU_cleanup_registry(); return CU_get_error(); } /* add the tests to the suite */ if ((NULL == CU_add_test(pSuite, "frame features can be calculated", test_calculate_fetures))) { CU_cleanup_registry(); return CU_get_error(); } /* Run all tests using the CUnit Basic interface */ CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); CU_cleanup_registry(); return CU_get_error(); }