Go to the documentation of this file.00001
00008 #include <blort/Recognizer3D/DetectGPUSIFT.hh>
00009 #include <blort/Recognizer3D/SDraw.hh>
00010
00011 namespace P
00012 {
00013
00014 DetectGPUSIFT::DetectGPUSIFT()
00015 {
00016
00017
00018
00019 char * argv[] = {"-m", "-fo","-1", "-s", "-v", "0", "-pack"};
00020
00021
00022
00023 int argc = sizeof(argv)/sizeof(char*);
00024 sift = new SiftGPU;
00025 sift->ParseParam(argc, argv);
00026
00027
00028 if(sift->CreateContextGL() != SiftGPU::SIFTGPU_FULL_SUPPORTED)
00029 throw Except(__HERE__,"SiftGPU is not fully supported");
00030 }
00031
00032 DetectGPUSIFT::~DetectGPUSIFT()
00033 {
00034 delete sift;
00035 }
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 void DetectGPUSIFT::Operate(IplImage *img, Array<KeypointDescriptor*> &keys)
00050 {
00051 for (unsigned i=0; i<keys.Size(); i++)
00052 delete keys[i];
00053 keys.Clear();
00054
00055 if (img->depth != IPL_DEPTH_8U && img->nChannels!=1)
00056 throw Except(__HERE__,"Wrong image type!");
00057
00058 if(sift->RunSIFT(img->width, img->height,(unsigned char *)img->imageData,GL_LUMINANCE,GL_UNSIGNED_BYTE))
00059 {
00060 KeypointDescriptor *k;
00061
00062 int num = sift->GetFeatureNum();
00063 if (num>0)
00064 {
00065 Array<SiftGPU::SiftKeypoint> ks(num);
00066 Array<SIFTDescriptor> desc(num);
00067
00068 sift->GetFeatureVector(&ks[0], (float*)&desc[0]);
00069
00070
00071 for (unsigned i=0; i<desc.Size(); i++)
00072 {
00073 k = new KeypointDescriptor(KeypointDescriptor::DOG_SIFT, ks[i].x,ks[i].y,ks[i].s, -ks[i].o);
00074 k->AllocVec(128);
00075 CopyVec((float*)&desc[i], k->vec, 128);
00076
00077 keys.PushBack(k);
00078 }
00079 }else cout<<"[DetectGPUSIFT::Operate] No SIFT found"<<endl;
00080 }else throw Except(__HERE__, "SiftGPU Error!");
00081
00082 }
00083
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111 void DetectGPUSIFT::Draw(IplImage *img, Array<KeypointDescriptor*> &keys)
00112 {
00113 for (unsigned i=0; i<keys.Size(); i++)
00114 {
00115 keys[i]->Draw(img,*keys[i],CV_RGB(255,0,0));
00116 }
00117 }
00118
00119
00120
00121 }
00122
blort
Author(s): Michael Zillich,
Thomas Mörwald,
Johann Prankl,
Andreas Richtsfeld,
Bence Magyar (ROS version)
autogenerated on Thu Jan 2 2014 11:38:25