I am new to publishing, so please be beautiful! I reviewed almost all other issues related to this, and tried the most, but I'm completely upset. I just want my Android phone to display the camera in portrait mode and not in landscape. I am just modifying the ImageManipulations sample that is provided with opencv.
I am using opencv 3.01, Android sdk version 23, Android Studio 2.0 and a Nexus 5 phone with Android version 6.0.1. This is 4/28/2016, and it is almost the most stable version of everything.
I already forced the application in portrait mode in the AndroidManifest.xml file with:
android:screenOrientation="portrait"
and the whole application is displayed correctly in portrait mode, but the displayed image of the camera rotates 90 degrees. In other words, if you tilt your head 90 degrees to the left, you will see the corresponding image. So I need to rotate the image to the right.
I tried using the opencv Tutorial3 code and setDisplayOrientation (90):
public void setResolution(Size resolution) {
disconnectCamera();
mMaxHeight = resolution.height;
mMaxWidth = resolution.width;
connectCamera(getWidth(), getHeight());
mCamera.setDisplayOrientation(90);
}
and it didn’t work. And in any case, this tutorial uses the "camera" class, which is deprecated in Android version 21 and has been replaced by the "camera2" class. I did not go further because I wanted to use the most advanced APIs, but maybe something in Camera2 could work?
"" "", , onCameraFrame:
, , :
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
Mat rgba = inputFrame.rgba();
... do stuff to the image ...
return rgba;
, FPS ()::
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
Mat rgba = inputFrame.rgba();
Core.transpose(rgba, rgba);
Core.flip(rgba, rgba, 1);
... do stuff to the image ...
return rgba;
180 , , , :
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
Mat rgba = inputFrame.rgba();
Core.transpose(rgba, rgba);
Core.flip(rgba, rgba, 1);
Core.transpose(rgba, rgba);
Core.flip(rgba, rgba, 1);
... do stuff to the image ...
return rgba;
, , onCameraFrame Mat , . onCameraFrame - , ?
, , onCameraFrame? , ?