Skip to content
Snippets Groups Projects
Commit 65ad5da7 authored by Sebastian Gomez-Gonzalez's avatar Sebastian Gomez-Gonzalez
Browse files

Logistic regression now working

parent f186d4d7
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <iostream> #include <iostream>
#include <boost/program_options.hpp> #include <boost/program_options.hpp>
#include <json.hpp> #include <json.hpp>
#include <chrono>
using namespace cv; using namespace cv;
using namespace std; using namespace std;
...@@ -49,17 +50,22 @@ int main(int argc, char** argv) { ...@@ -49,17 +50,22 @@ int main(int argc, char** argv) {
imshow("Color", back); imshow("Color", back);
waitKey(0); waitKey(0);
//Calculate the data with coefs //Calculate the data with coefs
auto start_t = std::chrono::steady_clock::now();
Mat im_proc = quadf_log_reg(img, back, model_coef); Mat im_proc = quadf_log_reg(img, back, model_coef);
cout << "pix data:" << im_proc.at<double>(340, 290) << endl auto end_t = std::chrono::steady_clock::now();
std::cout << "Computation took "
<< std::chrono::duration_cast<std::chrono::milliseconds>(end_t - start_t).count() <<
" milliseconds" << endl;
/*cout << "pix data:" << im_proc.at<double>(340, 290) << endl
<< im_proc.at<double>(342, 291) << endl << im_proc.at<double>(342, 291) << endl
<< im_proc.at<double>(290, 340) << endl << im_proc.at<double>(290, 340) << endl
<< im_proc.at<double>(2, 2) << endl; << im_proc.at<double>(2, 2) << endl;*/
MatIterator_<double> it_ans = im_proc.begin<double>(),end=im_proc.end<double>(); MatIterator_<double> it_ans = im_proc.begin<double>(),end=im_proc.end<double>();
//MatIterator_<Vec3b> it=im_proc.begin<Vec3b>(), end=im_proc.end<Vec3b>(); //MatIterator_<Vec3b> it=im_proc.begin<Vec3b>(), end=im_proc.end<Vec3b>();
while(it_ans != end){ while(it_ans != end){
//cout << "pix data:" << *it_ans << endl; //cout << "pix data:" << *it_ans << endl;
double prob = 1.0 / (1.0 + exp(-*it_ans)); double prob = 1.0 / (1.0 + exp(-*it_ans));
//*it_ans = 255*prob; //*it_ans = 255*prob;
*it_ans = (prob > 0.95) ? 255 : 0; *it_ans = (prob > 0.95) ? 255 : 0;
it_ans++; it_ans++;
} }
......
...@@ -52,7 +52,7 @@ namespace ball_tracking { ...@@ -52,7 +52,7 @@ namespace ball_tracking {
(*it_bkg)[0]/255.0, (*it_bkg)[1]/255.0, (*it_bkg)[2]/255.0, 1.0}; (*it_bkg)[0]/255.0, (*it_bkg)[1]/255.0, (*it_bkg)[2]/255.0, 1.0};
double* wptr = w; double* wptr = w;
for (unsigned int i=0; i<7; i++) { for (unsigned int i=0; i<7; i++) {
for (unsigned int j=i; j<channels; j++, wptr++) { for (unsigned int j=i; j<7; j++, wptr++) {
sum += (*wptr) * lfeat[i] * lfeat[j]; sum += (*wptr) * lfeat[i] * lfeat[j];
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment