opencv - Implementing Hough Transform for Lines -
i trying implement hough transform line detection in pre-processed image. input image black-white edge image, 0 - background , 255 - foreground. not wish use inbuilt houghlines library opencv. stuck creating accumulator , increasing values properly. cant figure out went wrong, here code block :
int diagonal = sqrt(height * height + width * width); iplimage *acc = cvcreateimage (cvsize(180, 2 * diagonal),ipl_depth_8u, 1); unsigned char* accdata = (unsigned char *)acc->imagedata; (int i=0; i<height; i++) { (int j=0; j<step; j++) { if (data[i*step + j] > 200) { (int theta=0; theta<180; theta++) { int p = j * cos(theta) + * sin(theta); if (p > 0) accdata[theta*180 + p] += 1; } } } }
the output image in acc not should like. not getting sinusoids, instead white patches here , there. can provide feedback went wrong ?
what see there don t use sinus radians values degree values change follows:
int p = j * cos((double)theta*pi/180) + * sin((double)theta*pi/180);