| 1 |
//////////////////////////////////////////////////////////////////////////// |
| 2 |
// File: ProgramCU.h |
| 3 |
// Author: Changchang Wu |
| 4 |
// Description : interface for the ProgramCU classes. |
| 5 |
// It is basically a wrapper around all the CUDA kernels |
| 6 |
// |
| 7 |
// Copyright (c) 2007 University of North Carolina at Chapel Hill |
| 8 |
// All Rights Reserved |
| 9 |
// |
| 10 |
// Permission to use, copy, modify and distribute this software and its |
| 11 |
// documentation for educational, research and non-profit purposes, without |
| 12 |
// fee, and without a written agreement is hereby granted, provided that the |
| 13 |
// above copyright notice and the following paragraph appear in all copies. |
| 14 |
// |
| 15 |
// The University of North Carolina at Chapel Hill make no representations |
| 16 |
// about the suitability of this software for any purpose. It is provided |
| 17 |
// 'as is' without express or implied warranty. |
| 18 |
// |
| 19 |
// Please send BUG REPORTS to [email protected] |
| 20 |
// |
| 21 |
//////////////////////////////////////////////////////////////////////////// |
| 22 |
|
| 23 |
#ifndef _PROGRAM_CU_H |
| 24 |
#define _PROGRAM_CU_H |
| 25 |
#if defined(SIFTGPU_CUDA_ENABLED) |
| 26 |
|
| 27 |
class CuTexImage; |
| 28 |
|
| 29 |
class ProgramCU |
| 30 |
{ |
| 31 |
public: |
| 32 |
//GPU FUNCTIONS |
| 33 |
static void FinishCUDA(); |
| 34 |
static int CheckErrorCUDA(const char* location); |
| 35 |
static int CheckCudaDevice(int device); |
| 36 |
public: |
| 37 |
////SIFTGPU FUNCTIONS |
| 38 |
static void CreateFilterKernel(float sigma, float* kernel, int& width); |
| 39 |
template<int KWIDTH> static void FilterImage(CuTexImage *dst, CuTexImage *src, CuTexImage* buf); |
| 40 |
static void FilterImage(CuTexImage *dst, CuTexImage *src, CuTexImage* buf, float sigma); |
| 41 |
static void ComputeDOG(CuTexImage* gus, CuTexImage* dog, CuTexImage* got); |
| 42 |
static void ComputeKEY(CuTexImage* dog, CuTexImage* key, float Tdog, float Tedge); |
| 43 |
static void InitHistogram(CuTexImage* key, CuTexImage* hist); |
| 44 |
static void ReduceHistogram(CuTexImage*hist1, CuTexImage* hist2); |
| 45 |
static void GenerateList(CuTexImage* list, CuTexImage* hist); |
| 46 |
static void ComputeOrientation(CuTexImage*list, CuTexImage* got, CuTexImage*key, |
| 47 |
float sigma, float sigma_step, int existing_keypoint); |
| 48 |
static void ComputeDescriptor(CuTexImage*list, CuTexImage* got, CuTexImage* dtex, int rect = 0, int stream = 0); |
| 49 |
|
| 50 |
//data conversion |
| 51 |
static void SampleImageU(CuTexImage *dst, CuTexImage *src, int log_scale); |
| 52 |
static void SampleImageD(CuTexImage *dst, CuTexImage *src, int log_scale = 1); |
| 53 |
static void ReduceToSingleChannel(CuTexImage* dst, CuTexImage* src, int convert_rgb); |
| 54 |
static void ConvertByteToFloat(CuTexImage*src, CuTexImage* dst); |
| 55 |
|
| 56 |
//visualization |
| 57 |
static void DisplayConvertDOG(CuTexImage* dog, CuTexImage* out); |
| 58 |
static void DisplayConvertGRD(CuTexImage* got, CuTexImage* out); |
| 59 |
static void DisplayConvertKEY(CuTexImage* key, CuTexImage* dog, CuTexImage* out); |
| 60 |
static void DisplayKeyPoint(CuTexImage* ftex, CuTexImage* out); |
| 61 |
static void DisplayKeyBox(CuTexImage* ftex, CuTexImage* out); |
| 62 |
|
| 63 |
//SIFTMATCH FUNCTIONS |
| 64 |
static void MultiplyDescriptor(CuTexImage* tex1, CuTexImage* tex2, CuTexImage* texDot, CuTexImage* texCRT); |
| 65 |
static void MultiplyDescriptorG(CuTexImage* texDes1, CuTexImage* texDes2, |
| 66 |
CuTexImage* texLoc1, CuTexImage* texLoc2, CuTexImage* texDot, CuTexImage* texCRT, |
| 67 |
float* H, float hdistmax, float* F, float fdistmax, |
| 68 |
int use_h, int use_f); |
| 69 |
// Guided matching against an essential matrix using per-feature bearing |
| 70 |
// vectors and unprojection Jacobians (12 floats per feature). |
| 71 |
static void MultiplyDescriptorGRay(CuTexImage* texDes1, CuTexImage* texDes2, |
| 72 |
CuTexImage* texLoc1, CuTexImage* texLoc2, CuTexImage* texDot, CuTexImage* texCRT, |
| 73 |
float* E, float edistmax); |
| 74 |
static void GetRowMatch(CuTexImage* texDot, CuTexImage* texMatch, float distmax, float ratiomax); |
| 75 |
static void GetColMatch(CuTexImage* texCRT, CuTexImage* texMatch, float distmax, float ratiomax); |
| 76 |
}; |
| 77 |
|
| 78 |
#endif |
| 79 |
#endif |
| 80 |
|