diff --git a/hough_machine.cpp b/hough_machine.cpp index 4c6a252..fa161ac 100644 --- a/hough_machine.cpp +++ b/hough_machine.cpp @@ -118,7 +118,7 @@ class HoughMachine { // if so, put it in the list struct hparam* lines = (struct hparam*) malloc(sizeof(struct hparam) * this->n_ang * this->n_rad); int line = 0; - for(int i=0; i<=this->n_ang*this->n_rad; i++) { + for(int i=0; in_ang*this->n_rad; i++) { int value = this->hough_arr[i]; if(value <= 5) continue; // Ignore small values // TODO: Check neighbours and compare! @@ -142,15 +142,15 @@ class HoughMachine { int quadrant = floor(theta / pi_half); std::cout << "Top " << i << ": " << lines[i].value << ", r: " << r << ", theta: " << theta << " quadrand: " << quadrant; - // cos(pi/8) -sin(pi/8) - // sin(pi/8) cos(pi/8) + // cos() -sin() + // sin() cos() // Do matrix multiplication // Turn r into a x/y vector double vec_x = r * cos(theta) + 0 * -sin(theta); double vec_y = r * sin(theta) + 0 * cos(theta); // find point in image - int x = vec_x + this->x_center; - int y = vec_y + this->y_center; + double x = vec_x + this->x_center; + double y = vec_y + this->y_center; std::cout << " vec x: " << x << ", vec y: " << y << std::endl; // create vector for line double vec_target_x = vec_y; @@ -159,13 +159,14 @@ class HoughMachine { double vec_target_len = sqrt(pow(vec_target_x, 2) + pow(vec_target_y, 2)); vec_target_x = vec_target_x / vec_target_len; vec_target_y = vec_target_y / vec_target_len; - // find first out of bounds condition + // find first border double i = x; double j = y; while(i < this->working_copy->width() && i > 0 && j < this->working_copy->height() && j > 0) { i += vec_target_x; j += vec_target_y; } + // find second border int x1 = i; int y1 = j; i = x;