fix image testcase. continue with sfm implementation.

This commit is contained in:
Jordan 2024-03-17 19:30:23 -07:00
parent 2f80cb3e55
commit fe5ecdeec1
3 changed files with 124 additions and 74 deletions

View File

@ -74,6 +74,7 @@ ImageResult *archimedes_get_image_data(const Frame *frame)
int Archimedes::images_to_sfm(const Frame **frames, size_t n_frames)
{
// https://openmvg.readthedocs.io/en/latest/openMVG/sfm/sfm/#structure-computation-from-known-camera-poses
using namespace openMVG::sfm;
const Frame *frame = frames[0];
@ -91,9 +92,35 @@ int Archimedes::images_to_sfm(const Frame **frames, size_t n_frames)
openMVG::image::Image bvgImage(eigenMatrix);
// Extract the features from the image
openMVG::features::SIFT_Anatomy_Image_describer desc;
std::unique_ptr<openMVG::features::SIFT_Anatomy_Image_describer::Regions_type> siftanatomy = desc.Describe_SIFT_Anatomy(bvgImage);
openMVG::features::SIOPointFeatures features = siftanatomy.get()->Features();
SfM_Data sfmData {};
sfmData.views = Views();
openMVG::features::SIOPointFeature feature = features.at(0);
Eigen::MatrixBase<Eigen::Vector2f> mat1 = feature.coords().matrix();
openMVG::TriangulateNView(mat1);
// SfM_Data sfmData {};
// sfmData.views = Views();
openMVG::sfm::GlobalSfM_Rotation_AveragingSolver rotSolver;
openMVG::sfm::GlobalSfM_Translation_AveragingSolver tranSolver;
openMVG::sfm::SfM_Data_Structure_Computation_Blind computation;
openMVG::rotation_averaging::RelativeRotation relRot;
openMVG::rotation_averaging::RelativeRotations relativeRot_in;
// rotSolver.Run(
// openMVG::sfm::ERotationAveragingMethod::ROTATION_AVERAGING_L1,
// openMVG::sfm::ERelativeRotationInferenceMethod::TRIPLET_ROTATION_INFERENCE_COMPOSITION_ERROR,
// relativeRot_in,
// map_globalR,
// );
return 0;

View File

@ -17,6 +17,13 @@
#include <openMVG/sfm/sfm_view.hpp>
#include <openMVG/system/timer.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
#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/SfmSceneInitializerStellar.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
#include "./base.hpp"

View File

@ -17,9 +17,11 @@ char frame1Path[STRLEN];
* 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) {
size_t read_file(const char *path, uint8_t **contents)
{
FILE *file = fopen(path, "rb");
if (file == NULL) {
if (file == NULL)
{
printf("Error: Unable to open file.\n");
return 0;
}
@ -31,7 +33,8 @@ size_t read_file(const char *path, uint8_t **contents) {
// Allocate memory for the contents array
*contents = (uint8_t *)malloc(file_size);
if (*contents == NULL) {
if (*contents == NULL)
{
printf("Error: Unable to allocate memory.\n");
fclose(file);
return 0;
@ -59,7 +62,8 @@ int setUp(void)
int tearDown(void)
{
if (imageHandle) {
if (imageHandle)
{
fclose(imageHandle);
}
return 0;
@ -72,8 +76,7 @@ void test_create_frame(void)
imageHandle,
768,
768,
64
);
64);
CU_ASSERT_PTR_NOT_NULL(f->stream);
CU_ASSERT(f->w == 768);
}
@ -94,8 +97,7 @@ void test_archimedes_get_data(void)
imageHandle,
768,
768,
64
);
64);
unsigned char *image_data = NULL;
size_t image_data_len = 0;
@ -105,29 +107,32 @@ void test_archimedes_get_data(void)
CU_ASSERT_TRUE(result->data_len > 0);
}
void test_archimedes_streamed_view(void) {
void test_archimedes_streamed_view(void)
{
return ;
imageHandle = fopen(frame1Path, "rw+");
Frame *f = new_frame_from_handle(
imageHandle,
768,
768,
64
);
64);
const libdart_openmvg::StreamingView view(f);
std::cerr << "OPENING " << frame1Path << std::endl;
std::ifstream inStream(std::string(frame1Path), std::ios::in | std::ios::binary);
std::ofstream outStream;
std::stringbuf buffer; // empty stringbuf
cereal::BinaryInputArchive inArchive(inStream);
cereal::BinaryOutputArchive outArchive(outStream);
std::ostream os(&buffer); // associate stream buffer to stream
std::istream is(&buffer); // associate stream buffer to stream
cereal::BinaryInputArchive inArchive(is);
cereal::BinaryOutputArchive outArchive(os);
// view.save(outArchive);
view.load(inArchive);
}
int main() {
int main()
{
CU_pSuite pSuite = NULL;
/* initialize the CUnit test registry */
@ -136,7 +141,8 @@ int main() {
/* add a suite to the registry */
pSuite = CU_add_suite("ImageSuite", setUp, tearDown);
if (NULL == pSuite) {
if (NULL == pSuite)
{
CU_cleanup_registry();
return CU_get_error();
}