Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add LISRD #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ set(onnxruntime_INCLUDE_DIRS
${onnxruntime_INSTALL_PREFIX}/include/onnxruntime
${onnxruntime_INSTALL_PREFIX}/include/onnxruntime/core/session
)

find_library(onnxruntime_LIBS NAMES onnxruntime PATHS /usr/local/lib)

option(ENABLE_TORCH "ENABLE LibTorch Inference" ON)
if(ENABLE_TORCH)
add_definitions(-DENABLE_TORCH)
set(Torch_DIR "/path/to/libtorch")
find_package(Torch REQUIED)
else()
message(STATUS "DISABLE LibTorch Inference")
endif()

find_package(CUDA QUIET)

if(CUDA_FOUND AND USE_GPU)
Expand Down
19 changes: 19 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,22 @@ target_include_directories(loftr
PUBLIC
${OpenCV_INCLUDE_DIRS}
)

# ---------------------------------------------------------

add_executable(lisrd
${CMAKE_CURRENT_LIST_DIR}/LISRD.cpp
${CMAKE_CURRENT_LIST_DIR}/SuperPoint.cpp
${CMAKE_CURRENT_LIST_DIR}/LISRDApp.cpp
)

target_link_libraries(lisrd
PUBLIC
${PROJECT_NAME}
${OpenCV_LIBS}
)

target_include_directories(lisrd
PUBLIC
${OpenCV_INCLUDE_DIRS}
)
25 changes: 25 additions & 0 deletions examples/LISRD.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* @file SuperPoint.cpp
*
* @author btran
*
*/

#include "Lisrd.hpp"
#include "Utility.hpp"

namespace Ort
{
void Lisrd::preprocess(float* dst, const unsigned char* src, const int64_t targetImgWidth,
const int64_t targetImgHeight, const int numChannels) const
{
for (int i = 0; i < targetImgHeight; ++i) {
for (int j = 0; j < targetImgWidth; ++j) {
for (int c = 0; c < numChannels; ++c) {
dst[c * targetImgHeight * targetImgWidth + i * targetImgWidth + j] =
(src[i * targetImgWidth * numChannels + j * numChannels + c]);
}
}
}
}
}
32 changes: 32 additions & 0 deletions examples/LISRD.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @file SuperPoint.hpp
*
* @author btran
*
*/

#pragma once

#include <opencv2/opencv.hpp>
#include <ort_utility/ort_utility.hpp>
#include <vector>

namespace Ort
{
class Lisrd : public OrtSessionHandler
{
public:
static constexpr int64_t IMG_H = 480;
static constexpr int64_t IMG_W = 640;
static constexpr int64_t IMG_CHANNEL = 3;

using OrtSessionHandler::OrtSessionHandler;

void preprocess(float* dst, //
const unsigned char* src, //
const int64_t targetImgWidth, //
const int64_t targetImgHeight, //
const int numChannels) const;

};
} // namespace Ort
Loading