I'm trying to do a program that creates various filters through webcam feed and ran into some issues with BLOB-analysis and some other.
I'm getting segFault everytime I activate my grassfire function. Here's the code for my grassfire function:
void testApp::grassFire(int mask_Y, int mask_X, unsigned char labelCnt)
{
blobArray[mask_Y * camWidth + mask_X] = labelCnt;
if (mask_X + 1 <= camWidth - 1 && blobArray[mask_Y * camWidth + mask_X + 1] == 0)
grassFire(mask_Y, mask_X + 1, labelCnt);
if (mask_Y + 1 <= camHeight - 1 && blobArray[(mask_Y + 1) * camWidth + mask_X] == 0)
grassFire(mask_Y + 1, mask_X, labelCnt);
if (mask_X - 1 >= 0 && blobArray[mask_Y * camWidth + mask_X - 1] == 0)
grassFire(mask_Y, mask_X - 1, labelCnt);
if (mask_Y - 1 >= 0 && blobArray[(mask_Y - 1) * camWidth + mask_X] == 0)
grassFire(mask_Y - 1, mask_X, labelCnt);
}
And how it is called is by a switch case that runs every frame This means it gets called every frame update
The function itself is declared outside any other scope.
I know it is a really heavy filter and it might be using a lot of memory, but compared to some of the other filters, it's not that bad, so I cannot figure out why i get the segFault.
I also get the segFault on another filter, that shouldn't be that memory usage demanding. I'm using openframeworks in codeblocks on win 7.