In the below code, I want to calculate the net sum of intensity at the end of the loop, but the objective C calls zsum undeclared variable in the NSlog. How do I calculate Sum at the end off loop and pass it outside the loop.
NSMutableArray *arr = [[NSMutableArray alloc] init];
for (int x = 1; x < 20; x++) {
double zsum = 0;
NSMutableArray *row = [NSMutableArray new];
for (int y = 1; y < 20; y++) {
uchar intensity= curFrame.at<uchar>(cvPoint(y, x));
double zebra = double (intensity)/255;
zsum+= zebra;
[row addObject:[NSNumber numberWithChar:intensity]];
}
// NSLog(@"%d", x);
//NSLog(@"%f",d);
[arr addObject:[NSNumber numberWithInt:zsum]];
// [matrix addObject:row];
}
NSLog(@“%f",zsum);