problems with the camera


Last Updated:

  1. chusobadenas

    chusobadenas New Member This Topic's Starter

    Joined:
    Sep 7, 2010
    Messages:
    3
    Likes Received:
    0
    Hi everyone!

    I'm developing an application that uses the camera.

    The idea is to get frames continuosly and modify this photos (for example convert to grey scale) and show the result in real time.

    I'm using the method onPreviewFrame(byte[] data, Camera camera) to get the image and convert it.

    The question is, once the conversion is already done, how I refresh the preview in real time to obtain the modified image?

    I try with this code, but it's not working:

    Camera.PreviewCallback previewCall = new Camera.PreviewCallback() {
    public void onPreviewFrame(byte[] data, Camera camera) {
    // Do something with the preview image.
    if (isPreviewRunning) {
    camera.stopPreview();
    isPreviewRunning = false;
    }

    Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length, opt);

    mRgbImage = mRgbImageAndroid.toRgbImage(bitmap);

    mRgbImage.greyScale();

    Canvas c = surfaceHolder.lockCanvas();

    c.drawBitmap(mRgbImage.getData(), 0, mRgbImage.getWidth(), 0, 0, mRgbImage.getWidth(), mRgbImage.getHeight(), false, null);

    surfaceHolder.unlockCanvasAndPost(c);

    try {
    camera.setPreviewDisplay(surfaceHolder);
    } catch (IOException e) {
    Log.d("3", "Error al actualizar la imagen");
    camera.release();
    }

    camera.startPreview();
    isPreviewRunning = true;
    }
    };

    Thanks ;)
     

    Advertisement
  2. couch

    couch Member

    Joined:
    Jul 13, 2010
    Messages:
    6
    Likes Received:
    0
    If you want to change the view to black and white you can do that from the Camera.Parameters settings. There are a number of different filters that you can use, and you dont have to worry about the nightmare of converting the image data back into an image, you can just use the camera preview.
     
  3. chusobadenas

    chusobadenas New Member This Topic's Starter

    Joined:
    Sep 7, 2010
    Messages:
    3
    Likes Received:
    0
    Thanks, but this code is only an example... i want to do more things than convert the image to grayscale.

    My intent is to work with the image information to do anything with it, and for that I should be able to modify it and then preview it.
     

Share This Page

Loading...