Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

countnonzero seg fault

Hello , I want to use countNonZero , but I am getting a seg fault at the countNnZero line.

vector<Mat> mycompare;
int compareSize = (N / 2) * (N -1);
mycompare.resize( compareSize );

int myCounts [ compareSize ]; 

int index = 0;
for ( int idx = 0; idx < N; idx++ )
{
    for ( int k = idx + 1; k < N; k ++ )
    {
         mycompare[ index++ ] = ( A[ idx ] == A[ k ] );
         myCounts[ index++ ] = countNonZero( mycompare[ index ] );
     }
}

countnonzero seg fault

Hello , I want to use countNonZero , but I am getting a seg fault at the countNnZero line.

vector<Mat> mycompare;
int compareSize = (N / 2) * (N -1);
mycompare.resize( compareSize );

int myCounts [ compareSize ]; 

int index = 0;
for ( int idx = 0; idx < N; idx++ )
{
    for ( int k = idx + 1; k < N; k ++ )
    {
         mycompare[ index++ ] = ( A[ idx ] == A[ k ] );
         myCounts[ index++ ] = countNonZero( mycompare[ index ] );
     }
}

OR

Is there a way to use if statement?:

if ( mycompare[ index ] == 255 ) 
    count++;