Resolution bug Save/load references

This commit is contained in:
Unknown 2018-07-30 16:56:41 +02:00
parent 3e071ff416
commit f3a81b5ce4
74 changed files with 39071 additions and 10139 deletions

View file

@ -535,14 +535,15 @@ bool ASIFT_matcher::saveReferences(const char* ref_path) const
std::ofstream file_key1(ref_path);
if (file_key1.is_open())
{
file_key1<<_nb_refs<<" "<<std::endl;
for(unsigned int i=0; i<_keys.size();i++)
file_key1<<_nb_refs<<" "<<std::endl;
for(unsigned int j=0; j<_keys.size();j++)
{
asift_keypoints kps =_keys[i];
asift_keypoints kps =_keys[j];
// Follow the same convention of David Lowe:
// the first line contains the number of keypoints and the length of the desciptors (128)
// Added number of tilts
file_key1 << _num_keys[i] << " " << VecLength << " " <<std::endl; //<< _num_tilts[i] << " " << std::endl;
// Added sizes
file_key1 << _num_keys[j] << " " << VecLength << " " << _num_tilts[j] << " " <<_size_refs[j].first<<" "<<_size_refs[j].second<<" "<<std::endl;
for (int tt = 0; tt < (int) kps.size(); tt++)
{
for (int rr = 0; rr < (int) kps[tt].size(); rr++)
@ -550,11 +551,11 @@ bool ASIFT_matcher::saveReferences(const char* ref_path) const
keypointslist::iterator ptr = kps[tt][rr].begin();
for(int i=0; i < (int) kps[tt][rr].size(); i++, ptr++)
{
file_key1 << _zoom_refs[i]*ptr->x << " " << _zoom_refs[i]*ptr->y << " " << _zoom_refs[i]*ptr->scale << " " << ptr->angle;
file_key1 << _zoom_refs[j]*ptr->x << " " << _zoom_refs[j]*ptr->y << " " << _zoom_refs[j]*ptr->scale << " " << ptr->angle;
for (int ii = 0; ii < (int) VecLength; ii++)
{
file_key1 << " " << ptr->vec[ii];
file_key1 << " " << ptr->vec[ii];
}
file_key1 << std::endl;
@ -580,14 +581,16 @@ bool ASIFT_matcher::loadReferences(const char* ref_path)
std::ifstream ref_file(ref_path);
std::string line, tmp;
std::stringstream iss;
pair<int,int> size_tmp;
if (ref_file.is_open())
{
std::getline(ref_file, line);
std::string::size_type sz;
_nb_refs = std::stoi(line, &sz); //C++11
// _nb_refs = atoi(line.c_str());
// _nb_refs = std::stoi(line, &sz); //C++11
_nb_refs = atoi(line.c_str());
_keys = std::vector<asift_keypoints>(_nb_refs);
_num_keys = std::vector< int >(_nb_refs);
_size_refs= std::vector< pair<int,int> >(_nb_refs);
_num_tilts = std::vector< int >(_nb_refs,1);
_zoom_refs = std::vector<float>(_nb_refs,1);
for(unsigned int i = 0; i<_nb_refs;i++)
@ -605,27 +608,40 @@ bool ASIFT_matcher::loadReferences(const char* ref_path)
return false;
}
// std::getline(iss,tmp,' ');
std::getline(iss,tmp,' ');
// _num_tilts[i]=atoi(tmp.c_str());
std::getline(iss,tmp,' ');
size_tmp.first=atoi(tmp.c_str());
std::getline(iss,tmp,' ');
size_tmp.second=atoi(tmp.c_str());
_size_refs[i]=size_tmp;
keypointslist list;
for(unsigned int j =0; j<(unsigned int)_num_keys[j];j++)
for(unsigned int j =0; j<(unsigned int)_num_keys[i];j++)
{
keypoint nkp;
std::getline(ref_file, line);
std::stringstream iss(line);
// if(j==0)
// cout<<line<<endl;
std::getline(iss,tmp,' ');
// std::stof(nb_ref, nkp.x); //C++11
nkp.x=atof(tmp.c_str());
// if(j<5)
// cout<<"x : "<<nkp.x<<endl;
std::getline(iss,tmp,' ');
nkp.y=atof(tmp.c_str());
// if(j<5)
// cout<<"y : "<<nkp.y<<endl;
std::getline(iss,tmp,' ');
nkp.scale=atof(tmp.c_str());
// if(j<5)
// cout<<"Scale : "<<nkp.scale<<endl;
std::getline(iss,tmp,' ');
nkp.angle=atof(tmp.c_str());
@ -636,6 +652,13 @@ bool ASIFT_matcher::loadReferences(const char* ref_path)
}
list.push_back(nkp);
// if(j<5)
// {
// cout<<"x : "<<list[j].x<<endl;
// cout<<"y : "<<list[j].y<<endl;
// cout<<"Scale : "<<list[j].scale<<endl;
// }
}
std::vector< keypointslist > vkps(1,list);
asift_keypoints akps(1,vkps);
@ -664,7 +687,7 @@ void ASIFT_matcher::print() const
for(unsigned int k=0; k<_keys[i][j].size();k++)
{
cout<<" "<<k<<" - size :"<<_keys[i][j][k].size()<<endl;
float sx=0,sy=0,ss=0,sa=0, sv=0;
double sx=0,sy=0,ss=0,sa=0, sv=0;
for(unsigned int l=0; l<_keys[i][j][k].size();l++)
{
sx+=_keys[i][j][k][l].x;
@ -675,6 +698,7 @@ void ASIFT_matcher::print() const
{
sv+=_keys[i][j][k][l].vec[v];
}
// cout<<" "<<sx<<"-"<<sy<<"-"<<ss<<"-"<<sa<<"-"<<sv<<endl;
}
cout<<" "<<sx<<"-"<<sy<<"-"<<ss<<"-"<<sa<<"-"<<sv<<endl;
}

View file

@ -66,6 +66,10 @@ unixio.h
zconf.h
./io_png/libs/zlib/zconf.h
/home/harle/catkin_ws/src/BaxterInterface/ASIFT_tests/demo_ASIFT_src/ASIFT_matcher.cpp
ASIFT_matcher.hpp
/home/harle/catkin_ws/src/BaxterInterface/ASIFT_tests/demo_ASIFT_src/ASIFT_matcher.hpp
/home/harle/catkin_ws/src/BaxterInterface/ASIFT_tests/demo_ASIFT_src/ASIFT_matcher.hpp
stdio.h
-
@ -318,10 +322,6 @@ string.h
vector
-
/home/harle/catkin_ws/src/BaxterInterface/ASIFT_tests/demo_ASIFT_src/test_ASIFT.cpp
ASIFT_matcher.hpp
/home/harle/catkin_ws/src/BaxterInterface/ASIFT_tests/demo_ASIFT_src/ASIFT_matcher.hpp
/usr/include/opencv/cv.h
opencv2/core/core_c.h
/usr/include/opencv/opencv2/core/core_c.h

View file

@ -1,21 +1,21 @@
0 20
23 1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
315.018 155.736 260.177 249.244
223.913 244.816 2.56948e-38 1.12989e-38
231.964 208.605 -5.21643e-18 -3.21371e-18
309.751 165.122 1.33215e-38 1.11233e-38
321.857 118.766 0 0
230.253 240.932 0 0
214.152 233.929 9.88742e-41 5.02646e-41
226.483 216.543 0 0
333.71 128.226 -1.75948e-18 -2.95041e-18
232.541 217.373 2.21343e-38 1.2881e-38
218.692 222.244 -5.68496e-18 -3.2052e-18
320.409 248.492 2.14415e-38 4.56393e-39
312.409 253.913 6.79367e-35 1.35834e-35
300.715 265.302 0 0
310.975 163.84 3.91747e-41 3.31785e-41
287.05 158.348 0 0
236.559 230.379 7.13971e-35 3.4433e-35
360.468 133.533 0 0
321.857 118.766 -1.60778e-18 -3.41162e-18

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 KiB

After

Width:  |  Height:  |  Size: 179 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

View file

@ -19,7 +19,7 @@ int main(int argc, char **argv)
char* output_img = "./results/res.png";
char* output_match = "./results/matching.txt";
// char* output_references = "./results/references.txt";
char* output_references = "./results/references.txt";
//////////////////////////////////////////////// Input
// float * iarr1;
@ -137,36 +137,58 @@ int main(int argc, char **argv)
zoom1 = 1;
}
// unsigned int nb_ref =2;
// std::string refData[] = {
// "book_training/train_image_000.png",
// "book_training/train_image_001.png",
// "book_training/train_image_002.png",
// "book_training/train_image_003.png"};
unsigned int nb_ref =21;
unsigned int nb_ref =1;
std::string refData[] = {
"toy_training/obj1bg1__processed__0000_color.jpg",
"toy_training/obj1bg1__processed__0001_color.jpg",
"toy_training/obj1bg1__processed__0002_color.jpg",
"toy_training/obj1bg1__processed__0003_color.jpg",
"toy_training/obj1bg1__processed__0004_color.jpg",
"toy_training/obj1bg1__processed__0005_color.jpg",
"toy_training/obj1bg1__processed__0006_color.jpg",
"toy_training/obj1bg1__processed__0007_color.jpg",
"toy_training/obj1bg1__processed__0008_color.jpg",
"toy_training/obj1bg1__processed__0009_color.jpg",
"toy_training/obj1bg1__processed__0010_color.jpg",
"toy_training/obj1bg1__processed__0011_color.jpg",
"toy_training/obj1bg1__processed__0012_color.jpg",
"toy_training/obj1bg1__processed__0013_color.jpg",
"toy_training/obj1bg1__processed__0014_color.jpg",
"toy_training/obj1bg1__processed__0015_color.jpg",
"toy_training/obj1bg1__processed__0016_color.jpg",
"toy_training/obj1bg1__processed__0017_color.jpg",
"toy_training/obj1bg1__processed__0018_color.jpg",
"toy_training/obj1bg1__processed__0019_color.jpg",
"toy_training/obj1bg1__processed__0020_color.jpg"};
"book_training/train_image_000.png",
"book_training/train_image_001.png",
"book_training/train_image_002.png",
"book_training/train_image_003.png"};
// unsigned int nb_ref =21;
// std::string refData[] = {
// "toy_training/obj1bg0__processed__0000_color.jpg",
// "toy_training/obj1bg0__processed__0001_color.jpg",
// "toy_training/obj1bg0__processed__0002_color.jpg",
// "toy_training/obj1bg0__processed__0003_color.jpg",
// "toy_training/obj1bg0__processed__0004_color.jpg",
// "toy_training/obj1bg0__processed__0005_color.jpg",
// "toy_training/obj1bg0__processed__0006_color.jpg",
// "toy_training/obj1bg0__processed__0007_color.jpg",
// "toy_training/obj1bg0__processed__0008_color.jpg",
// "toy_training/obj1bg0__processed__0009_color.jpg",
// "toy_training/obj1bg0__processed__0010_color.jpg",
// "toy_training/obj1bg0__processed__0011_color.jpg",
// "toy_training/obj1bg0__processed__0012_color.jpg",
// "toy_training/obj1bg0__processed__0013_color.jpg",
// "toy_training/obj1bg0__processed__0014_color.jpg",
// "toy_training/obj1bg0__processed__0015_color.jpg",
// "toy_training/obj1bg0__processed__0016_color.jpg",
// "toy_training/obj1bg0__processed__0017_color.jpg",
// "toy_training/obj1bg0__processed__0018_color.jpg",
// "toy_training/obj1bg0__processed__0019_color.jpg",
// "toy_training/obj1bg0__processed__0020_color.jpg"};
// unsigned int nb_ref =12;
// std::string refData[] = {
// "toy_training/obj11__processed__0036_color.jpg",
// "toy_training/obj11__processed__0037_color.jpg",
// "toy_training/obj11__processed__0038_color.jpg",
// "toy_training/obj11__processed__0039_color.jpg",
// "toy_training/obj11__processed__0040_color.jpg",
// "toy_training/obj11__processed__0041_color.jpg",
// "toy_training/obj11__processed__0042_color.jpg",
// "toy_training/obj11__processed__0043_color.jpg",
// "toy_training/obj11__processed__0044_color.jpg",
// "toy_training/obj11__processed__0045_color.jpg",
// "toy_training/obj11__processed__0046_color.jpg",
// "toy_training/obj11__processed__0047_color.jpg"};
// unsigned int nb_ref =1;
// std::string refData[] = {
// "toy_training/000.png",
// "toy_training/001.png",
// "toy_training/002.png",
// "toy_training/003.png",};
int tilt_ref = 7, tilt_input = 1;
int nb_match;
@ -182,15 +204,19 @@ int main(int argc, char **argv)
time_t tstart, tend;
tstart = time(0);
for(unsigned int i=0; i<nb_ref;i++)
{
matcher.addReference(refData[i].c_str(), tilt_ref);
}
// matcher.saveReferences(output_references);
std::cout<<"Saving..."<<std::endl;
matcher.saveReferences(output_references);
// matcher.print();
// matcher.loadReferences(output_references);
std::cout<<"Loading..."<<std::endl;
matcher.loadReferences(output_references);
// std::cout<<"Saving..."<<std::endl;
// matcher.saveReferences("./results/references2.txt");
// matcher.print();
nb_match = matcher.match(ipixels1_zoom, wS1, hS1, tilt_input);

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 349 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 337 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB