Ok, así que mirando el archivo cvhough.cpp, la estructura CvLinePolar solo se define por rho y ángulo.
Esto es todo lo que se devuelve como resultado de nuestra llamada a HoughLines. Estoy en el proceso de modificar el archivo C++ y ver si puedo obtener los votos.
Actualización oct 26: me acabo de dar cuenta de que estas no son realmente respuestas, sino más como preguntas. aparentemente mal visto. Encontré algunas instrucciones para recompilar OpenCV. Supongo que tendremos que ir al código y modificarlo y volver a compilarlo. How to install OpenCV 2.0 on win32
actualización 27 de octubre: bueno, no pude compilar las DLL para OpenCV con mi nuevo código, así que terminé copiando y pegando las partes específicas que deseo modificar en mis propios archivos. Me gusta agregar nuevas funciones para evitar sobrecargar las funciones ya definidas. Hay 4 cosas principales que usted necesita copiar: 1- algunas define al azar
#define hough_cmp_gt(l1,l2) (aux[l1] > aux[l2])
static CV_IMPLEMENT_QSORT_EX(icvHoughSortDescent32s, int, hough_cmp_gt, const int*)
2- redefinición de la estructura de la línea de parámetros
typedef struct CvLinePolar2
{
float rho;
float angle;
float votes;
}
CvLinePolar2;
3- la función principal que se ha modificado
static void
icvHoughLinesStandard2(const CvMat* img, float rho, float theta,
int threshold, CvSeq *lines, int linesMax)
{
cv::AutoBuffer<int> _accum, _sort_buf;
cv::AutoBuffer<float> _tabSin, _tabCos;
const uchar* image;
int step, width, height;
int numangle, numrho;
int total = 0;
float ang;
int r, n;
int i, j;
float irho = 1/rho;
double scale;
CV_Assert(CV_IS_MAT(img) && CV_MAT_TYPE(img->type) == CV_8UC1);
image = img->data.ptr;
step = img->step;
width = img->cols;
height = img->rows;
numangle = cvRound(CV_PI/theta);
numrho = cvRound(((width + height) * 2 + 1)/rho);
_accum.allocate((numangle+2) * (numrho+2));
_sort_buf.allocate(numangle * numrho);
_tabSin.allocate(numangle);
_tabCos.allocate(numangle);
int *accum = _accum, *sort_buf = _sort_buf;
float *tabSin = _tabSin, *tabCos = _tabCos;
memset(accum, 0, sizeof(accum[0]) * (numangle+2) * (numrho+2));
for(ang = 0, n = 0; n < numangle; ang += theta, n++)
{
tabSin[n] = (float)(sin(ang) * irho);
tabCos[n] = (float)(cos(ang) * irho);
}
// stage 1. fill accumulator
for(i = 0; i < height; i++)
for(j = 0; j < width; j++)
{
if(image[i * step + j] != 0)
for(n = 0; n < numangle; n++)
{
r = cvRound(j * tabCos[n] + i * tabSin[n]);
r += (numrho - 1)/2;
accum[(n+1) * (numrho+2) + r+1]++;
}
}
// stage 2. find local maximums
for(r = 0; r < numrho; r++)
for(n = 0; n < numangle; n++)
{
int base = (n+1) * (numrho+2) + r+1;
if(accum[base] > threshold &&
accum[base] > accum[base - 1] && accum[base] >= accum[base + 1] &&
accum[base] > accum[base - numrho - 2] && accum[base] >= accum[base + numrho + 2])
sort_buf[total++] = base;
}
// stage 3. sort the detected lines by accumulator value
icvHoughSortDescent32s(sort_buf, total, accum);
// stage 4. store the first min(total,linesMax) lines to the output buffer
linesMax = MIN(linesMax, total);
scale = 1./(numrho+2);
for(i = 0; i < linesMax; i++)
{
CvLinePolar2 line;
int idx = sort_buf[i];
int n = cvFloor(idx*scale) - 1;
int r = idx - (n+1)*(numrho+2) - 1;
line.rho = (r - (numrho - 1)*0.5f) * rho;
line.angle = n * theta;
line.votes = accum[idx];
cvSeqPush(lines, &line);
}
cvFree((void**)&sort_buf);
cvFree((void**)&accum);
cvFree((void**)&tabSin);
cvFree((void**)&tabCos);
}
4- la función que llama a esa función
CV_IMPL CvSeq*
cvHoughLines3(CvArr* src_image, void* lineStorage, int method,
double rho, double theta, int threshold,
double param1, double param2)
{
CvSeq* result = 0;
CvMat stub, *img = (CvMat*)src_image;
CvMat* mat = 0;
CvSeq* lines = 0;
CvSeq lines_header;
CvSeqBlock lines_block;
int lineType, elemSize;
int linesMax = INT_MAX;
int iparam1, iparam2;
img = cvGetMat(img, &stub);
if(!CV_IS_MASK_ARR(img))
CV_Error(CV_StsBadArg, "The source image must be 8-bit, single-channel");
if(!lineStorage)
CV_Error(CV_StsNullPtr, "NULL destination");
if(rho <= 0 || theta <= 0 || threshold <= 0)
CV_Error(CV_StsOutOfRange, "rho, theta and threshold must be positive");
if(method != CV_HOUGH_PROBABILISTIC)
{
lineType = CV_32FC3;
elemSize = sizeof(float)*3;
}
else
{
lineType = CV_32SC4;
elemSize = sizeof(int)*4;
}
if(CV_IS_STORAGE(lineStorage))
{
lines = cvCreateSeq(lineType, sizeof(CvSeq), elemSize, (CvMemStorage*)lineStorage);
}
else if(CV_IS_MAT(lineStorage))
{
mat = (CvMat*)lineStorage;
if(!CV_IS_MAT_CONT(mat->type) || (mat->rows != 1 && mat->cols != 1))
CV_Error(CV_StsBadArg,
"The destination matrix should be continuous and have a single row or a single column");
if(CV_MAT_TYPE(mat->type) != lineType)
CV_Error(CV_StsBadArg,
"The destination matrix data type is inappropriate, see the manual");
lines = cvMakeSeqHeaderForArray(lineType, sizeof(CvSeq), elemSize, mat->data.ptr,
mat->rows + mat->cols - 1, &lines_header, &lines_block);
linesMax = lines->total;
cvClearSeq(lines);
}
else
CV_Error(CV_StsBadArg, "Destination is not CvMemStorage* nor CvMat*");
iparam1 = cvRound(param1);
iparam2 = cvRound(param2);
switch(method)
{
case CV_HOUGH_STANDARD:
icvHoughLinesStandard2(img, (float)rho,
(float)theta, threshold, lines, linesMax);
break;
default:
CV_Error(CV_StsBadArg, "Unrecognized method id");
}
if(mat)
{
if(mat->cols > mat->rows)
mat->cols = lines->total;
else
mat->rows = lines->total;
}
else
result = lines;
return result;
}
Y supongo que podría desinstalar opencv para que elimine todas esas configuraciones automáticas de ruta y recompilarlo usted mismo usando el método CMake y luego el OpenCV es realmente lo que sea que haga.
Me pregunto por qué esta funcionalidad no está en la biblioteca OpenCV –