parent
9c912e925b
commit
4e338039c2
@ -0,0 +1,14 @@ |
|||||||
|
package com.flurgle.camerakit; |
||||||
|
|
||||||
|
/** |
||||||
|
* Simple pojo containing various camera properties. |
||||||
|
*/ |
||||||
|
public class ExtraProperties { |
||||||
|
public final float verticalViewingAngle; |
||||||
|
public final float horizontalViewingAngle; |
||||||
|
|
||||||
|
public ExtraProperties(float verticalViewingAngle, float horizontalViewingAngle) { |
||||||
|
this.verticalViewingAngle = verticalViewingAngle; |
||||||
|
this.horizontalViewingAngle = horizontalViewingAngle; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,68 @@ |
|||||||
|
package com.flurgle.camerakit; |
||||||
|
|
||||||
|
import android.annotation.TargetApi; |
||||||
|
import android.content.Context; |
||||||
|
import android.graphics.SurfaceTexture; |
||||||
|
import android.view.Surface; |
||||||
|
import android.view.SurfaceHolder; |
||||||
|
import android.view.SurfaceView; |
||||||
|
import android.view.TextureView; |
||||||
|
import android.view.View; |
||||||
|
import android.view.ViewGroup; |
||||||
|
|
||||||
|
// This is not used.
|
||||||
|
class SurfaceViewPreview extends PreviewImpl { |
||||||
|
|
||||||
|
private final SurfaceView mSurfaceView; |
||||||
|
|
||||||
|
SurfaceViewPreview(Context context, ViewGroup parent) { |
||||||
|
final View view = View.inflate(context, R.layout.surface_view, parent); // MATCH_PARENT
|
||||||
|
mSurfaceView = (SurfaceView) view.findViewById(R.id.surface_view); |
||||||
|
final SurfaceHolder holder = mSurfaceView.getHolder(); |
||||||
|
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); |
||||||
|
holder.addCallback(new SurfaceHolder.Callback() { |
||||||
|
@Override |
||||||
|
public void surfaceCreated(SurfaceHolder holder) { |
||||||
|
setSurfaceSize(mSurfaceView.getWidth(), mSurfaceView.getHeight()); |
||||||
|
dispatchSurfaceChanged(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { |
||||||
|
setSurfaceSize(width, height); |
||||||
|
dispatchSurfaceChanged(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void surfaceDestroyed(SurfaceHolder holder) { |
||||||
|
setSurfaceSize(0, 0); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
Surface getSurface() { |
||||||
|
return getSurfaceHolder().getSurface(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
View getView() { |
||||||
|
return mSurfaceView; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
SurfaceHolder getSurfaceHolder() { |
||||||
|
return mSurfaceView.getHolder(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
Class getOutputClass() { |
||||||
|
return SurfaceHolder.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
boolean isReady() { |
||||||
|
return mSurfaceView.getWidth() != 0 && mSurfaceView.getHeight() != 0; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,10 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<merge xmlns:android="http://schemas.android.com/apk/res/android"> |
||||||
|
|
||||||
|
<SurfaceView |
||||||
|
android:id="@+id/surface_view" |
||||||
|
android:gravity="center" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent" /> |
||||||
|
|
||||||
|
</merge> |
@ -0,0 +1,14 @@ |
|||||||
|
package com.flurgle.camerakit; |
||||||
|
|
||||||
|
import android.support.annotation.IntDef; |
||||||
|
|
||||||
|
import java.lang.annotation.Retention; |
||||||
|
import java.lang.annotation.RetentionPolicy; |
||||||
|
|
||||||
|
import static com.flurgle.camerakit.CameraKit.Constants.SESSION_TYPE_PICTURE; |
||||||
|
import static com.flurgle.camerakit.CameraKit.Constants.SESSION_TYPE_VIDEO; |
||||||
|
|
||||||
|
@Retention(RetentionPolicy.SOURCE) |
||||||
|
@IntDef({SESSION_TYPE_PICTURE, SESSION_TYPE_VIDEO}) |
||||||
|
public @interface SessionType { |
||||||
|
} |
@ -0,0 +1,18 @@ |
|||||||
|
package com.flurgle.camerakit; |
||||||
|
|
||||||
|
import android.support.annotation.IntDef; |
||||||
|
|
||||||
|
import java.lang.annotation.Retention; |
||||||
|
import java.lang.annotation.RetentionPolicy; |
||||||
|
|
||||||
|
import static com.flurgle.camerakit.CameraKit.Constants.WHITE_BALANCE_AUTO; |
||||||
|
import static com.flurgle.camerakit.CameraKit.Constants.WHITE_BALANCE_INCANDESCENT; |
||||||
|
import static com.flurgle.camerakit.CameraKit.Constants.WHITE_BALANCE_FLUORESCENT; |
||||||
|
import static com.flurgle.camerakit.CameraKit.Constants.WHITE_BALANCE_DAYLIGHT; |
||||||
|
import static com.flurgle.camerakit.CameraKit.Constants.WHITE_BALANCE_CLOUDY; |
||||||
|
|
||||||
|
@Retention(RetentionPolicy.SOURCE) |
||||||
|
@IntDef({WHITE_BALANCE_AUTO, WHITE_BALANCE_INCANDESCENT, WHITE_BALANCE_FLUORESCENT, |
||||||
|
WHITE_BALANCE_DAYLIGHT, WHITE_BALANCE_CLOUDY}) |
||||||
|
public @interface WhiteBalance { |
||||||
|
} |
@ -0,0 +1,14 @@ |
|||||||
|
package com.flurgle.camerakit; |
||||||
|
|
||||||
|
import android.support.annotation.IntDef; |
||||||
|
|
||||||
|
import java.lang.annotation.Retention; |
||||||
|
import java.lang.annotation.RetentionPolicy; |
||||||
|
|
||||||
|
import static com.flurgle.camerakit.CameraKit.Constants.ZOOM_OFF; |
||||||
|
import static com.flurgle.camerakit.CameraKit.Constants.ZOOM_PINCH; |
||||||
|
|
||||||
|
@Retention(RetentionPolicy.SOURCE) |
||||||
|
@IntDef({ZOOM_OFF, ZOOM_PINCH}) |
||||||
|
public @interface ZoomMode { |
||||||
|
} |
@ -0,0 +1,43 @@ |
|||||||
|
package com.flurgle.camerakit; |
||||||
|
|
||||||
|
class RotationHelper { |
||||||
|
|
||||||
|
|
||||||
|
static byte[] rotate(final byte[] yuv, final int width, final int height, final int rotation) { |
||||||
|
if (rotation == 0) return yuv; |
||||||
|
if (rotation % 90 != 0 || rotation < 0 || rotation > 270) { |
||||||
|
throw new IllegalArgumentException("0 <= rotation < 360, rotation % 90 == 0"); |
||||||
|
} |
||||||
|
final byte[] output = new byte[yuv.length]; |
||||||
|
final int frameSize = width * height; |
||||||
|
final boolean swap = rotation % 180 != 0; |
||||||
|
final boolean xflip = rotation % 270 != 0; |
||||||
|
final boolean yflip = rotation >= 180; |
||||||
|
|
||||||
|
for (int j = 0; j < height; j++) { |
||||||
|
for (int i = 0; i < width; i++) { |
||||||
|
final int yIn = j * width + i; |
||||||
|
final int uIn = frameSize + (j >> 1) * width + (i & ~1); |
||||||
|
final int vIn = uIn + 1; |
||||||
|
|
||||||
|
final int wOut = swap ? height : width; |
||||||
|
final int hOut = swap ? width : height; |
||||||
|
final int iSwapped = swap ? j : i; |
||||||
|
final int jSwapped = swap ? i : j; |
||||||
|
final int iOut = xflip ? wOut - iSwapped - 1 : iSwapped; |
||||||
|
final int jOut = yflip ? hOut - jSwapped - 1 : jSwapped; |
||||||
|
|
||||||
|
final int yOut = jOut * wOut + iOut; |
||||||
|
final int uOut = frameSize + (jOut >> 1) * wOut + (iOut & ~1); |
||||||
|
final int vOut = uOut + 1; |
||||||
|
|
||||||
|
output[yOut] = (byte) (0xff & yuv[yIn]); |
||||||
|
output[uOut] = (byte) (0xff & yuv[uIn]); |
||||||
|
output[vOut] = (byte) (0xff & yuv[vIn]); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return output; |
||||||
|
} |
||||||
|
} |
||||||
|
|
Loading…
Reference in new issue