I am trying to create an android application. which constantly displays a camera preview in portrait mode and performs some heavy image processing operations on (some) frames. Therefore, I use OpenCV (both OpenCV4Android and native C / C ++ components). The problem is that when using the CameraBridgeViewBase or JavaCameraView classes, the frame returned by OnCameraFrame is in landscape mode.
Now, if the Landscape mode is used for Activity (as in the OpenCV application examples), the view looks fine, but any additional user interface views are tilted 90 degrees (and, as mentioned earlier, the device should launch my application in Portrait mode).
If the Activity parameter is set to portrait mode, the user interface views will obviously look right, but the camera’s preview will be tilted 90 degrees.
If I try to rotate each frame by manipulating the Matrix image on an OnCameraFrame, follow these steps:
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
mRgba = inputFrame.rgba();
Core.transpose(mRgba,mRgbaT);
Core.flip(mRgbaT, mRgbaT, -1);
Imgproc.resize(mRgbaT, mRgbaT, mRgba.size());
return mRgbaT;
}
, (, , ), - . ( , ) , ( ), :
E/CameraBridge(11183): Utils.matToBitmap() throws an exception: /home/reports/ci/slave_desktop/50-SDK/opencv/modules/java/generator/src/cpp/utils.cpp:97: error: (-215) src.dims == 2 && info.height == (uint32_t)src.rows && info.width == (uint32_t)src.cols in function void Java_org_opencv_android_Utils_nMatToBitmap2(JNIEnv*, jclass, jlong, jobject, jboolean)
, : OpenCV , ?
, - SO . , , SO , , , .