hi,
     I am sending the onpreviewFrame byte array to socket. it send the
first image but due to onPreviewframe callback it does not send any
image and go to Exception. I want to send images to socket
continuously. 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) {
                        e.printStackTrace();
                     } catch (IOException e) {
                        e.printStackTrace();
                     } finally {
                     }
                Preview.this.invalidate();
                }
               }
          });
       obj.close();
    } catch (IOException e) {
      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

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