Android Question Video Processing Methods

Socaplaya21

Member
Licensed User
Longtime User
Hi,

This is my first post, and I'd like to compliment the developers and community for making B4A such an amazing tool. So the goal of my application is to be able to read a single pixel from a video recorded with the rear camera at least 5 times a second (the resolution of the video doesn't matter). At the moment I am using the CamEx class to bring up a preview image from the camera in a panel, and from there converting the preview image to a jpeg and then to a bitmap that I can get a pixel's value from. However, using this method I only receive about 3 readings a second in real time and it varies with different devices.

I have also tried to record a short video and analyze it after recording, although using the reflection library and getframeattime() only retrieves about 1 different reading a second. So then I looked into using ffmpeg but we don't have a library yet utilizing these video processing aspects of ffmpeg (to my knowledge). Finally, I looked into using the opengl library, but I'm not even sure if I could read pixels from video with opengl in my situation.

I would very much appreciate it if someone could help me out!


-Matt
 

JordiCP

Expert
Licensed User
Longtime User
Look at this example attached with a small library.

You only have to modify the Camera1_Preview code adding a line


B4X:
Sub Camera1_Preview (PreviewPic() As Byte)


    '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

    NV21toRGB.proceed( PreviewPic, myBitmap.Width*myScale, myBitmap.Height*myScale, myScale, myBitmap, camVertical , camEx.Front, camEx.DispRotation, myIndexEffect )

'Add this line (mypixel is an int)
mypixel = myBitmap.GetPixel( myBitmap.width/2,miBitmap.Height/2)

    myIV.invalidate    'Refresh the view
   

End Sub


Preview frame rate will vary from device to device but this is fast enough
 
Upvote 0
Top