Android Question get GetSupportedPreviewFpsRange

joop

Active Member
Licensed User
Longtime User
Hi ,I tried to get the supported preview ranges from my phone with:

B4X:
Log("Frames/sec  modes________")
    Dim FpsRange As List = camEx.GetSupportedPreviewFpsRange
    If FpsRange.IsInitialized = False Then
        Log(TAB & "Not supported.")
    Else
        Dim fps As String
        For i=0 To FpsRange.Size-1
            fps=FpsRange.Get(i) : Log(TAB & fps)
        Next
    End If

with this :

B4X:
Public Sub GetSupportedPreviewFpsRange As List
  r.Target = parameters
  Return r.RunMethod("getSupportedPreviewFpsRange")
End Sub

I got this => [I@40a908f0 as output .
If anyone could help me understand the output it would help me a lot, thanks!
 
Last edited:

joop

Active Member
Licensed User
Longtime User
This is the info
http://developer.android.com/refere...Parameters.html#getSupportedPreviewFpsRange()


Returns
  • a list of supported preview fps ranges. This method returns a list with at least one element. Every element is an int array of two values - minimum fps and maximum fps. The list is sorted from small to large (first by maximum fps and then minimum fps).



How do I get 2 int values from an int array in a list ,that's the question .
 
Upvote 0

JordiCP

Expert
Licensed User
Longtime User
Can't test it now, but if the call returns a list, and its elements are arrays of ints, you should do

B4X:
If FpsRange.IsInitialized = False Then
    Log(TAB & "Not supported.")
Else
    Dim fps() As Int
    For i=0 To FpsRange.Size-1
        fps=FpsRange.Get(i) : Log(TAB & fps(0) & TAB & fps(1))
    Next
End If
 
Upvote 0

joop

Active Member
Licensed User
Longtime User
Yes ,that works Jordi ! fps must be an array :rolleyes: it gives frame rate from my phone:
7000 30000

Wich is 7 - 30 frm/sec

Thanks
 
Upvote 0

joop

Active Member
Licensed User
Longtime User
Well I tried to set the frame rate to 7000 with

B4X:
camEx.SetPreviewFpsRange(7000,7000)

but frame rate is not changed. no errors

So i want to to read it back, if the values are stored with this reflection routine .

https://www.b4x.com/android/forum/t...ra-preview-process-lighter.28936/#post-167896

B4X:
'Returns the current preview fps range.
'Range is a two elements array. The minimum value and maximum value will be stored in this array.
Public Sub GetPreviewFpsRange(Range() As Int)
  r.Target = parameters
  r.RunMethod4("getPreviewFpsRange", Array As Object(Range), Array As String("[I"))
End Sub

I have not much understanding of the use of Java classes and their fields and methods.
My question is how can I get this values with B4A (Range() As Int) this is confusing
 
Upvote 0

joop

Active Member
Licensed User
Longtime User
Yes, that works it gives

Min = 7000
Max =7000
Thanks erel.

But frame-rate stays visual the same I see no difference on my phone (has api 16 android)
B4a isn't the cause of this , maybe it will work on some phones?

Has anyone tried this before ? what I did was this using the perfect CamEX class.

B4X:
Sub Camera1_Ready (Success As Boolean)
    If Success Then
      camEx.SetPreviewSize(640, 480)
      camEx.SetJpegQuality(90)
      camEx.SetPreviewFpsRange(7000,7000)
  
      Log("CurrentPreviewFpsRange ________")
      Dim MinMax(2) As Int
     camEx.GetPreviewFpsRange(MinMax)
     Log($"Min = ${MinMax(0)}"$)               'gives 7000
     Log($"Max = ${MinMax(1)}"$)              'gives 7000
    
    camEx.CommitParameters 'Error setting parameters message when wrong.
    camEx.StartPreview
  Else
     ToastMessageShow("Cannot open camera.", True)
  End If
End Sub

Maybe it's not in the right order ?
 
Upvote 0

joop

Active Member
Licensed User
Longtime User
GetSupportedPreviewFpsRange = 7000 - 30000
so 7000 = supported

divided / 1000 = 7 - 30 frm/sec I want a lower Fps range.
 
Upvote 0

joop

Active Member
Licensed User
Longtime User
camEx.setSceneMode is also not working in the class ,I am not sure it has to do
with the reflection objects. it gives no errors.
I will post a new thread with example
 
Upvote 0
Top