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