diff --git a/examples/img_proc/log_reg_approach.cpp b/examples/img_proc/log_reg_approach.cpp index d4a86b7091a3167e300d1c49164795dd50f38c4e..565e8fd86272478f46b1c17dbbefb1257b7a5794 100644 --- a/examples/img_proc/log_reg_approach.cpp +++ b/examples/img_proc/log_reg_approach.cpp @@ -6,6 +6,7 @@ #include <iostream> #include <boost/program_options.hpp> #include <json.hpp> +#include <chrono> using namespace cv; using namespace std; @@ -49,17 +50,22 @@ int main(int argc, char** argv) { imshow("Color", back); waitKey(0); //Calculate the data with coefs + auto start_t = std::chrono::steady_clock::now(); 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>(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_<Vec3b> it=im_proc.begin<Vec3b>(), end=im_proc.end<Vec3b>(); while(it_ans != end){ //cout << "pix data:" << *it_ans << endl; 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++; } diff --git a/src/img_proc.cpp b/src/img_proc.cpp index b7a6d32cf7654e4d3c3b2cb1d807795a878e9a76..474871f80fe7bd95af723d7c32f6882ffddf3d14 100644 --- a/src/img_proc.cpp +++ b/src/img_proc.cpp @@ -52,7 +52,7 @@ namespace ball_tracking { (*it_bkg)[0]/255.0, (*it_bkg)[1]/255.0, (*it_bkg)[2]/255.0, 1.0}; double* wptr = w; 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]; } }