1 | initial version |
i do not have any adroid sdk, so i cannot test, but the gist is like this:
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
mRgba = inputFrame.rgba();
float zoom = 0.8;
Size orig = mRgba.size();
int offx = (1.0-zoom) * orig.width;
int offy = (1.0-zoom) * orig.height;
// crop the part, you want to zoom into:
Mat cropped = mRgba.submat(offy, orig.height-2*offy, offx, orig.width-2*offx);
// resize to original:
Imgproc.resize(cropped, cropped, orig);
return cropped;
}
2 | No.2 Revision |
i do not have any adroid sdk, so i cannot test, but the gist is like this:
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
mRgba = inputFrame.rgba();
float zoom = 0.8;
Size orig = mRgba.size();
int offx = 0.5 * (1.0-zoom) * orig.width;
int offy = 0.5 * (1.0-zoom) * orig.height;
// crop the part, you want to zoom into:
Mat cropped = mRgba.submat(offy, orig.height-2*offy, orig.height-offy, offx, orig.width-2*offx);
orig.width-offx);
// resize to original:
Imgproc.resize(cropped, cropped, orig);
return cropped;
}