Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
changchaokun committed May 7, 2019
1 parent 1360f3a commit 0b720dd
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 26 deletions.
2 changes: 1 addition & 1 deletion include/SkyMapMatching.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "SkyMap.h"

#define PIXEL_LENGTH 1.5e-6
#define DEFAULT_FOCAL_LENGTH 4
#define DEFAULT_FOCAL_LENGTH 4e-3

/**
* Below are the running modes of this system.
Expand Down
2 changes: 1 addition & 1 deletion include/extraction.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <vector>

// macros
#define BLOCK 5
#define BLOCK 8
#define ALPHA 5
#define STARS_MAX 200
#define FOOTSTEP 40
Expand Down
2 changes: 1 addition & 1 deletion src/ImageProcessing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ vector<StarPoint> ImageProcessing::Process() {

vector<StarPoint> recList;
for (size_t i=0;i!=centroids.size();i++) {
StarPoint starRec(int(i),centroids[i].first.first,centroids[i].first.second,centroids[i].second);
StarPoint starRec(int(i),centroids[i].first.second,centroids[i].first.first,centroids[i].second);
recList.push_back(starRec);
}
QCSVAdapter pic_csv(QString::fromStdString(this->__gen_picture));
Expand Down
8 changes: 4 additions & 4 deletions src/LPFI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ bool mag_cmp(StarPoint& a,StarPoint& b)
return a.magnitude>b.magnitude;
}

LPFI::LPFI(std::vector<StarPoint> navStarMap,double r=6, int m=200,int n=120,double f=0.004):navStarTable(navStarMap),r(r),m(m),n(n),focal_length(f)
LPFI::LPFI(std::vector<StarPoint> navStarMap,double r=6, int m=100,int n=80,double f=0.004):navStarTable(navStarMap),r(r),m(m),n(n),focal_length(f)
{
qDebug()<<"load sky complete!"<<endl;
load();
Expand Down Expand Up @@ -137,7 +137,7 @@ vector<int> LPFI::calc_LPF(std::vector<StarPoint>& StarTable,StarPoint target,bo
{
if(pic[i][j]==true)
{
tmpvec[i]=j;
tmpvec[i]=j+1;
break;
}
}
Expand Down Expand Up @@ -177,7 +177,7 @@ vector<pair<int,int> > calc_next(vector<int>& v)
{
while(k>-2&&abs(v[k+2]-v[q])>1)
{
if(ec<=1)
if(ec<=2)
{
ec++;
}
Expand Down Expand Up @@ -207,7 +207,7 @@ bool compare(vector<int>& v,vector<int>& p)
{
while(k>-2&&abs(p[k+2]-v[i])>1)
{
if(ec<=1)
if(ec<=2)
{
ec++;
}
Expand Down
46 changes: 28 additions & 18 deletions src/SkyMapMatching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ void SkyMapMatching::LoadImage(QString &f_name,ImageProperties property) {
}

void SkyMapMatching::LoadImage(vector<StarPoint> &stars, ImageProperties property){
for(size_t i=0;i<stars.size();i++){
stars[i].y = property.width_pixel - stars[i].y;
}
if(property.focal_length<1e-6) {
/** property
* if the focal_length = 0, it means the picture hasn't info of focal length.
Expand Down Expand Up @@ -188,7 +191,7 @@ int SkyMapMatching::TriangleModel() {
pTM =new TriangleMatching(sky_.stars_.size(), 15.0, 0.02);
pTM->LoadData(sky_.stars_);
}
assert(this->image_.count_>=3);
//assert(this->image_.count_>=3);
qDebug()<<"focal_length:";
if(this->image_.property.focal_length>1e-6){
qDebug()<<this->image_.property.focal_length;
Expand Down Expand Up @@ -277,7 +280,7 @@ int SkyMapMatching::RCFIModel(){
int SkyMapMatching::LPFIModel(){
if(pLPFI==nullptr)
{
pLPFI = new LPFI(this->sky_.stars_,6,200,120,0.004);
pLPFI = new LPFI(this->sky_.stars_,6,100,80,0.004);
}
if(this->RUNNING_MODE == EVALUATION)
return pLPFI->efind(this->image_.stars_,this->__target_star);
Expand All @@ -299,12 +302,12 @@ void SkyMapMatching::Match(bool* pmodel) {

}
else printf("Triangle Model cannot get answer.\n");
while((skymap_index[0]=this->pTM->GetCandidate())){
if(skymap_index[0] == -1) break;
this->__matching_star = this->sky_.stars_[size_t(skymap_index[0])];
Candidate one("Triangle Model",this->__matching_star);
this->candidates_.push_back(one);
}
// while((skymap_index[0]=this->pTM->GetCandidate())){
// if(skymap_index[0] == -1) break;
// this->__matching_star = this->sky_.stars_[size_t(skymap_index[0])];
// Candidate one("Triangle Model",this->__matching_star);
// this->candidates_.push_back(one);
// }
}
if(pmodel[1])
{
Expand Down Expand Up @@ -361,7 +364,7 @@ bool similar_position(StarPoint &s1, StarPoint &s2){
}

int SkyMapMatching::Check() {
if(this->RUNNING_MODE == EVALUATION){
if(this->RUNNING_MODE == EVALUATION || this->RUNNING_MODE == SIMULATION){
return this->__target_star.index == this->__matching_star.index ? 1:-1;
}
//get the __matching_star's offset in check_set, which should be equal to offset of __target_star in sky_image.
Expand Down Expand Up @@ -704,8 +707,11 @@ GeneratedImage SkyMapMatching::GenerateSimImage(const StarPoint &center, const d
p.x = static_cast<int>(point.x*property.ppmm) + ppi_x/2;
p.y = static_cast<int>(point.y*property.ppmm) + ppi_y/2;
if(p.x < 0 || p.x > ppi_x || p.y < 0 || p.y > ppi_y ) continue;
stars_in_image.push_back(point);
circle(sim_image_shift,p,5,CV_RGB(0,0,255),-1);

StarPoint sp(point.index,p.x,p.y,0.0);
stars_in_image.push_back(sp);

circle(sim_image_shift,p,4,CV_RGB(0,0,255),-1);
}

/**
Expand All @@ -730,7 +736,7 @@ GeneratedImage SkyMapMatching::GenerateSimImage(const StarPoint &center, const d
string path_shift = "./SimImage_"+to_string(count_num)+".jpg";
cv::imwrite(path_shift,sim_image_shift);

return GeneratedImage(sim_image_shift,path_shift,stars,property);
return GeneratedImage(sim_image_shift,path_shift,stars_in_image,property);
}

void SkyMapMatching::GenerateSubSky(const StarPoint &centre, const double &image_ratio, const int &num) {
Expand Down Expand Up @@ -843,12 +849,14 @@ EvalResult SkyMapMatching::ExeEvaluation(bool* model,size_t round,size_t miss_nu

/*Test Simulation...
*/
ImageProperties property(int(1024),int(1024),int(96),double(58.0));
property.length_inch = property.length_pixel*1.0/property.ppi;
property.width_inch = property.width_pixel*1.0/property.ppi;
simResult sim_eval = this->ExeSimulation(model,property,round,fl,fr,miss_num,add_num,off_rate);
cout<<"Simulation result:"<<sim_eval.accuracy<<endl;
//return sim_eval;
// ImageProperties property(int(1024),int(1024),int(96),double(58.0));
// property.length_inch = property.length_pixel*1.0/property.ppi;
// property.width_inch = property.width_pixel*1.0/property.ppi;
// simResult sim_eval = this->ExeSimulation(model,property,round,fl,fr,miss_num,add_num,off_rate);
// cout<<"Simulation result:"<<sim_eval.accuracy<<endl;
// cout<<"Toal number:"<<sim_eval.total_num<<endl;
// cout<<"Error number:"<<sim_eval.error_num<<endl;

return eval;
}

Expand Down Expand Up @@ -900,6 +908,8 @@ simResult SkyMapMatching::ExeSimulation(bool* model,ImageProperties property,siz
}
double ans = (succeed_num)*1.0/(succeed_num+failed_num);
simResult sim;
sim.total_num = succeed_num + failed_num;
sim.error_num = failed_num;
sim.accuracy = (ans);
this->RUNNING_MODE = DEFAULT_MODE;
return sim;
Expand Down
3 changes: 3 additions & 0 deletions src/extraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ vector<pair<pair<double, double>, double>> get_centroids(Mat &img)
p.first.second = block_sum(img, x[i], y[j], 'y', T);
p.first.second = p.first.second / p.second + y[j].first;

// double tmp = p.first.second;
// p.first.second = p.first.first;
// p.first.first = tmp;
centroids.push_back(p);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#define LOADANI(i) loading[((i)/100)%4]
#define simDev 100
#define simDev 5
static QStringList loading={"",".","..","..."};
static QStringList AN={"三角匹配","无标定参数","径向环向特征","Log-Polar"};
MainWindow::MainWindow(QWidget *parent) :
Expand Down

0 comments on commit 0b720dd

Please sign in to comment.