Good day
I have implemented Gnuplot 5.4 in my Visual Studio 2019 Community edition. Through a sample program, I can successfully print the content of an STL vector.
Now the question arises whether it is possible to display a nested vector with X,Y value pairs?
constexpr int WIDTH = 2;
constexpr int LENGTH = 1280;
vector<vector<double> > vector_2d(LENGTH, vector<double>(WIDTH, 0));
In my example, randomly generated values are described at fixed X-positions, which are added up by a for-loop. In my case, however, the X-values do not have a fixed distance to each other, so I have to map them individually and cannot work with a for-loop. The following is an excerpt from my recorded values
-2.73414564 -2.81298971
-1.95063043 -300.00000000
-2.66365290 -3.08498740
-2.62452888 -2.99414206
-2.58396339 -2.81281424
-2.54788446 -2.90335822
-2.51031804 -2.90331340
-1.77885580 -300.00000000
-1.75022638 -300.00000000
-2.39761853 -2.90317917
In the further course, a Hough transformation is also to be displayed in another Gnuplot window. For this, I iterate through a nested For loop in which I perform a calculation. This calculation (result is a sine curve in the Hough sapce) is to be displayed.
float rho, cos_theta, sin_theta;
for (int ti = 0; ti < n_theta; ti++) {
cos_theta = static_cast<float>(cos(theta));
sin_theta = static_cast<float>(sin(theta));
for (long i = 0; i < arrIndex; i++) {
rho = vector_2d[i][0] * cos_theta + vector_2d[i][1] * sin_theta;
}
}
theta += q_theta;
}
n_theta describes the number of passes for all angles from 0 to 180 degrees. q_theta specifies the angle which is added up (quantisation). arrIndex describes the index in the vector. Perhaps someone can answer the question of whether it is possible to display the Hough transformation in real time. If this is not relatively easy to solve, whether and how the Hough space is to be represented after all calculations.
So far I have not found a suitable solution. I would be very grateful for help
Many greetings
If anyone comes across this post I have the following solution. To visualise the Hough transform, I write every tenth theta and rho value of the Hough transform for a pair of X-Y values in a text document. This is done 18 times per X-Y value pair.
fstream outputFile5;
outputFile5.open("C:\\(...)", ios::out);
outputFile5.setf(ios::fixed);
outputFile5.precision(8);
//ArrIndex describes the number of X-Y values in the array (number of edge points)
for (long i = 0; i < arrIndex; i++) {
//Hough-Transform from -90° to 90°
float theta = static_cast<float>(-M_PI / 2);
for (int k = 0; k < n_theta; k++) {
/*performing Hough-Transform*/
}
//needed to separate the data sets
if (k == 0) {
outputFile5 << endl << endl << "Punkt " << i << endl;
}
if (k % 10 == 0) {
outputFile5 << theta << " " << rho << endl;
}
theta += q_theta;
}
Then, with the help of the text file and the following code, the Hough Space is displayed.
gp << "set grid\n ";
gp << "set xlabel 'Theta'\n ";
gp << "set ylabel 'Rho'\n ";
gp << "set terminal wxt 0 size 790,800 position 500,100\n ";
gp << "set term wxt title 'Windowname'\n ";
gp << "set object circle at first " << acc_max_theta << "," << acc_max_rho << "radius char 0.7 fillstyle empty border lc rgb 'red' lw 3 front \n ";
gp << "plot for [IDX=0:" << arrIndex << "]'C:/Users/pathname/' i IDX u 1:2 notitle with lines;pause mouse close\n ";
gp << "unset object\n ";