add workflow cpp.

This commit is contained in:
Jordan Hewitt 2024-03-22 17:27:54 -07:00
parent 7d225729ec
commit 2e304394e5
10 changed files with 71 additions and 19 deletions

View File

@ -11,4 +11,4 @@ DIR=$(cd -P "$(dirname "$SOURCE")" >/dev/null 2>&1 && pwd)
BUILD_DIR=$(realpath ${DIR}/../build) BUILD_DIR=$(realpath ${DIR}/../build)
printf '\033c' printf '\033c'
${BUILD_DIR}/test_image ${BUILD_DIR}/test_frame

View File

@ -10,4 +10,4 @@ DIR=$(cd -P "$(dirname "$SOURCE")" >/dev/null 2>&1 && pwd)
BUILD_DIR=$(realpath ${DIR}/../build) BUILD_DIR=$(realpath ${DIR}/../build)
echo ${BUILD_DIR}/test_image | entr -r ${DIR}/runtests.sh echo ${BUILD_DIR}/test_frame | entr -r ${DIR}/runtests.sh

View File

@ -100,11 +100,13 @@ target_link_options(${LIBDART_OPENMVG} PRIVATE "-Wl,-Bdynamic")
add_executable( add_executable(
test_image test_image
${CMAKE_CURRENT_SOURCE_DIR}/tests/test_image.cxx ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_image.cxx
${CMAKE_CURRENT_SOURCE_DIR}/util.cpp
) )
add_executable( add_executable(
test_frame test_frame
${CMAKE_CURRENT_SOURCE_DIR}/tests/test_image.cxx ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_frame.cxx
${CMAKE_CURRENT_SOURCE_DIR}/util.cpp
) )
target_link_libraries( target_link_libraries(
@ -151,9 +153,10 @@ target_include_directories(
${CEREAL_INCLUDE_DIR} ${CEREAL_INCLUDE_DIR}
) )
set_target_properties(test_image set_target_properties(
PROPERTIES test_image
LINKER_LANGUAGE CXX PROPERTIES
LINKER_LANGUAGE CXX
) )
add_test ( add_test (

@ -1 +1 @@
Subproject commit aff37dd005f85b3589aa50caca13b74ca7bd57e4 Subproject commit 7fd19fc22419a35481d39d2946f77e1dc00df37c

View File

@ -70,6 +70,11 @@ Frame *new_frame_from_handle(FILE *stream, int w, int h, int depth)
return f; return f;
} }
void clean_frame(Frame *f) {
fclose(f->stream);
free(f);
}
#ifdef __cplusplus #ifdef __cplusplus
openMVG::image::Image<u_char> DartOpenMvg::imageFromFrame(const CFrame *frame) openMVG::image::Image<u_char> DartOpenMvg::imageFromFrame(const CFrame *frame)

View File

@ -87,7 +87,7 @@ namespace DartOpenMvg
typedef std::pair<const Frame &, const Frame &> FrameMatchKey; typedef std::pair<const Frame &, const Frame &> FrameMatchKey;
typedef std::map<std::pair<size_t, size_t>, openMVG::matching::IndMatches> FrameFeatureMatch; typedef std::map<std::pair<size_t, size_t>, openMVG::matching::IndMatches> FrameFeatureMatch;
class Frames : protected std::vector<Frame> class Frames : protected std::vector<DartOpenMvg::Frame>
{ {
protected: protected:
@ -112,6 +112,6 @@ Frame *new_frame_from_handle(FILE *, int, int, int);
_FFI_PLUGIN _FFI_PLUGIN
Frame *new_frame_from_data(const uint8_t *, const size_t, int, int, int); Frame *new_frame_from_data(const uint8_t *, const size_t, int, int, int);
void frame_cleanup(Frame **); void frame_cleanup(Frame *);
#endif // __FRAME_H #endif // __FRAME_H

View File

@ -10,8 +10,11 @@
#define STRLEN 2048 #define STRLEN 2048
typedef Frame CFrame;
FILE *imageHandle = NULL; FILE *imageHandle = NULL;
char frame1Path[STRLEN]; char frame1Path[STRLEN];
char frame2Path[STRLEN];
#define HERE __FILE__ #define HERE __FILE__
@ -22,13 +25,14 @@ int setUp(void)
cwk_path_get_dirname(HERE, &length); // archimedes_mobile_lib/src/tests cwk_path_get_dirname(HERE, &length); // archimedes_mobile_lib/src/tests
cwk_path_join(HERE, "../../../assets/test/frames", framesDir, STRLEN); cwk_path_join(HERE, "../../../assets/test/frames", framesDir, STRLEN);
cwk_path_join(framesDir, "0001.png", frame1Path, STRLEN); cwk_path_join(framesDir, "0001.png", frame1Path, STRLEN);
cwk_path_join(framesDir, "0002.png", frame2Path, STRLEN);
printf("Opening file %s\n", frame1Path); printf("Opening file %s\n", frame1Path);
return 0; return 0;
} }
Frame *get_frame() { CFrame *get_first_frame() {
imageHandle = fopen(frame1Path, "rw+"); imageHandle = fopen(frame1Path, "rw+");
Frame *f = new_frame_from_handle( CFrame *f = new_frame_from_handle(
imageHandle, imageHandle,
768, 768,
768, 768,
@ -36,10 +40,17 @@ Frame *get_frame() {
return f; return f;
} }
void destroy_frame() { CFrame *get_second_frame() {
frame_ imageHandle = fopen(frame2Path, "rw+");
CFrame *f = new_frame_from_handle(
imageHandle,
768,
768,
64);
return f;
} }
int tearDown(void) int tearDown(void)
{ {
if (imageHandle) if (imageHandle)
@ -49,7 +60,23 @@ int tearDown(void)
return 0; return 0;
} }
void test_calculate_fetures 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() int main()
{ {
@ -60,7 +87,7 @@ int main()
return CU_get_error(); return CU_get_error();
/* add a suite to the registry */ /* add a suite to the registry */
pSuite = CU_add_suite("ImageSuite", setUp, tearDown); pSuite = CU_add_suite("FrameSuite", setUp, tearDown);
if (NULL == pSuite) if (NULL == pSuite)
{ {
CU_cleanup_registry(); CU_cleanup_registry();
@ -68,10 +95,7 @@ int main()
} }
/* add the tests to the suite */ /* add the tests to the suite */
if ((NULL == CU_add_test(pSuite, "frame can be created", test_create_frame)) || if ((NULL == CU_add_test(pSuite, "frame features can be calculated", test_calculate_fetures)))
(NULL == CU_add_test(pSuite, "frame can be created from data", test_frame_from_data)) ||
(NULL == CU_add_test(pSuite, "data can be retrieved from frame", test_archimedes_get_data)) ||
(NULL == CU_add_test(pSuite, "Streaming view can read & write data", test_archimedes_streamed_view)))
{ {
CU_cleanup_registry(); CU_cleanup_registry();
return CU_get_error(); return CU_get_error();

View File

@ -1,3 +1,5 @@
#include "./util.h"
size_t read_file(const char *path, uint8_t **contents) size_t read_file(const char *path, uint8_t **contents)
{ {
FILE *file = fopen(path, "rb"); FILE *file = fopen(path, "rb");

View File

@ -1,3 +1,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
/* /*
* Read the contents of a file into an array * Read the contents of a file into an array
* path: path to the file * path: path to the file

14
src/workflow.h Normal file
View File

@ -0,0 +1,14 @@
#include <vector>
#ifndef __WORKFLOW_H
#define __WORKFLOW_H
#ifdef __cplusplus
namespace DartOpenmvg {
class MvgWorkflow {
MvgWorkflow();
};
}
#endif // __cplusplus
#endif // __WORKFLOW_H