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 <per.arn...@anyplanet.com> 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 android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---