Compare commits

...

10 Commits

Author SHA1 Message Date
Jordan b84d40fd14 can compute matches! no errors! yay! 2024-04-05 11:04:28 -07:00
Jordan e1137844ac use main image describer as reference. 2024-04-03 07:39:37 -07:00
Jordan 301fc2ca75 add 200 frames. 2024-03-27 11:05:48 -07:00
Jordan 3022adcbb7 frame tests complete successfully. 2024-03-23 10:44:50 -07:00
Jordan Hewitt 2e304394e5 add workflow cpp. 2024-03-22 17:27:54 -07:00
Jordan 7d225729ec start developing unit tests for frames. 2024-03-22 09:07:04 -07:00
Jordan Hewitt d85c25b21e began writing my own matching alg. 2024-03-20 09:42:18 -07:00
Jordan fe5ecdeec1 fix image testcase. continue with sfm implementation. 2024-03-17 19:30:23 -07:00
Jordan 2f80cb3e55 rename project in pubspect. testing streamingview. 2024-03-15 08:22:44 -07:00
Jordan 59daf14ee4 add link to financial contribution. 2024-03-13 10:29:23 -07:00
218 changed files with 804 additions and 139 deletions
+3
View File
@@ -5,6 +5,9 @@ OpenMVG bindings for dart.
[OpenMVG](https://openmvg.readthedocs.io/) is an AI graphics application that supports [OpenMVG](https://openmvg.readthedocs.io/) is an AI graphics application that supports
feature detection and surface-from-motion capabilities feature detection and surface-from-motion capabilities
If you'd like to contribute, financially, please visit https://ko-fi.com/damngood and
mention "libdart_openmvg" in your message.
## Getting Started ## Getting Started
This project is a starting point for a Flutter This project is a starting point for a Flutter
Binary file not shown.

After

Width:  |  Height:  |  Size: 466 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 482 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 482 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 482 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 470 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 466 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 470 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 482 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 485 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 486 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 487 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 485 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 482 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 482 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 482 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 470 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 461 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 457 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 455 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 453 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 453 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 470 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 471 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 471 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 470 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 459 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 457 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 456 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 453 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 456 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 482 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 485 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 486 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 489 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 489 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 492 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 494 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 495 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 495 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 486 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 485 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 482 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 471 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 466 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 KiB

+22
View File
@@ -42,6 +42,28 @@ class LibDartOpenMVG {
late final _make_buffer = _make_bufferPtr late final _make_buffer = _make_bufferPtr
.asFunction<ffi.Pointer<FILE> Function(ffi.Pointer<ffi.Uint8>, int)>(); .asFunction<ffi.Pointer<FILE> Function(ffi.Pointer<ffi.Uint8>, int)>();
int read_buffer(
ffi.Pointer<FILE> arg0,
ffi.Pointer<ffi.Pointer<ffi.Uint8>> arg1,
ffi.Pointer<ffi.Size> arg2,
) {
return _read_buffer(
arg0,
arg1,
arg2,
);
}
late final _read_bufferPtr = _lookup<
ffi.NativeFunction<
ffi.Int Function(
ffi.Pointer<FILE>,
ffi.Pointer<ffi.Pointer<ffi.Uint8>>,
ffi.Pointer<ffi.Size>)>>('read_buffer');
late final _read_buffer = _read_bufferPtr.asFunction<
int Function(ffi.Pointer<FILE>, ffi.Pointer<ffi.Pointer<ffi.Uint8>>,
ffi.Pointer<ffi.Size>)>();
ffi.Pointer<Frame> new_frame_from_handle( ffi.Pointer<Frame> new_frame_from_handle(
ffi.Pointer<FILE> arg0, ffi.Pointer<FILE> arg0,
int arg1, int arg1,
+1 -1
View File
@@ -1,4 +1,4 @@
name: dart_openmvg name: libdart_openmvg
description: "Dart Bindings for OpenMVG" description: "Dart Bindings for OpenMVG"
version: 0.0.1 version: 0.0.1
homepage: homepage:
-2
View File
@@ -24,6 +24,4 @@ cmake \
-DCMAKE_BUILD_TYPE=Debug -DCMAKE_BUILD_TYPE=Debug
make make
printf "\033c"
set +e set +e
+1 -1
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
+1 -1
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
+47 -4
View File
@@ -39,6 +39,7 @@ set (LIBDART_OPENMVG_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src)
find_package(JPEG REQUIRED) find_package(JPEG REQUIRED)
find_package(TIFF REQUIRED) find_package(TIFF REQUIRED)
find_package(OpenCV REQUIRED)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extlib/cwalk) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extlib/cwalk)
@@ -59,18 +60,25 @@ set(SKIP_INSTALL_ALL OFF CACHE BOOL "" FORCE) # we only want lib
add_definitions(${PNG_DEFINITIONS}) add_definitions(${PNG_DEFINITIONS})
add_library(${LIBDART_OPENMVG} SHARED add_library(${LIBDART_OPENMVG} SHARED
"mvg_override/describer/akaze.hpp"
"frame.cxx" "frame.cxx"
"streamingview.cxx" "streamingview.cxx"
"image.cxx" "image.cxx"
"util.cpp"
) )
set(CEREAL_INCLUDE_DIR ${OpenMVG_DIR}/../../../include/openMVG_dependencies/cereal/include/cereal/)
dump_cmake_variables("^opencv")
target_include_directories( target_include_directories(
${LIBDART_OPENMVG} ${LIBDART_OPENMVG}
PRIVATE PRIVATE
${FFMPEG_INCLUDE_DIRS} ${FFMPEG_INCLUDE_DIRS}
${PNG_INCLUDE_DIRS} ${PNG_INCLUDE_DIRS}
${ARCHIMEDES_INCLUDE_DIRS} ${ARCHIMEDES_INCLUDE_DIRS}
${OpenMVG_DIR}/../../../include/openMVG_dependencies/cereal/include/cereal/ ${CEREAL_INCLUDE_DIR}
${OpenCV_INCLUDE_DIRS}
) )
target_link_libraries( target_link_libraries(
@@ -79,6 +87,7 @@ target_link_libraries(
jpeg jpeg
tiff tiff
png png
${OpenCV_LIBS}
OpenMVG::openMVG_image OpenMVG::openMVG_image
OpenMVG::openMVG_numeric OpenMVG::openMVG_numeric
OpenMVG::openMVG_features OpenMVG::openMVG_features
@@ -100,6 +109,11 @@ add_executable(
${CMAKE_CURRENT_SOURCE_DIR}/tests/test_image.cxx ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_image.cxx
) )
add_executable(
test_frame
${CMAKE_CURRENT_SOURCE_DIR}/tests/test_frame.cxx
)
target_link_libraries( target_link_libraries(
test_image test_image
cunit cunit
@@ -114,16 +128,40 @@ target_link_libraries(
OpenMVG::openMVG_exif OpenMVG::openMVG_exif
) )
target_link_libraries(
test_frame
cunit
cwalk
${LIBDART_OPENMVG}
png
OpenMVG::openMVG_image
OpenMVG::openMVG_numeric
OpenMVG::openMVG_features
OpenMVG::openMVG_sfm
OpenMVG::openMVG_features
OpenMVG::openMVG_exif
)
target_include_directories( target_include_directories(
test_image test_image
PRIVATE PRIVATE
${LIBDART_OPENMVG_INCLUDE_DIRS} ${LIBDART_OPENMVG_INCLUDE_DIRS}
${OpenMVG_INCLUDE_DIRS}/src ${OpenMVG_INCLUDE_DIRS}/src
${CEREAL_INCLUDE_DIR}
) )
set_target_properties(test_image target_include_directories(
PROPERTIES test_frame
LINKER_LANGUAGE CXX PRIVATE
${LIBDART_OPENMVG_INCLUDE_DIRS}
${OpenMVG_INCLUDE_DIRS}/src
${CEREAL_INCLUDE_DIR}
)
set_target_properties(
test_image
PROPERTIES
LINKER_LANGUAGE CXX
) )
add_test ( add_test (
@@ -131,4 +169,9 @@ add_test (
COMMAND test_image COMMAND test_image
) )
add_test (
NAME test_frame
COMMAND test_frame
)
target_compile_definitions(${LIBDART_OPENMVG} PUBLIC DART_SHARED_LIB) target_compile_definitions(${LIBDART_OPENMVG} PUBLIC DART_SHARED_LIB)
+171 -4
View File
@@ -1,5 +1,7 @@
#include "frame.h" #include "frame.h"
#include <iostream>
#include <stdexcept>
#include <stdlib.h>
FILE *make_buffer(const uint8_t *data, const size_t data_len) FILE *make_buffer(const uint8_t *data, const size_t data_len)
{ {
@@ -20,15 +22,47 @@ FILE *make_buffer(const uint8_t *data, const size_t data_len)
return file; return file;
} }
int read_buffer(FILE *file, uint8_t **buffer, size_t *length)
{
if (file != NULL)
{
// Get the file size
fseek(file, 0, SEEK_END);
(*length) = ftell(file);
fseek(file, 0, SEEK_SET);
const Frame *new_frame_from_data(const uint8_t *data, const size_t data_len, int w, int h, int depth) // Allocate memory
*buffer = (uint8_t *)malloc((*length) * sizeof(char));
if (buffer == NULL)
{
printf("Error: Unable to allocate memory.\n");
return 1;
}
// Read file
size_t newLen = fread(*buffer, sizeof(char), *length, file);
if (newLen == 0)
{
if (feof(file))
{
printf("Error: End of file reached.\n");
return 2;
}
printf("Error: Reading file.\n");
return 3;
}
return 4;
}
return 5;
}
Frame *new_frame_from_data(const uint8_t *data, const size_t data_len, int w, int h, int depth)
{ {
FILE *buf = make_buffer(data, data_len); FILE *buf = make_buffer(data, data_len);
return new_frame_from_handle(buf, w, h, depth); return new_frame_from_handle(buf, w, h, depth);
} }
Frame *new_frame_from_handle(FILE *stream, int w, int h, int depth)
const Frame *new_frame_from_handle(FILE *stream, int w, int h, int depth)
{ {
Frame *f = (Frame *)malloc(sizeof(Frame)); Frame *f = (Frame *)malloc(sizeof(Frame));
f->stream = stream; f->stream = stream;
@@ -37,3 +71,136 @@ const Frame *new_frame_from_handle(FILE *stream, int w, int h, int depth)
f->depth = depth; f->depth = depth;
return f; return f;
} }
void clean_frame(Frame *f)
{
fclose(f->stream);
free(f);
}
#ifdef __cplusplus
DartOpenMvg::Frame::Frame(const DartOpenMvg::Frame &frame)
{
cFrame = frame.cFrame;
// mRegions = std::unique_ptr<openMVG::features::Regions>(frame.mRegions.get());
}
openMVG::image::Image<u_char> DartOpenMvg::imageFromFrame(const CFrame *frame)
{
rewind(frame->stream);
std::vector<unsigned char> imageData;
if (!openMVG::image::ReadPngStream(frame->stream, &imageData, (int *)&(frame->w), (int *)&(frame->h), (int *)&(frame->depth)))
{
throw std::runtime_error("Could not read stream");
};
int w = frame->w, h = frame->h;
Eigen::Matrix<u_char, Eigen::Dynamic, Eigen::Dynamic, 1> eigenMatrix(frame->w, frame->h);
for (int i = 0; i < w * h; ++i)
{
eigenMatrix(i / h, i % h) = imageData[i];
}
return openMVG::image::Image<uint8_t>(eigenMatrix);
}
DartOpenMvg::Frames::Frames(openMVG::sfm::Bundle_Adjustment_Ceres::BA_Ceres_options &options)
{
mAdjustment = openMVG::sfm::Bundle_Adjustment_Ceres(options);
}
void DartOpenMvg::Frames::add_frame(FILE *handle, int w, int h, int depth)
{
CFrame *f = new_frame_from_handle(handle, w, h, depth);
mFrames.push_back(
Frame(f));
}
void DartOpenMvg::Frames::computeMatches()
{
// Match the pairs as a sequence
// Within openMvg::matching_image_collection::Matcher
// they matcha gainst *ALL* images. However, since we know the order of the
// image sequences (video frames), we'll stick to the sequence order.
for (size_t i = 0; i < mFrames.size() - 1; ++i)
{
Frame &frame1 = mFrames[i];
Frame &frame2 = mFrames[i + 1];
frame1.calculateFeatures();
frame2.calculateFeatures();
auto regions1 = frame1.mRegions.get();
auto regions2 = frame2.mRegions.get();
if (!regions1)
{
std::string msg = std::string("No frame. Did you remember to calculate regions for frame ") + std::to_string(i) + "?";
throw std::out_of_range(msg);
}
// regions1->Load();
std::cerr << "Loading " << std::to_string(regions1->RegionCount()) << " regions" << std::endl;
auto is_binary = regions1->IsBinary();
// Initialize the matching interface
const std::unique_ptr<openMVG::matching::RegionsMatcher> matcher =
openMVG::matching::RegionMatcherFactory(openMVG::matching::EMatcherType::HNSW_L2, *regions1);
if (!matcher)
continue;
openMVG::matching::IndMatches vec_putative_matches;
matcher->MatchDistanceRatio(0.5, *regions2, vec_putative_matches);
if (vec_putative_matches.empty())
{
return;
}
mFeatureMap[std::make_pair(i, i + 1)] = vec_putative_matches;
}
};
void DartOpenMvg::Frames::buildTracks()
{
openMVG::tracks::TracksBuilder trackBuilder;
openMVG::matching::PairWiseMatches matches;
trackBuilder.Build(mFeatureMap);
trackBuilder.Filter();
trackBuilder.ExportToSTL(mTracks);
}
void DartOpenMvg::Frames::adjust()
{
const openMVG::sfm::Optimize_Options ba_refine_options(openMVG::cameras::Intrinsic_Parameter_Type::ADJUST_ALL,
openMVG::sfm::Extrinsic_Parameter_Type::ADJUST_ALL, // Adjust camera motion
openMVG::sfm::Structure_Parameter_Type::ADJUST_ALL, // Adjust scene structure
openMVG::sfm::Control_Point_Parameter(),
false);
mAdjustment.Adjust(mSfmData, ba_refine_options);
}
void DartOpenMvg::Frame::calculateFeatures()
{
using namespace openMVG::image;
using namespace openMVG::features;
MvgOverride::AKAZE_OCV_Image_describer desc;
auto im = imageFromFrame(cFrame);
mRegions = desc.Describe(im);
if (!mRegions.get()) {
throw std::range_error("Could not set regions member.");
}
}
void DartOpenMvg::Frames::resection()
{
// openMVG::tracks::TracksUtilsMap::GetFeatIndexPerViewAndTrackId(
// mTracks;
// )
}
openMVG::image::Image<u_char> DartOpenMvg::Frame::getMvgImage()
{
return imageFromFrame(this->cFrame);
}
#endif // __cplusplus
+108 -2
View File
@@ -1,7 +1,46 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include <string>
#include <openMVG/matching/cascade_hasher.hpp>
#include <openMVG/matching/regions_matcher.hpp>
#include <openMVG/matching_image_collection/Matcher.hpp>
#include <openMVG/matching_image_collection/Matcher_Regions.hpp>
#include <openMVG/matching_image_collection/Pair_Builder.hpp>
#include <openMVG/sfm/pipelines/sfm_regions_provider.hpp>
#include <openMVG/sfm/pipelines/sfm_engine.hpp>
#include <openMVG/sfm/sfm_data_BA_ceres.hpp>
#include <openMVG/features/feature.hpp>
#include <openMVG/features/sift/octaver.hpp>
#include <openMVG/features/sift/SIFT_Anatomy_Image_Describer.hpp>
#include <openMVG/features/sift/sift_DescriptorExtractor.hpp>
#include <openMVG/features/sift/sift_KeypointExtractor.hpp>
#include <openMVG/features/akaze/AKAZE.hpp>
#include <openMVG/image/image_container.hpp>
#include <openMVG/image/image_io.hpp>
#include <openMVG/numeric/numeric.h>
#include <openMVG/tracks/tracks.hpp>
#include <opencv2/opencv.hpp>
#include <string>
#include <vector>
#include <memory>
#include <openMVG/matching/indMatch.hpp>
#include <openMVG/matching_image_collection/Matcher_Regions.hpp>
#include <openMVG/matching_image_collection/Matcher.hpp>
#include <openMVG/matching/regions_matcher.hpp>
#include <openMVG/sfm/pipelines/sfm_regions_provider.hpp>
#include <openMVG/system/progressinterface.hpp>
#include <openMVG/system/logger.hpp>
#include <iostream>
#include <map>
#include <utility>
#include "./base.hpp" #include "./base.hpp"
#include "./mvg_override/describer/akaze.hpp"
#ifndef __FRAME_H
#define __FRAME_H
typedef struct _Frame typedef struct _Frame
{ {
@@ -12,9 +51,76 @@ typedef struct _Frame
} Frame; } Frame;
FILE *make_buffer(const uint8_t *, const size_t); FILE *make_buffer(const uint8_t *, const size_t);
int read_buffer(FILE *, uint8_t **, size_t *);
#ifdef __cplusplus
typedef Frame CFrame;
namespace DartOpenMvg
{
openMVG::image::Image<uint8_t> imageFromFrame(const Frame *);
class Frame
{
protected:
std::stringstream mStream;
int mW;
int mH;
int mDepth;
public:
// TODO make this private
const CFrame *cFrame;
// TODO make this private
std::unique_ptr<openMVG::features::Regions> mRegions;
Frame(const CFrame *f) : mW(f->w), mH(f->h), mDepth(f->depth)
{
cFrame = f;
uint8_t *buffer_data = NULL;
size_t len = 0;
rewind(f->stream);
read_buffer(f->stream, &buffer_data, &len);
mStream = std::stringstream(std::string((char *)buffer_data));
}
Frame(const Frame &);
openMVG::image::Image<u_char> getMvgImage();
void calculateFeatures();
};
typedef std::pair<const Frame &, const Frame &> FrameMatchKey;
typedef std::map<std::pair<size_t, size_t>, openMVG::matching::IndMatches> FrameFeatureMatch;
class Frames
{
protected:
public:
// TODO: make private with accessors
openMVG::matching::PairWiseMatches mFeatureMap;
openMVG::tracks::STLMAPTracks mTracks;
openMVG::sfm::SfM_Data mSfmData;
openMVG::sfm::Bundle_Adjustment_Ceres mAdjustment;
std::vector<Frame> mFrames;
Frames(openMVG::sfm::Bundle_Adjustment_Ceres::BA_Ceres_options &);
void add_frame(FILE *, int, int, int);
void computeMatches();
void buildTracks();
void adjust();
void resection();
void resectionAll();
};
}
#endif
_FFI_PLUGIN _FFI_PLUGIN
const Frame *new_frame_from_handle(FILE *, int, int, int); Frame *new_frame_from_handle(FILE *, int, int, int);
_FFI_PLUGIN _FFI_PLUGIN
const 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 *);
#endif // __FRAME_H
+6 -24
View File
@@ -38,7 +38,7 @@ void free_image_result(ImageResult *image_result)
} }
std::vector<u_char> Archimedes::get_image_data_as_vector(const Frame *frame) std::vector<u_char> DartOpenmvg::get_image_data_as_vector(const Frame *frame)
{ {
rewind(frame->stream); rewind(frame->stream);
std::vector<unsigned char> imageData; std::vector<unsigned char> imageData;
@@ -51,7 +51,7 @@ std::vector<u_char> Archimedes::get_image_data_as_vector(const Frame *frame)
#ifdef __cplusplus #ifdef __cplusplus
ImageResult *Archimedes::get_image_data(const Frame *frame) ImageResult *DartOpenmvg::get_image_data(const Frame *frame)
{ {
try { try {
const std::vector<u_char> imageData = get_image_data_as_vector(frame); const std::vector<u_char> imageData = get_image_data_as_vector(frame);
@@ -69,31 +69,13 @@ ImageResult *Archimedes::get_image_data(const Frame *frame)
_FFI_PLUGIN _FFI_PLUGIN
ImageResult *archimedes_get_image_data(const Frame *frame) ImageResult *archimedes_get_image_data(const Frame *frame)
{ {
return Archimedes::get_image_data(frame); return DartOpenmvg::get_image_data(frame);
} }
int Archimedes::images_to_sfm(const Frame **frames, size_t n_frames) int DartOpenmvg::images_to_sfm(const Frame **frames, size_t n_frames)
{ {
using namespace openMVG::sfm; // TODO
const Frame *frame = frames[0];
const std::vector<u_char> imageData = get_image_data_as_vector(frame);
const size_t w = frame->w;
const size_t h = frame->h;
// Create the Eigen matrix and the image
Eigen::Matrix<u_char, Eigen::Dynamic, Eigen::Dynamic, 1> eigenMatrix(w, h);
for (int i = 0; i < w * h; ++i) {
eigenMatrix(i / h, i % h) = imageData[i];
}
openMVG::image::Image bvgImage(eigenMatrix);
SfM_Data sfmData {};
sfmData.views = Views();
return 0; return 0;
} }
@@ -101,5 +83,5 @@ int Archimedes::images_to_sfm(const Frame **frames, size_t n_frames)
_FFI_PLUGIN _FFI_PLUGIN
int archimedes_images_to_sfm(const Frame **frames, size_t n_frames) int archimedes_images_to_sfm(const Frame **frames, size_t n_frames)
{ {
return Archimedes::images_to_sfm(frames, n_frames); return DartOpenmvg::images_to_sfm(frames, n_frames);
} }
+18 -16
View File
@@ -17,6 +17,13 @@
#include <openMVG/sfm/sfm_view.hpp> #include <openMVG/sfm/sfm_view.hpp>
#include <openMVG/system/timer.hpp> #include <openMVG/system/timer.hpp>
#include <openMVG/types.hpp> #include <openMVG/types.hpp>
#include <openMVG/tracks/tracks.hpp>
#include <openMVG/multiview/rotation_averaging.hpp>
#include <openMVG/multiview/rotation_averaging_l1.hpp>
#include <openMVG/multiview/triangulation.hpp>
#include <openMVG/multiview/triangulation_method.hpp>
#include <openMVG/multiview/triangulation_nview.hpp>
#include <openMVG/multiview/translation_averaging_solver.hpp>
// SfM Engines // SfM Engines
#include <openMVG/sfm/pipelines/global/GlobalSfM_rotation_averaging.hpp> #include <openMVG/sfm/pipelines/global/GlobalSfM_rotation_averaging.hpp>
@@ -27,6 +34,16 @@
#include <openMVG/sfm/pipelines/sequential/SfmSceneInitializerMaxPair.hpp> #include <openMVG/sfm/pipelines/sequential/SfmSceneInitializerMaxPair.hpp>
#include <openMVG/sfm/pipelines/sequential/SfmSceneInitializerStellar.hpp> #include <openMVG/sfm/pipelines/sequential/SfmSceneInitializerStellar.hpp>
#include <openMVG/sfm/pipelines/stellar/sfm_stellar_engine.hpp> #include <openMVG/sfm/pipelines/stellar/sfm_stellar_engine.hpp>
#include <openMVG/sfm/sfm_data.hpp>
#include <openMVG/sfm/pipelines/sfm_features_provider.hpp>
#include <openMVG/features/sift/octaver.hpp>
#include <openMVG/features/sift/sift_DescriptorExtractor.hpp>
#include <openMVG/features/sift/hierarchical_gaussian_scale_space.hpp>
#include <openMVG/features/sift/sift_keypoint.hpp>
#include <openMVG/features/sift/SIFT_Anatomy_Image_Describer.hpp>
#include <openMVG/features/feature.hpp>
#endif // __cplusplus #endif // __cplusplus
#include "./base.hpp" #include "./base.hpp"
@@ -48,21 +65,6 @@ extern "C" {
#define error_t int #define error_t int
#ifdef __cplusplus
class StreamedView : openMVG::sfm::View {
private:
const Frame *mFrame;
public:
StreamedView(const Frame *);
};
#endif
typedef struct _ImageResult typedef struct _ImageResult
{ {
@@ -81,7 +83,7 @@ int image_result_free(ImageResult *);
#ifdef __cplusplus #ifdef __cplusplus
namespace Archimedes namespace DartOpenmvg
{ {
std::vector<u_char> get_image_data_as_vector(const Frame *frame); std::vector<u_char> get_image_data_as_vector(const Frame *frame);
ImageResult *get_image_data(const Frame *); ImageResult *get_image_data(const Frame *);
+152
View File
@@ -0,0 +1,152 @@
// This file is part of OpenMVG, an Open Multiple View Geometry C++ library.
// Copyright (c) 2012, 2013 Pierre MOULON.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// The <cereal/archives> headers are special and must be included first.
#include <cereal/archives/json.hpp>
#include "openMVG/image/image_io.hpp"
#include "openMVG/features/regions_factory_io.hpp"
#include "openMVG/sfm/sfm.hpp"
#include "openMVG/system/timer.hpp"
/// OpenCV Includes
#include <opencv2/opencv.hpp>
#include <opencv2/core/eigen.hpp>
#include <cstdlib>
#include <fstream>
#ifndef __MVG_OVERRIDE_DESCRIBER_AKAZE_H
#define __MVG_OVERRIDE_DESCRIBER_AKAZE_H
namespace MvgOverride
{
using namespace openMVG;
using namespace openMVG::image;
using namespace openMVG::features;
using namespace openMVG::sfm;
enum eGeometricModel
{
FUNDAMENTAL_MATRIX = 0,
ESSENTIAL_MATRIX = 1,
HOMOGRAPHY_MATRIX = 2
};
enum ePairMode
{
PAIR_EXHAUSTIVE = 0,
PAIR_CONTIGUOUS = 1,
PAIR_FROM_FILE = 2
};
///
//- Create an Image_describer interface that use an OpenCV feature extraction method
// i.e. with the AKAZE detector+descriptor
//--/!\ If you use a new Regions type you define and register it in
// "openMVG/features/regions_factory.hpp" file.
///
// Reuse the existing AKAZE floating point Keypoint.
typedef features::AKAZE_Float_Regions AKAZE_OpenCV_Regions;
// Define the Interface
class AKAZE_OCV_Image_describer : public Image_describer
{
public:
using Regions_type = AKAZE_OpenCV_Regions;
cv::Ptr<cv::Feature2D> extractor;
AKAZE_OCV_Image_describer() : Image_describer()
{
extractor = cv::AKAZE::create(cv::AKAZE::DESCRIPTOR_KAZE);
}
bool Set_configuration_preset(EDESCRIBER_PRESET preset) override
{
return false;
}
/**
@brief Detect regions on the image and compute their attributes (description)
@param image Image.
@param mask 8-bit gray image for keypoint filtering (optional).
Non-zero values depict the region of interest.
@return regions The detected regions and attributes (the caller must delete the allocated data)
*/
std::unique_ptr<Regions> Describe(
const Image<unsigned char> &image,
const Image<unsigned char> *mask = nullptr) override
{
return Describe_AKAZE_OCV(image, mask);
}
/**
@brief Detect regions on the image and compute their attributes (description)
@param image Image.
@param mask 8-bit gray image for keypoint filtering (optional).
Non-zero values depict the region of interest.
@return regions The detected regions and attributes (the caller must delete the allocated data)
*/
std::unique_ptr<Regions_type> Describe_AKAZE_OCV(
const Image<unsigned char> &image,
const Image<unsigned char> *mask = nullptr)
{
auto regions = std::unique_ptr<Regions_type>(new Regions_type);
cv::Mat img;
cv::eigen2cv(image.GetMat(), img);
cv::Mat m_mask;
if (mask != nullptr)
{
cv::eigen2cv(mask->GetMat(), m_mask);
}
std::vector<cv::KeyPoint> vec_keypoints;
cv::Mat m_desc;
extractor->detectAndCompute(img, m_mask, vec_keypoints, m_desc);
if (!vec_keypoints.empty())
{
// reserve some memory for faster keypoint saving
regions->Features().reserve(vec_keypoints.size());
regions->Descriptors().reserve(vec_keypoints.size());
using DescriptorT = Descriptor<float, 64>;
DescriptorT descriptor;
int cpt = 0;
for (auto i_keypoint = vec_keypoints.begin(); i_keypoint != vec_keypoints.end(); ++i_keypoint, ++cpt)
{
const SIOPointFeature feat((*i_keypoint).pt.x, (*i_keypoint).pt.y, (*i_keypoint).size, (*i_keypoint).angle);
regions->Features().push_back(feat);
memcpy(descriptor.data(),
m_desc.ptr<typename DescriptorT::bin_type>(cpt),
DescriptorT::static_size * sizeof(DescriptorT::bin_type));
regions->Descriptors().push_back(descriptor);
}
}
return regions;
};
/// Allocate Regions type depending of the Image_describer
std::unique_ptr<Regions> Allocate() const override
{
return std::unique_ptr<Regions_type>(new Regions_type);
}
template <class Archive>
void serialize(Archive &ar)
{
}
};
}
#endif // __MVG_OVERRIDE_DESCRIBER_AKAZE_H
+18 -11
View File
@@ -1,15 +1,22 @@
#include "streamingview.hpp" #include "streamingview.hpp"
#include <string.h>
template<class Archive> void libdart_openmvg::StreamingView::load(cereal::BinaryInputArchive &ar) const {
void libdart_openmvg::StreamingView::load(cereal::BinaryOutputArchive &ar) const { uint8_t *data = NULL;
int i = 0; const size_t dLen1 = (mFrame->w * mFrame->h * mFrame->depth * sizeof(uint8_t));
while (i = fgetc(mFrame->stream) != EOF) { size_t sz1 = sizeof(uint8_t) * dLen1;
ar(i); ar.loadBinary(data, sz1);
const size_t dlen2 = sizeof(data) * sizeof(uint8_t);
mFrame->stream = make_buffer(data, dlen2);
rewind(mFrame->stream);
}
void libdart_openmvg::StreamingView::save(cereal::BinaryOutputArchive &ar) const {
uint8_t * data = NULL;
size_t data_len = 0;
int ret = 0;
if(ret = read_buffer(mFrame->stream, &data, &data_len)) {
std::cerr << "ERROR: " << ret << std::endl;
} }
} ar.saveBinary(data, data_len);
template<class Archive>
void libdart_openmvg::StreamingView::save(cereal::BinaryInputArchive &ar) const {
// int i = 0;
// todo
} }
+4 -6
View File
@@ -12,14 +12,12 @@ namespace libdart_openmvg
{ {
private: private:
const Frame *mFrame; Frame *mFrame;
public: public:
StreamingView(const Frame *frame) : mFrame(frame), View () {} StreamingView(Frame *frame) : mFrame(frame), View () {}
template <class Archive> void save(cereal::BinaryOutputArchive &) const;
void save(cereal::BinaryInputArchive &) const; void load(cereal::BinaryInputArchive &) const;
template <class Archive>
void load(cereal::BinaryOutputArchive &) const;
}; };
} }
+130
View File
@@ -0,0 +1,130 @@
#include <sys/stat.h>
#include <archives/binary.hpp>
#include <CUnit/Basic.h>
#include <errno.h>
#include <ios>
#include "../image.h"
#include "../streamingview.hpp"
#include "../util.h"
#include <cwalk.h>
#ifdef __cplusplus
#include <iostream>
#endif // __cplusplus
#define STRLEN 2048
#define FRAME_COUNT 200
typedef Frame CFrame;
char *framePaths[FRAME_COUNT];
#define HERE __FILE__
int setUp(void)
{
char framesDir[STRLEN];
size_t length;
char framePathTpl[STRLEN];
cwk_path_get_dirname(HERE, &length); // archimedes_mobile_lib/src/tests
cwk_path_join(HERE, "../../../assets/test/frames", framesDir, STRLEN);
cwk_path_join(framesDir, "%04d.png", framePathTpl, STRLEN);
// Set the length to be the length of the "template" plus enough room
// for the sequence number.
size_t pathLen = strlen(framePathTpl) + 5;
for (size_t i = 0; i < FRAME_COUNT; ++i)
{
framePaths[i] = (char *)calloc(pathLen, sizeof(char *));
snprintf(framePaths[i], pathLen, framePathTpl, i+1, 4);
printf("Load frame %s\n", framePaths[i]);
}
return 0;
}
CFrame *get_nth_frame(size_t frame_num)
{
struct stat statbuf;
if (stat(framePaths[frame_num], &statbuf) < 0)
{
// std::cerr << "ERROR reading \"" << framePaths << "\"" << std::endl;
std::cerr << std::string("Reading \"") << std::string(framePaths[frame_num]) << std::string("\"") << std::endl;
throw new std::ios_base::failure(std::string(strerror(errno)));
}
FILE *handle = fopen(framePaths[frame_num], "r");
CFrame *f = new_frame_from_handle(
handle,
768,
768,
64);
return f;
}
int tearDown(void)
{
for (int i = 0; i < FRAME_COUNT; ++i)
{
free(framePaths[i]);
}
return 0;
}
void test_calculate_fetures(void)
{
Frame *f = get_nth_frame(0);
DartOpenMvg::Frame frame(f);
frame.calculateFeatures();
CU_ASSERT_TRUE(frame.mRegions.get()->RegionCount() > 0);
}
void test_compute_matches(void)
{
Frame *f1 = get_nth_frame(0);
Frame *f2 = get_nth_frame(1);
DartOpenMvg::Frame frame1(f1), frame2(f2);
openMVG::sfm::Bundle_Adjustment_Ceres::BA_Ceres_options opts;
DartOpenMvg::Frames frames(opts);
frame1.calculateFeatures();
frame2.calculateFeatures();
frames.mFrames.push_back(frame1);
frames.mFrames.push_back(frame2);
CU_ASSERT_EQUAL(frames.mFeatureMap.size(), 0)
frames.computeMatches();
CU_ASSERT_TRUE(frames.mFeatureMap.size() > 0);
}
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)) ||
(NULL == CU_add_test(pSuite, "matches can be computed", test_compute_matches)))
{
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();
}
+64 -64
View File
@@ -1,44 +1,18 @@
#include <archives/binary.hpp>
#include <CUnit/Basic.h> #include <CUnit/Basic.h>
#include "../image.h" #include "../image.h"
#include "../streamingview.hpp"
#include "../util.h"
#include <cwalk.h> #include <cwalk.h>
#ifdef __cplusplus
#include <iostream>
#endif // __cplusplus
#define STRLEN 2048 #define STRLEN 2048
FILE *imageHandle = NULL; FILE *imageHandle = NULL;
char frame1Path[STRLEN]; char frame1Path[STRLEN];
/*
* Read the contents of a file into an array
* path: path to the file
* contents: array we'll write to that contains the contents of the file.
*/
size_t read_file(const char *path, uint8_t **contents) {
FILE *file = fopen(path, "rb");
if (file == NULL) {
printf("Error: Unable to open file.\n");
return 0;
}
// Determine the file size
fseek(file, 0, SEEK_END);
size_t file_size = ftell(file);
rewind(file);
// Allocate memory for the contents array
*contents = (uint8_t *) malloc(file_size);
if (*contents == NULL) {
printf("Error: Unable to allocate memory.\n");
fclose(file);
return 0;
}
// Read the file contents into the array
fread(*contents, 1, file_size, file);
fclose(file);
return file_size;
}
#define HERE __FILE__ #define HERE __FILE__
int setUp(void) int setUp(void)
@@ -54,10 +28,11 @@ int setUp(void)
int tearDown(void) int tearDown(void)
{ {
if (imageHandle) { if (imageHandle)
fclose(imageHandle); {
} fclose(imageHandle);
return 0; }
return 0;
} }
void test_create_frame(void) void test_create_frame(void)
@@ -67,8 +42,7 @@ void test_create_frame(void)
imageHandle, imageHandle,
768, 768,
768, 768,
64 64);
);
CU_ASSERT_PTR_NOT_NULL(f->stream); CU_ASSERT_PTR_NOT_NULL(f->stream);
CU_ASSERT(f->w == 768); CU_ASSERT(f->w == 768);
} }
@@ -89,8 +63,7 @@ void test_archimedes_get_data(void)
imageHandle, imageHandle,
768, 768,
768, 768,
64 64);
);
unsigned char *image_data = NULL; unsigned char *image_data = NULL;
size_t image_data_len = 0; size_t image_data_len = 0;
@@ -100,32 +73,59 @@ void test_archimedes_get_data(void)
CU_ASSERT_TRUE(result->data_len > 0); CU_ASSERT_TRUE(result->data_len > 0);
} }
int main() { void test_archimedes_streamed_view(void)
CU_pSuite pSuite = NULL; {
return ;
imageHandle = fopen(frame1Path, "rw+");
Frame *f = new_frame_from_handle(
imageHandle,
768,
768,
64);
/* initialize the CUnit test registry */ const libdart_openmvg::StreamingView view(f);
if (CUE_SUCCESS != CU_initialize_registry())
return CU_get_error();
/* add a suite to the registry */ std::stringbuf buffer; // empty stringbuf
pSuite = CU_add_suite("ImageSuite", setUp, tearDown);
if (NULL == pSuite) {
CU_cleanup_registry();
return CU_get_error();
}
/* add the tests to the suite */ std::ostream os(&buffer); // associate stream buffer to stream
if ((NULL == CU_add_test(pSuite, "frame can be created", test_create_frame)) || std::istream is(&buffer); // associate stream buffer to stream
(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)))
{
CU_cleanup_registry();
return CU_get_error();
}
/* Run all tests using the CUnit Basic interface */ cereal::BinaryInputArchive inArchive(is);
CU_basic_set_mode(CU_BRM_VERBOSE); cereal::BinaryOutputArchive outArchive(os);
CU_basic_run_tests();
CU_cleanup_registry(); // view.save(outArchive);
return CU_get_error(); view.load(inArchive);
}
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("ImageSuite", 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 can be created", test_create_frame)) ||
(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();
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();
} }
+31
View File
@@ -0,0 +1,31 @@
#include "./util.h"
size_t read_file(const char *path, uint8_t **contents)
{
FILE *file = fopen(path, "rb");
if (file == NULL)
{
printf("Error: Unable to open file.\n");
return 0;
}
// Determine the file size
fseek(file, 0, SEEK_END);
size_t file_size = ftell(file);
rewind(file);
// Allocate memory for the contents array
*contents = (uint8_t *)malloc(file_size);
if (*contents == NULL)
{
printf("Error: Unable to allocate memory.\n");
fclose(file);
return 0;
}
// Read the file contents into the array
fread(*contents, 1, file_size, file);
fclose(file);
return file_size;
}
+10
View File
@@ -0,0 +1,10 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
/*
* Read the contents of a file into an array
* path: path to the file
* contents: array we'll write to that contains the contents of the file.
*/
size_t read_file(const char *path, uint8_t **contents);
+14
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