Skip to content
Snippets Groups Projects
Commit e34916da authored by Sebastian Gomez-Gonzalez's avatar Sebastian Gomez-Gonzalez
Browse files

Fixing problems of compilation in the GPU

parent 379c2e87
Branches
Tags
No related merge requests found
......@@ -11,7 +11,11 @@ if (CUDA_FOUND)
endif (CUDA_FOUND)
if (WITH_CUDA)
include_directories(${CUDA_INCLUDE_DIRS})
include_directories(
${CUDA_INCLUDE_DIRS}
include
)
add_definitions(-DWITH_CUDA)
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -std=c++11 -arch=sm_30" )
cuda_add_library(cu_ball_track SHARED
src/cuda/img_proc.cu
......@@ -22,7 +26,6 @@ if (WITH_CUDA)
set(GPU_BT_LIB
cu_ball_track
)
add_definitions(-DWITH_CUDA)
endif(WITH_CUDA)
include_directories(include
......@@ -40,6 +43,7 @@ target_link_libraries(ball_tracking
${GPU_BT_LIB}
)
#Compile with C++11 support only
if(NOT MSVC AND (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")))
include(CheckCXXCompilerFlag)
......@@ -66,6 +70,3 @@ install(TARGETS ball_tracking DESTINATION lib)
install(FILES include/json.hpp DESTINATION include)
install(DIRECTORY include/ball_tracking DESTINATION include)
if (PYLIB)
endif (PYLIB)
......@@ -123,7 +123,8 @@ int main(int argc, char** argv) {
//3) Run blob detection algorithm (In CPU)
start_t = std::chrono::steady_clock::now();
auto key_pts = bf(bin_img);
gpu_l_lh.download(l_lh);
auto key_pts = bf(l_lh);
end_t = std::chrono::steady_clock::now();
blob_time.push_back(std::chrono::duration_cast<std::chrono::microseconds>(end_t - start_t).count());
......@@ -133,7 +134,6 @@ int main(int argc, char** argv) {
//4) Compute output image
start_t = std::chrono::steady_clock::now();
gpu_l_lh.download(l_lh);
drawKeypoints(img, key_pts, res(Rect(0,0,in_size.width,in_size.height)),
Scalar(255,255,0), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
normalize(l_lh, tmp, 0, 1, NORM_MINMAX);
......
......@@ -5,6 +5,11 @@
#include <algorithm>
#include <json.hpp>
#ifdef WITH_CUDA
#include <ball_tracking/cuda/tracker.hpp>
#include <opencv2/core.hpp>
#endif
using namespace cv;
using namespace std;
using json = nlohmann::json;
......@@ -235,8 +240,9 @@ namespace ball_tracking {
};
#ifdef WITH_CUDA
#include <ball_tracking/cuda/tracker.hpp>
#include <opencv2/core.hpp>
using namespace cv::cuda;
class GPUTracker {
private:
ball_tracking::cuda::BallLogLikelihood llh; //!< Fully implemented in GPU
......@@ -250,14 +256,14 @@ namespace ball_tracking {
vector<KeyPoint> operator()(cv::InputArray _img) {
Mat img = _img.getMat();
GpuMat gpu_img(img, stream);
GpuMat gpu_img;
GpuMat gpu_llh_img;
gpu_img.upload(img, stream);
llh(gpu_img, gpu_llh_img, stream);
Mat llh_img;
gpu_llh_img.download(llh_img, stream);
stream.waitForCompletion();
return blob_detect(llh_img);
}
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment