Dear All..
Due to a unfortunate business idea I am forced to re write a camera application on Android 2.2. Its a severe problem as the CameraEx class does not work in this version .
I just need to capture frames from the camera in a fast timing (capture 2 images / second)
I tried to use the Camera1_PictureTaken method, it works but is very slow (captures only 1 image in two or three seconds)
I am not able to use the Camera1_Preview like in latest Androids as the PreviewImageToJpeg is not working properly as I simply dont know how to do it ..The code I am trying to do is below..
The function PreviewImageToJpeg is to convert YUV format to JPEG which could be the problem I guess but I am not able to fix it.. need some help in this please..
Can any one help me in using the camera_preview with out using CameraExclass please...
Thanks,
Sangee
Due to a unfortunate business idea I am forced to re write a camera application on Android 2.2. Its a severe problem as the CameraEx class does not work in this version .
I just need to capture frames from the camera in a fast timing (capture 2 images / second)
I tried to use the Camera1_PictureTaken method, it works but is very slow (captures only 1 image in two or three seconds)
I am not able to use the Camera1_Preview like in latest Androids as the PreviewImageToJpeg is not working properly as I simply dont know how to do it ..The code I am trying to do is below..
The function PreviewImageToJpeg is to convert YUV format to JPEG which could be the problem I guess but I am not able to fix it.. need some help in this please..
Can any one help me in using the camera_preview with out using CameraExclass please...
Thanks,
Sangee
B4X:
Sub Camera1_Preview (Data() As Byte)
Dim forDate As String
DateTime.DateFormat ="HH.mm.ss.SS_dd-MM-yy"
forDate=DateTime.Date(DateTime.now)
Dim Tcr As String
DateTime.DateFormat ="HH:mm:ss dd-MM-yyyy"
Tcr = DateTime.Date(DateTime.now)
Dim tempstr As StringBuilder
tempstr.Initialize
tempstr.Append(forDate).Append("_").Append(Hostname).Append("_")
InProg=True
If DateTime.now > lastPreviewSaved + IntervalMs Then
Dim jpeg() As Byte = PreviewImageToJpeg(Data, 90)
Dim InputStream As InputStream
InputStream.InitializeFromBytesArray(jpeg, 0, jpeg.Length)
btmp.InitializeMutable(640,480)
Canvas1.Initialize2(btmp)
Dim Bitmap1 As Bitmap
Bitmap1.Initialize2(InputStream)
InputStream.Close
Dim Rect1 As Rect
Rect1.Initialize(0,0,btmp.Width ,btmp.Height)
Canvas1.DrawRect(Rect1, Colors.Gray,True, 1dip)
Canvas1.DrawBitmap(Bitmap1,Null,Rect1)
Canvas1.DrawLine(btmp.Width -270,btmp.Height -20, btmp.Width -2, btmp.Height -20, Colors.Black , 16dip)
Canvas1.DrawText(Hostname & " - " & Tcr,btmp.Width -270,btmp.Height -15,Typeface.DEFAULT,15,Colors.White,"LEFT")
Dim out As OutputStream
out = File.OpenOutput(File.DirRootExternal, "/Images/" & tempstr & ".jpg", False)
Canvas1.Bitmap.WriteToStream(out,45,"JPEG")
out.Close
lastPreviewSaved = DateTime.now
End If
InProg=False
End Sub