Android Question Cameraexclass: Distortion problem

grafsoft

Well-Known Member
Licensed User
Longtime User
Hi,

this is my code

B4X:
#Region  Activity Attributes
   #FullScreen: false
   #IncludeTitle: true
#End Region

Private Sub InitializeCamera
   Try
   camEx.Initialize(Panel1, frontCamera, Me, "Camera1")
   frontCamera = camEx.Front
   Catch
     Dim s As String
     s="Camera Resume " & LastException.Message
     Log (s)
     Main.prot.Add (s)
   End Try
End Sub

Sub camera1_Ready (Success As Boolean)
   Try
   If Success Then
     camEx.SetJpegQuality(Settings.jpgquality)
     
     camEx.CommitParameters
     ' camEx.SetPictureSize (Panel1.Width,Panel1.Height)
     camEx.StartPreview
     Log(camEx.GetPreviewSize)
     camerasetbuttons
     
     
     
   Else
     ToastMessageShow("Die Kamera funktioniert nicht.", True)
   End If
   Catch
     Dim s As String
     s="Camera ready " & LastException.Message
     Log (s)
     Main.prot.Add (s)
   End Try
End Sub

This produces no distortion.

When I reverse the variables for fullscreen and includetitle to true and false, the picture becomes distsorted, everything is too wide. Setpicturesize does not help.

What am I doing wrong?

Thank you

Peter
 

grafsoft

Well-Known Member
Licensed User
Longtime User
The size of the panel is 897*720. The preview is distorted, everything looks higher. The picture taken has the right proportions.

Since I need some buttons, the panel is 75%x to 100%y. Should I take care that the panel has the same proportions of the entire screen?
 
Upvote 0

grafsoft

Well-Known Member
Licensed User
Longtime User
Sorry, still not solved.

The photo is OK, the preview is distorted. I need to have a preview with other width/height ratio than the screen.
 
Upvote 0

grafsoft

Well-Known Member
Licensed User
Longtime User
Maybe bacvause of this:

B4X:
camEx.SetPictureSize (Panel1.Width,Panel1.Height)

Error occurred on line: 172 (cameraexclass)
java.lang.NoSuchMethodException: setPictureSize [int, int]
at java.lang.Class.getConstructorOrMethod(Class.java:472)
at java.lang.Class.getDeclaredMethod(Class.java:640)
at anywheresoftware.b4a.agraham.reflection.Reflection.runmethod(Reflection.java:214)
at anywheresoftware.b4a.agraham.reflection.Reflection.RunMethod3(Reflection.java:834)
at Photo.Tagger.cameraexclass._setpicturesize(cameraexclass.java:242)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:636)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:302)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
at Photo.Tagger.kamera.afterFirstLayout(kamera.java:98)
at Photo.Tagger.kamera.access$100(kamera.java:16)
at Photo.Tagger.kamera$WaitForLayout.run(kamera.java:76)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5086)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Camera Resume java.lang.Exception: java.lang.NoSuchMethodException: setPictureSize [int, int]


Why this?
 
Upvote 0

grafsoft

Well-Known Member
Licensed User
Longtime User
Thank you very much for your help! I really need it.

When you start the app, you start the activity "Kamera". I need the right margin, because I need to put the buttons somewhere.

You see it is slightly distorted here.

When you take the picture, you come to another activity, "Draw", where you can draw on the picture (not in this app, I wanted to keep it simple). You see it is distorted the other way round.

You see it best when you make a picture of a round object.

Thanks

Peter
 

Attachments

  • b4atest.zip
    45.4 KB · Views: 220
Upvote 0

grafsoft

Well-Known Member
Licensed User
Longtime User
>ou mean
B4X:
cvsBackground.DrawBitmap(LoadBitmap(Main.outdir, Main.thepic), Null, rectPanels)
?

I can check that. But in the module Kamera, where the image is saved, ther is not bitmap, and the image is saved distorted. The bigger problem lies here.
 
Upvote 0
Top