1

Working on Android mobile Camera effects.

How to get Camera shake effect? Tried adding shake animation to the surfaceview, but its not shaking the camera view. Camera view remains stable(i.e., whatever i can view from camera on the screen should shake, instead view is shaking).

How to achieve this complete effect in android?

This is handled by iOS using the filter GPUImageTransformFilter. I want an alternative to achieve this.

Pavandroid
  • 1,586
  • 2
  • 15
  • 30
  • 8
    Have you tried shaking the device? – miki Jul 24 '15 at 17:23
  • Do you want to record video with this, or just shake it on screen? What is supposed to happen at the edges? – fadden Jul 24 '15 at 17:51
  • @ miki Nope, Can you provide me more info. @ fadden Just shake effect on the screen. No need of recording. Black screen will be shown in the BG. – Pavandroid Jul 24 '15 at 22:48
  • 1
    You could send it to a TextureView, and apply a translation to the matrix. For example, see `adjustAspectRatio()` in https://github.com/google/grafika/blob/master/src/com/android/grafika/PlayMovieActivity.java#L211 , which applies scale and translation changes (and, if you uncomment it, a rotation). – fadden Jul 25 '15 at 15:19
  • 2
    @fadden You used android.view.TextureView while am having android.opengl.GLSurfaceView. As per the link "https://github.com/crosswalk-project/crosswalk-website/wiki/Android-SurfaceView-vs-TextureView", We can not apply animations to SurfaceView. – Pavandroid Jul 27 '15 at 02:14
  • I will try changing to TextureView – Pavandroid Jul 27 '15 at 02:22
  • Animation worked with TextueView. But, I want this effect for GLSurfaceView as i need to use https://github.com/CyberAgent/android-gpuimage library which only supports SurfaceView. – Pavandroid Jul 27 '15 at 02:39
  • @fadden Can you please respond. – Pavandroid Jul 28 '15 at 07:14
  • Take the Y+ values of a high-frequency sine wave, and apply an offset to all objects in the SurfaceView. If you want to shake it horizontally, apply a Y axis height difference to the object's X position. I do not have any knowledge as to what the final product of your Camera shake is going to be, so I assumed your Camera shake is more of a "earthquake-shattering" vibration. – tom_mai78101 Aug 05 '15 at 05:05

1 Answers1

0

Why not simply extend a new class that gives that functionality?

class CustomView extends SurfaceView {
    //override or create methods that did what the TextureView did,
    //such as setTransform,etc.
}

Then it'd work perfectly with the package, and would have any additional functionality that you need it to.

You could also create an interface that has these methods:

interface Transformable{
    protected setTransform(Matrix mx);
}

Then extend the class and implement the interface..

class CustomView extends SurfaceView implements Transformable{
    @Override
    protected setTransform(Matrix mx){
        //do stuff here
        //this.getMatrix().set(mx);
}
}

You could then use the interface on any other View that doesn't have the functionality.