can be called many times a second, maybe try something simpler instead
of writing a file out, just to see if it is being executed. The data
will also need to be decoded if you're wanting to write it to a usable
image. If you just want ONE frame, try setOneShotPreviewCallback.
For doing expensive operations like this on each frame maybe look into
the setPreviewCallbackWithBuffer method.
On Jul 26, 3:01 pm, TurboMan <yusufce...@gmail.com> wrote:
> Hi,
>
> I have an application which uses Camera preview feature.
> I can see the camera preview without any problem.
> But, OOH I need to capture preview frame.
> I've googled and find out the setPreviewCallback.
> But my tablet PC doesn't callback this function as follows.
> I am not sure if I am doing something wrong.
> Any help is appreciated.
>
> In SurfaceHolder.Callback class in surfaceCreated function I have the
> following code.
> [Code]
> mCamera = Camera.open();
> try {
> mCamera.setPreviewCallback(new PreviewCallback() {
> @Override
> public void onPreviewFrame(byte[] data, Camera arg1) {
> FileOutputStream outStream = null;
> try {
> outStream = new FileOutputStream(String.format(
> "/sdcard/%d.jpg", System.currentTimeMillis()));
> outStream.write(data);
> outStream.close();
> Log.d(TAG, "onPreviewFrame - wrote bytes: "
> + data.length);
> } catch (FileNotFoundException e) {
> e.printStackTrace();
> } catch (IOException e) {
> e.printStackTrace();
> } finally {
> }
> Preview.this.invalidate();
> }
> });
> mCamera.setPreviewDisplay(holder);
> } catch (IOException exception) {
> //} finally {
> mCamera.release();
> mCamera = null;
> }
> [/Code]
--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
No comments:
Post a Comment