Android Question How can i apply grayscale effect to camera preview data before send to detect function

ykucuk

Well-Known Member
Licensed User
Longtime User
How can i add effects to data(grayscale) before send for detect function?

B4X:
Sub Camera1_Preview (data() As Byte)
'i should apply grayscale effect here
Dim bb As JavaObject
bb = bb.InitializeStatic("java.nio.ByteBuffer").RunMethod("wrap", Array(data))
 

TILogistic

Expert
Licensed User
Longtime User
I solved with bitmapeffects lib.
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
tips:
See grayscale for OCR

B4X:
Public Sub GreyScale (bmp As B4XBitmap) As B4XBitmap
    Dim bc As BitmapCreator = CreateBC(bmp)
    Dim argb As ARGBColor
    For x = 0 To bc.mWidth - 1
        For y = 0 To bc.mHeight - 1
            bc.GetARGB(x, y, argb)
            Dim c As Int = argb.r * 0.21 + argb.g * 0.72 + 0.07 * argb.b
            argb.r = c
            argb.g = c
            argb.b = c
            bc.SetARGB(x, y, argb)
        Next
    Next
    Return bc.Bitmap
End Sub
 
Upvote 0
Top