Android Question Camera2 - preview still stretched

queensoft

Member
I'm using Erel's example for Camera2: https://www.b4x.com/android/forum/threads/camera2-still-images-and-videos.83920/
I made only one change: #SupportedOrientations: unspecified
When I rotate the phone in landscape mode, the preview (for both video and still image) is stretched vertically.
If I switch between video and still image, while NOT changing orientation, preview is still stretched.
Images and videos are saved correctly, correct orientation, no stretching (proper ratio).
Phone is Huawei P Smart 2019, Android 10, B4A 10.50
Also, I'm very very noob at this, so please keep explanations extremely simple, with exact code.
Please help. Thank you.
 

queensoft

Member
OK, I think I have / understand all that.

Latest version: of B4A or of Camera2 library?
BTW, where do I download updated (if any) Camera2 library?

Based on B4XPages - yes, like I said, I used the example, which is based on B4XPages, right ?!

Orientation must be locked - you mean #SupportedOrientations: portrait or landscape and NOT unspecified ?
But, in that case, images and videos are NOT automatically rotated.

For images I have found a workaround:
- #SupportedOrientations: portrait
- detect phone orientation using sensors, rotate image, save.
For videos, like I said, I cannot process again after original video is saved.
I tried this for video, but it has no effect.
Instead of this (original code):
B4X:
MediaRecorder.RunMethod("setOrientationHint", Array(GetHintOrientation))
I put this - always roatte video, no matter what phone actual orientation is
B4X:
Dim orr As Int = 90
MediaRecorder.RunMethod("setOrientationHint", Array(orr))
It does not work, video is either rotated according to phone orientation or not rotated at all.
 
Last edited:
Upvote 0

queensoft

Member
Thank you for your help, but it's not that useful for me.
Yes, I know I'm confusing things, I'm a total beginner.
But I used the Camera2 example (see link above) and it's not working properly for me.

This new example is also different than what I need.
I need Camera2, camera preview / capture "embedded" in my app.
This example (intent) launches the default camera, captures image, approve/reject image, back to my app.
It doesn't use Camera2 at all.

Also, like I said, image orientation is OK now, using sensors.
I need video orientation help.
Again, using Camera2.
 
Upvote 0
Top