I am writing an IOS app that determines color intensity in a rectangle. My measurement is to calculate intensity value of red rectangle region when it falls in the white paper laid on the top of black background. The display is done in the iphone 6 held vertically and intensity measurement is seen in debug window of xcode. When I put a white paper in a black background, the value of intensity is around 30, which says the location of intensity calculation may be indicating black region. When I move the phone closer to the white paper, so the white paper is near the bottom of the phone and the picture is enlarged, it get a value near 200, which makes sense. Can you please tell me what I am doing wrong. The following code is written in viewcontroller, xcode 8.2.1
- (void)processImage:(cv::Mat&)image
cv::Mat curFrame = image
cv::rectangle(curFrame, cvPoint(180+15, 300-15),cv::Scalar(0,0,255, 255),5);
uchar intensity = curFrame.at<uchar>(cvPoint(180, 300));
int intensityvalue = 255;
intensityvalue = (int) intensity;
NSLog (@"intensity: %d ", intensityvalue);