B4J Question Simple Pi Camera

derez

Expert
Licensed User
Longtime User
Use raspistill with shell command :
B4X:
Sub raspitimer_tick
    If ProcessIsRunning = False Then
        If quality_flag = 1 Then    ' low quality picture
            shl.Initialize("shl", "raspistill", Array("-o", "temp.jpg", "-t", "1", _
                            "-tl","2000", "-br","55",    "-w", "320", "-h", "240", "-q", "75"))
            Log("320")
        Else if quality_flag = 2 Then  ' high quality picture
            shl.Initialize("shl", "raspistill", Array("-o", "temp.jpg", "-t", "1", _
                            "-tl","2000", "-br","55", "-w", "960", "-h", "720", "-q", "75"))
            Log("960")
        End If
        shl.Run(-1)
    Else
        Log("raspistill is already running.")
    End If
End Sub


Sub ProcessIsRunning As Boolean
    shl.Initialize("", "ps", Array("-a"))
    Return shl.RunSynchronous(10000).StdOut.Contains("raspistill")
End Sub


Private Sub shl_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
    Log($"process completed: ${Success}, ${ExitCode},
    ${StdOut}
    ${StdErr}
    "$)
End Sub
 
Upvote 0
Top