> 2. G1 doesn't support 100, 100 preview. It only does 480 x 320, but > your request will not cause any problems, it will just get ignored. > When you finally do receive the preview callback check the actual > frame size in onPreviewFrame.
Correct, but end-user testing indicated that the situation with the T- Mobile G1 is even worse, in that getPreviewSize() will return the *requested* settings as applied through setPreviewSize() even though the actual size is indeed always 480 x 320 on the G1. So getPreviewSize () on the G1 returns nonsense after applying setPreviewSize(), without returning any error message. The only indication that "something is wrong" is that the length of data[] in the preview callback will not match your setPreviewSize() settings, but that is not enough information to know the actual preview size: a 100 x 100 preview would yield the same array length as, say, 200 x 50, as these share the same pixel count. Regards On Dec 12, 9:13 am, dmanpearl <[email protected]> wrote: > Pure, > > Filter: > > 1. Your CamApp Activity must extend Surface Holder, and you shouldn't > start the camera until the surface is created. > 2. G1 doesn't support 100, 100 preview. It only does 480 x 320, but > your request will not cause any problems, it will just get ignored. > When you finally do receive the preview callback check the actual > frame size in onPreviewFrame. > 3. The byte[] array data sent to onPreviewFrame is in YCbCr_422_SP > format. No other formats are available, even if you attempt to set > them. The data is described > here:http://groups.google.com/group/android-developers/msg/d3b29d3ddc8abf9b > 4. Don't try to decode the data in onPreviewFrame. There isn't enough > time - you will hose the camera if you try to hold up the system in > that function for so long. Copy the data to your own buffer and > decode in a separate Thread. > > Overlay: > > This is a completely different story and interesting to me. I have > not done this yet on Android but it works on many other phones - even > Java on occasion. I think this will work in Android. In my attempts > on many phones the screen flickers or flashes badly because it is > impossible to synchronize the video preview with your paint/draw/blit/ > etc. > > Good luck. Hope this helps. > - Sincerely, David Manpearl > > On Dec 10, 12:10 pm, pure <[email protected]> wrote: > > > I am trying to use the PreviewCallback but i get an IOException > > saying: > > "startPreview failed". I run the emulator in the debugger. I am pretty > > stuck here. Are there any examples using the PreviewCallback. It would > > be so nice to get this working since i have 4 great ideas for > > applications that all need to use the camera preview and apply a > > filter or overlay. > > > Thanx. > > > The code that fails: > > > public class CamApp extends Activity implements Camera.PreviewCallback > > { > > > �...@override > > public void onCreate(Bundle savedInstanceState) { > > super.onCreate(savedInstanceState); > > > SurfaceView surfView = new SurfaceView(this); > > setContentView(surfView); > > > Camera cam = Camera.open(); > > Camera.Parameters parameters = cam.getParameters(); > > parameters.setPreviewSize(100, 100); > > cam.setParameters(parameters); > > cam.setPreviewCallback(this); > > cam.startPreview(); > > > } > > > �...@override > > public void onPreviewFrame(byte[] data, Camera camera) { > > > } > > > } > > > Stack Trace > > Code: > > > Thread [<3> main] (Suspended (exception RuntimeException)) > > ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord) > > line: 2140 <--- Here is where i can see the IOException > > ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord) > > line: 2156 > > ActivityThread.access$1800(ActivityThread, ActivityThread > > $ActivityRecord) line: 112 > > ActivityThread$H.handleMessage(Message) line: 1580 > > ActivityThread$H(Handler).dispatchMessage(Message) line: 88 > > Looper.loop() line: 123 > > ActivityThread.main(String[]) line: 3742 > > Method.invokeNative(Object, Object[], Class, Class[], Class, int, > > boolean) line: not available [native method] > > Method.invoke(Object, Object...) line: 515 > > ZygoteInit$MethodAndArgsCaller.run() line: 739 > > ZygoteInit.main(String[]) line: 497 > > NativeStart.main(String[]) line: not available [native method] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

