For background, I am implementing this code in Vitis HLS. When I try to print values for my possible_radius and tested_angle arrays it always outputs zero and I dont know why.
// extrafiles.h
#include <math.h>
int possible_radius[363];
float tested_angles[361];
float cosines[361];
float sines[361];
void createfiles();
// extrafiles.c
#include "extras.h"
float tested_angles[361];
int possible_radius[363];
float cosines[361];
float sines[361];
void createfiles(){
for(int i = 0;i < 363;i++){
possible_radius[i] = i + 1;
}
for(int j = 0; j < 361; j++) {
tested_angles[j] = -M_PI + j * ((M_PI + M_PI) / 360.0);
}
for(int k = 0; k < 361; k++) {
cosines[k] = cos(tested_angles[k]);
sines[k] = sin(tested_angles[k]);
}
}
// hough.c (top function)
#include "hough.h"
#include "extras.h"
#include <stdio.h>
#define Len ROWS * COLS
#define max_distance 363
#define thetas 361
unsigned int accumulator[max_distance][thetas] = {0};
int xcoord[257]; // Set to an arbitrarily large amount so that any number of coordinates can be passed in
int ycoord[257];
int current_max = 0;
void createfiles();
void hough(unsigned int testarray[ROWS][COLS], float *slope1, float *intercept1){
#pragma HLS INTERFACE s_axilite port=return
#pragma HLS INTERFACE s_axilite port=return
#pragma HLS PIPELINE
int i, j, radius1,z,k; // All the integers I will use
float theta1, xi, yi,i1,s1;
double r;
// First loop grabs our x and y values from the image
z = 0;
for (i=0;i<ROWS;i++){
k = 255 - i;
for (j=0;j<COLS;j++){
if (testarray[k][j] != 0){
ycoord[z] = i;
xcoord[z] = j;
z += 1;
}
}
}
for (i=0;i<257;i++){
for (j=0;j<thetas;j++){
r = abs(xcoord[i] * cosines[j] + ycoord[i] * sines[j]);
accumulator[(int)r][j] += 1;
}
}
for (i=0;i<max_distance;i++){
for (j=0;j<thetas;j++){
if (accumulator[i][j] > current_max){
current_max = accumulator[i][j];
radius1 = possible_radius[i];
theta1 = tested_angles[j];
}
}
}
printf("%d\n",possible_radius[50]);
printf("%f\n",tested_angles[0]);
// Calculating the slope and intercept from top radius and theta
s1 = tan(theta1 + M_PI/2.00);
xi = radius1 * cos(theta1 + M_PI_2);
yi = (radius1 - xi*cos(theta1 + M_PI_2)) / sin(theta1 + M_PI_2);
i1 = yi - (s1 * xi);
*slope1 = tested_angles[200];
*intercept1 = cosines[180];
}