hi reghavsood,
                      I am new on android. i don't know about logcat but i 
debug during capturing the frames it send frist frame but on next frame it go 
to exception.

Thanks
Date: Sun, 8 Jan 2012 14:11:55 +0530
Subject: Re: [android-developers] onPreviewFrame got Exception???
From: [email protected]
To: [email protected]

What does the LogCat say?

On Sun, Jan 8, 2012 at 2:08 PM, [email protected] 
<[email protected]> wrote:

hi,

 á áPlease anyone tell me that when onPreviewFrame call it send first

frame of the preview to socket but when it callback it get exception

and does send any frame to socket, I want to send images from

onPreviewFrame continuously. áPlease tell me what's the reason, and

sorry for my English. Here is my code.



ápublic void surfaceCreated(SurfaceHolder holder) {

 á á// The Surface has been created, acquire the camera and tell it

where

 á á// to draw.

 á á á á//////////////////connection to server

 á á á á átry {

 á á á á á á á ásocket = new Socket("192.168.1.220", 8888);

 á á á á á á á áobj = new ObjectOutputStream(socket.getOutputStream());

 á á á á} catch (UnknownHostException e1) {

 á á á á á á á á// TODO Auto-generated catch block

 á á á á á á á áe1.printStackTrace();

 á á á á} catch (IOException e1) {

 á á á á á á á á// TODO Auto-generated catch block

 á á á á á á á áe1.printStackTrace();

 á á á á}





 á ácamera = Camera.open();

 á átry {





 á á ácamera.setPreviewDisplay(holder);



 á á ácamera.setPreviewCallback(new PreviewCallback() {

 á á á á// Called for each frame previewed

 á á á // @SuppressWarnings("null")

 á á á á á á á ápublic void onPreviewFrame(byte[] data, Camera camera) {





 á á á á á á á áCamera.Parameters parameters = camera.getParameters();

 á á á á á á á áint format = parameters.getPreviewFormat();



 á á á á á á á á //YUV formats require more conversion

 á á á á á á á áif (format == ImageFormat.NV21 /*|| format ==

ImageFormat.YUY2 || format == ImageFormat.NV16*/)

 á á á á á á á á{

 á á á á á á á áint w = parameters.getPreviewSize().width;

 á á á á á á á áint h = parameters.getPreviewSize().height;

 á á á á á á á á// Get the YuV image

 á á á á á á á áYuvImage yuv_image = new YuvImage(data, format, w, h,

null);

 á á á á á á á á// Convert YuV to Jpeg

 á á á á á á á á á á á áRect rect = new Rect(0, 0, w, h);

 á á á á á á á á á á á áByteArrayOutputStream output_stream = new

ByteArrayOutputStream();

 á á á á á á á á á á á áyuv_image.compressToJpeg(rect, 100, output_stream);

 á á á á á á á á á á á ábyte[] byt=output_stream.toByteArray();

 á á á á á á á á á try

 á á á á á á á á á á{

 á á á á á á á á á á á á á á á á áobj.writeObject(byt);

 á á á á á á á á á á á á á á á á áobj.flush();



 á á á á á á á á á á á}

 á á á á á á á á á á catch (FileNotFoundException e) {

 á á á á á á á á á á á á á á á áe.printStackTrace();

 á á á á á á á á á á á á á á } catch (IOException e) {

 á á á á á á á á á á á á á á á áe.printStackTrace();

 á á á á á á á á á á á á á á } finally {

 á á á á á á á á á á á á á á }



 á á á á á á á á á á Preview.this.invalidate();

 á á á á á á á á á }

 á á á á á á á á }

 á á á á á á á});



 á á á } catch (IOException e) {

 á á áe.printStackTrace();

 á á}

 á}



Thanks and regards

umer



--

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



-- 
Raghav Soodhttp://www.androidactivist.org/ - Authorhttp://www.appaholics.in/ - 
Founder





-- 

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                         
                  

-- 
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

Reply via email to