I have suceesfully drew a rectanlge over the face in Android. Inorder to crop the selected face I used the following code:
Mat cropped_face = image;
Rect cropped= new Rect(facesArray[i].tl(), facesArray[i].br());
cropped_face = new Mat(image,cropped);
The 'image' variable holds the original image from the camera. I encountered following error on the last line of code.
AndroidRuntime: FATAL EXCEPTION: Thread-6
Process: com.example.kiran.opencv, PID: 5573
CvException [org.opencv.core.CvException: cv::Exception: OpenCV(3.4.1) /build/master_pack-android/opencv/modules/core/src/matrix.cpp:418: error: (-215) 0 <= _rowRange.start && _rowRange.start <= _rowRange.end && _rowRange.end <= m.rows in function cv::Mat::Mat(const cv::Mat&, const cv::Range&, const cv::Range&)
]