Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim flgProcessOnce as Boolean = False
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim pnlGraph As Panel ' Graph panel (Grid)
Dim rectGraph As Rect ' Graph rectangle
Dim GraphX0 As Int ' left position of the Graph
Dim GraphY0 As Int ' top position of the Graph
Dim GraphW As Int ' width of the Graph
Dim GraphH As Int ' height of the Graph
Dim GraphColor As Int ' Graph background color
Dim row As Int
Dim col As Int
Dim luminance As Int
Dim myThreshold As Int
Dim cvsGraph As Canvas
Dim Button1 As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
Create_Graph
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Create_Graph
GraphX0 = 4%y 'Xstart of graphics frame
GraphW = 70%x - 2 * GraphX0 'X(width) of graphics frame
GraphY0 = 3%y 'Ystart of graphics frame
GraphH = 100%y - 2 * GraphY0 'Y(height) of graphics frame
rectGraph.Initialize(0, 0, GraphW, GraphH) 'corners of graphics frame
GraphColor = Colors.White 'colour of graphics frame
pnlGraph.Initialize("pnlGraph") 'initialize graphics panel
Activity.AddView(pnlGraph, GraphX0, GraphY0, GraphW, GraphH) 'and add it to the screen
cvsGraph.Initialize(pnlGraph) 'initialize canvas onto panel
cvsGraph.DrawRect(rectGraph, GraphColor, True, 1) 'draw a white rectangle
cvsGraph.DrawLine(100, 50, 200, 50, Colors.Black, 1) 'draw a black line
End Sub
Sub Button1_Click
flgProcessOnce=True 'Just tell the routine that next time you want it to do something
End Sub
Sub Dotty( PreviewPic() as Byte )
'we are assuming that camera preview is 640x480. Also, the array is in camera orientation order, usually landscape.
For row = 0 To 480-1 Step 10 ' adapt the step value to your needs
For col = 0 To 640-1 Step 10
Dim luminance As Int = Bit.AND( PreviewPic( 640*row + col), 0xFF) ' needed since we will compare values that we know are "absolute" but in android bytes are signed...
If luminance>myThreshold Then
' you have a rough estimation of a "bright" point at coordinates x=col, y=row
cvsGraph.DrawPoint(row, col, Colors.Red)
End If
Next
Next
End Sub
Sub Camera1_Preview (PreviewPic() As Byte)
'we are assuming that camera preview is 640x480. Also, the array is in camera orientation order, usually landscape.
'prevent queued events from previous camera settings, if any. Just in case
If PreviewPic.Length<>(3*myBitmap.Width*myScale*myBitmap.Height*myScale/2) Then
Log("Not processing")
Return
End If
if flgProcessOnce=True Then 'if flag has been raised because you clicked the button, process once
Dotty( PreviewPic ) ' Direct call to Dotty(). Here you can pass the parameter 'PreviewPic' because it is a local var in this Sub
flgProcessOnce=False ' reset the flag
End sub
' You don't need my library as you are processing directly on luminance. So this line can be removed.
'NV21toRGB.proceed( PreviewPic, myBitmap.Width*myScale, myBitmap.Height*myScale, myScale, myBitmap, camVertical , camEx.Front, camEx.DispRotation, myIndexEffect )
'DOTTY WAS ORIGINALLY HERE AS PART OF YOUR ROUTING..........
myIV.invalidate 'Refresh the view
End Sub