Hi all,
I’m using nppiGraphcut_32f8u to compute my graph. In my main, I have a for loop like this that calls an extern void “C” function that does the CUDA/NPP computation like this:
unsigned short *temp = (unsigned short *)malloc(frameWidth*frameHeight*sizeof(unsigned short)); //initialize to zero for one-frame
nNodes = frameWidth*frameHeight;
for (int frameNum = 1; frameNum< 10; frameNum++)
{
for (int i=0; i<frameWidth*frameHeight; i++)
{
temp[i] = data_buffer[frameNum*frameWidth*frameHeight + i];
}
twoDseg (frameWidth,
frameHeight,
frameNum,
frames,
fileLen,
temp);
}
free(temp);
where data_buffer is the volume (bigger) array I’m extracting from to ‘temp’.
Then in my twoDseg() void function, I have the nppiGraphCut call as follows:
int c = nppiGraphcut_32f8u(d_terminals, d_left_transposed, d_right_transposed,
d_top, d_bottom, step, transposed_step,
size, d_label, pitch, pGraphcutState); //UNSTABLE WHY-because of edgeweights
printf("GC error 1: %i \n", c);
which returns GC error = 0 the first iteration of the main for loop, but for the 2nd frame or 2nd iteration, the GC error = -3.
The strangest thing is, this works when nppiGraphCut is called twice like this:
int c = nppiGraphcut_32f8u(d_terminals, d_left_transposed, d_right_transposed,
d_top, d_bottom, step, transposed_step,
size, d_label, pitch, pGraphcutState); //UNSTABLE WHY-because of edgeweights
printf("GC error 1: %i \n", c);
c = nppiGraphcut_32f8u(d_terminals, d_left_transposed, d_right_transposed,
d_top, d_bottom, step, transposed_step,
size, d_label, pitch, pGraphcutState); //UNSTABLE WHY-because of edgeweights
printf("GC error 2: %i \n", c);
which returns GC error 1= -3, GC error 2=0. So it means it worked the 2nd time…Can someone help explain or show me why calling nppiGraphCut twice would result in different success?