hi,
     I am sending the onpreviewFrame byte array to socket it send the first 
image but on callback it does not send any image and go to Exception what's the 
reason. Here is my code &  logCat result


 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) { // <10>
                        e.printStackTrace();
                     } catch (IOException e) {
                        e.printStackTrace();
                     } finally {
                     }
                Preview.this.invalidate();
                }
               }
          });
       obj.close();
    } catch (IOException e) { // <13>
      e.printStackTrace();
    }
  }

/////////////////////////    according to logCat

01-08 17:52:07.033: ERROR/mm-camera 7x-vfe(3726): Received VFE Stop ACK!!! 
ctrlCmd is NULL
01-08 17:52:07.533: ERROR/mm-camera(3726): +++ DELETING LEAKED MEMORY AT 
0x2c790 (2 REMAINING)
01-08 17:52:07.533: ERROR/mm-camera(3726):      6 0xa742e2fc
01-08 17:52:07.533: ERROR/mm-camera(3726):      5 0xa740cd0a
01-08 17:52:07.533: ERROR/mm-camera(3726):      4 0xa740e576
01-08 17:52:07.533: ERROR/mm-camera(3726):      3 0xa740e066
01-08 17:52:07.533: ERROR/mm-camera(3726):      2 0xafd110b0
01-08 17:52:07.533: ERROR/mm-camera(3726):      1 0xafd10b94
01-08 17:52:07.533: ERROR/mm-camera(3726): +++ DELETING LEAKED MEMORY AT 
0x2e648 (1 REMAINING)
01-08 17:52:07.533: ERROR/mm-camera(3726):      6 0xa742e2fc
01-08 17:52:07.543: ERROR/mm-camera(3726):      5 0xa740cd0a
01-08 17:52:07.543: ERROR/mm-camera(3726):      4 0xa740e576
01-08 17:52:07.543: ERROR/mm-camera(3726):      3 0xa740e066
01-08 17:52:07.543: ERROR/mm-camera(3726):      2 0xafd110b0
01-08 17:52:07.543: ERROR/mm-camera(3726):      1 0xafd10b94
01-08 17:52:18.223: ERROR/QualcommCameraHardware(3726): native_access_parm: 
error (No such file or directory): fd 12, type 1, length 32, status 0
01-08 17:52:18.523: ERROR/mm-camera 7x-vfe(3726): Received VFE start ACK!!! 
This is a user preview start.

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