-
Notifications
You must be signed in to change notification settings - Fork 400
/
ProgramCG.h
161 lines (149 loc) · 5.82 KB
/
ProgramCG.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
////////////////////////////////////////////////////////////////////////////
// File: ProgramCG.h
// Author: Changchang Wu
// Description : interface for the ProgramCG classes.
// ProgramCG: Cg programs
// ShaderBagCG: All Cg shaders for Sift in a bag
// FilterGLCG: Cg Gaussian Filters
//
// Copyright (c) 2007 University of North Carolina at Chapel Hill
// All Rights Reserved
//
// Permission to use, copy, modify and distribute this software and its
// documentation for educational, research and non-profit purposes, without
// fee, and without a written agreement is hereby granted, provided that the
// above copyright notice and the following paragraph appear in all copies.
//
// The University of North Carolina at Chapel Hill make no representations
// about the suitability of this software for any purpose. It is provided
// 'as is' without express or implied warranty.
//
// Please send BUG REPORTS to ccwu@cs.unc.edu
//
////////////////////////////////////////////////////////////////////////////
#if defined(CG_SIFTGPU_ENABLED)
#ifndef _PROGRAM_CG_H
#define _PROGRAM_CG_H
#include "ProgramGPU.h"
class FragmentProgram;
#include "Cg/cgGL.h"
class ProgramCG:public ProgramGPU
{
CGprogram _programID;
CGprofile _profile;
int _valid;
public:
static CGcontext _Context;
static CGprofile _FProfile;
public:
operator CGprogram (){return _programID;}
CGprogram GetProgramID(){return _programID;}
int UseProgram();
int IsValidProgram(){return _programID && _valid;}
static void ErrorCallback();
static void InitContext();
static void DestroyContext();
ProgramCG(const char * code, const char** cg_compile_args= NULL, CGprofile profile = ProgramCG::_FProfile);
ProgramCG();
virtual ~ProgramCG();
};
class ShaderBagCG:public ShaderBag
{
CGparameter _param_dog_texu;
CGparameter _param_dog_texd;
CGparameter _param_genlist_start_tex0;
CGparameter _param_ftex_width;
CGparameter _param_genlist_step_tex;
CGparameter _param_genlist_step_tex0;
CGparameter _param_genvbo_size;
CGparameter _param_orientation_gtex;
CGparameter _param_orientation_stex;
CGparameter _param_orientation_size;
CGparameter _param_descriptor_gtex;
CGparameter _param_descriptor_size;
CGparameter _param_descriptor_dsize;
CGparameter _param_margin_copy_truncate;
CGparameter _param_genlist_init_bbox;
public:
virtual void LoadDescriptorShader();
void LoadDescriptorShaderF2();
static void WriteOrientationCodeToStream(ostream& out);
virtual void SetGenListInitParam(int w, int h);
virtual void SetMarginCopyParam(int xmax, int ymax);
virtual void SetFeatureOrientationParam(int gtex, int width, int height, float sigma, int stex = 0, float step = 1.0f);
virtual void SetFeatureDescirptorParam(int gtex, int otex, float dwidth, float fwidth, float width, float height, float sigma);
virtual void SetSimpleOrientationInput(int oTex, float sigma, float sigma_step);
void LoadOrientationShader();
virtual void SetGenListStartParam(float width, int tex0);
static ProgramCG* LoadGenListStepShader(int start, int step);
static ProgramCG* LoadGenListStepShaderV2(int start, int step);
void LoadGenListShader(int ndoglev, int nlev);
virtual void UnloadProgram();
virtual void SetDogTexParam(int texU, int texD);
virtual void SetGenListStepParam(int tex, int tex0);
virtual void SetGenVBOParam( float width, float fwidth, float size);
virtual void LoadFixedShaders();
virtual void LoadDisplayShaders();
virtual void LoadKeypointShader(float threshold, float edgeThreshold);
virtual int LoadKeypointShaderMR(float threshold, float edgeThreshold);
ShaderBagCG();
virtual ~ShaderBagCG(){}
};
class FilterGLCG : public FilterProgram
{
private:
ProgramGPU* CreateFilterH(float kernel[], float offset[], int width);
ProgramGPU* CreateFilterV(float kernel[], float offset[], int height);
//packed version
ProgramGPU* CreateFilterHPK(float kernel[], float offset[], int width);
ProgramGPU* CreateFilterVPK(float kernel[], float offset[], int height);
};
class ShaderBagPKCG:public ShaderBag
{
private:
CGparameter _param_dog_texu;
CGparameter _param_dog_texd;
CGparameter _param_margin_copy_truncate;
CGparameter _param_grad_pass_texp;
CGparameter _param_genlist_init_bbox;
CGparameter _param_genlist_start_tex0;
CGparameter _param_ftex_width;
CGparameter _param_genlist_step_tex;
CGparameter _param_genlist_step_tex0;
CGparameter _param_genlist_end_ktex;
CGparameter _param_genvbo_size;
CGparameter _param_orientation_gtex;
CGparameter _param_orientation_otex;
CGparameter _param_orientation_size;
CGparameter _param_descriptor_gtex;
CGparameter _param_descriptor_otex;
CGparameter _param_descriptor_size;
CGparameter _param_descriptor_dsize;
public:
ShaderBagPKCG();
virtual ~ShaderBagPKCG(){}
virtual void LoadDescriptorShader();
virtual void LoadDescriptorShaderF2();
virtual void LoadOrientationShader();
virtual void LoadGenListShader(int ndoglev, int nlev);
virtual void LoadGenListShaderV2(int ndoglev, int nlev);
virtual void UnloadProgram() ;
virtual void LoadKeypointShader(float threshold, float edgeTrheshold);
virtual void LoadFixedShaders();
virtual void LoadDisplayShaders();
virtual void SetGradPassParam(int texP);
virtual void SetGenListEndParam(int ktex);
public:
//parameters
virtual void SetGenListStartParam(float width, int tex0);
virtual void SetGenListInitParam(int w, int h);
virtual void SetMarginCopyParam(int xmax, int ymax);
virtual void SetDogTexParam(int texU, int texD);
virtual void SetGenListStepParam(int tex, int tex0);
virtual void SetGenVBOParam( float width, float fwidth, float size);
virtual void SetFeatureDescirptorParam(int gtex, int otex, float dwidth, float fwidth, float width, float height, float sigma);
virtual void SetFeatureOrientationParam(int gtex, int width, int height, float sigma, int stex, float step);
virtual void SetSimpleOrientationInput(int oTex, float sigma, float sigma_step);
};
#endif
#endif