I have my source file ImageFeatures.cpp. From this file I want to call a cuda file. But I cannot get it to work.
I believe it is because of the include statement “#include “knn_cuda_without_indexes.cu””. The compiler does not understand this because it is inside a cpp file. I am not sure.
I hope you know what it is.
ImageFeatures.cpp
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/gpu/gpu.hpp"
#include <cuda.h>
#include "knn_cuda_without_indexes.cu"
using namespace std;
using namespace cv;
using namespace cv::gpu;
void knn(float* ref_host, int ref_width, float* query_host, int query_width, int height, int k, float* dist_host);
void computeSURFPoints(string path)
{
GpuMat image(imread(path, CV_LOAD_IMAGE_GRAYSCALE));
SURF_GPU surf;
// detecting keypoints & computing descriptors
GpuMat keypointsGPU;
GpuMat descriptorsGPU;
surf(image, GpuMat(), keypointsGPU, descriptorsGPU);
// downloading results
vector<KeyPoint> keypoints;
vector<float> descriptors;
surf.downloadKeypoints(keypointsGPU, keypoints);
surf.downloadDescriptors(descriptorsGPU, descriptors);
cout << "Test" << endl;
}
void computeKnn(int k)
{
float* ref; // Pointer to reference point array
float* query; // Pointer to query point array
float* dist; // Pointer to distance array
int ref_nb = 4096; // Reference point number, max=65535
int query_nb = 4096; // Query point number, max=65535
int dim = 32; // Dimension of points
knn(ref, ref_nb, query, query_nb, dim, k, dist);
}
int main(int argc, char* argv[])
{}
The file knn_cuda_without_indexes.cu is taken from here.
I have tried compiling and linking with:
g++ ImageFeatures.cpp `pkg-config --cflags --libs opencv` -lopencv_gpu
nvcc ImageFeatures.cpp `pkg-config --cflags --libs opencv` -lopencv_gpu
but I get the errors:
ImageFeatures.cpp:7:18: error: cuda.h: No such file or directory
In file included from ImageFeatures.cpp:8:
knn_cuda_without_indexes.cu:54: error: expected constructor, destructor, or type conversion before ‘<’ token
knn_cuda_without_indexes.cu:74: error: expected constructor, destructor, or type conversion before ‘void’