├── .gitignore ├── settings.gradle ├── testSurfaceView.apk ├── res ├── drawable │ └── ic_launcher.png ├── values │ ├── colors.xml │ ├── strings.xml │ ├── attrs.xml │ └── styles.xml └── layout │ └── activity_main.xml ├── gradle └── wrapper │ └── gradle-wrapper.properties ├── README.md ├── .idea └── runConfigurations.xml ├── project.properties ├── src └── com │ └── example │ └── openglcamera │ ├── TouchActivity.java │ ├── SurfaceTextureActivity.java │ └── CameraPreview.java ├── app ├── build.gradle └── app.iml ├── .project ├── OpenGLCamera.iml ├── AndroidManifest.xml ├── LICENSE ├── gradlew.bat └── gradlew /.gitignore: -------------------------------------------------------------------------------- 1 | local.* -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /testSurfaceView.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexcohn/OpenGLCamera/HEAD/testSurfaceView.apk -------------------------------------------------------------------------------- /res/drawable/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexcohn/OpenGLCamera/HEAD/res/drawable/ic_launcher.png -------------------------------------------------------------------------------- /res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #66000000 4 | 5 | 6 | -------------------------------------------------------------------------------- /res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | OpenGLCamera 5 | Dummy Button 6 | DUMMY\nCONTENT 7 | 8 | 9 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | OpenGLCamera 2 | ============ 3 | 4 | Android camera using SurfaceTexture 5 | 6 | This is a minimalistic example of custom camera preview app that uses SurfaceTexture and uses a matrix transform to change the way it is displayed. 7 | 8 | Here, we show front camera image not as a mirror. 9 | 10 | Many details like error checking have been skipped for brevity. In the real world, you will open the camera on a separate EventThread, so that the camera callbacks would not interfere with UI thread. 11 | 12 | Depends on android-support-v4.jar -------------------------------------------------------------------------------- /res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-19 15 | -------------------------------------------------------------------------------- /src/com/example/openglcamera/TouchActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.openglcamera; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.view.SurfaceView; 6 | 7 | 8 | public class TouchActivity extends Activity { 9 | 10 | static TouchActivity reference; 11 | 12 | @Override 13 | protected void onCreate(Bundle savedInstanceState) { 14 | super.onCreate(savedInstanceState); 15 | reference = this; 16 | SurfaceView sv = new SurfaceView(this); 17 | sv.getHolder().addCallback(new CameraPreview(640, 480)); 18 | setContentView(sv); 19 | } 20 | 21 | TouchActivity getActivity() { 22 | return this; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 19 5 | buildToolsVersion "22.0.1" 6 | 7 | defaultConfig { 8 | applicationId "com.example.openglcamera" 9 | minSdkVersion 14 10 | targetSdkVersion 18 11 | } 12 | 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 17 | } 18 | } 19 | 20 | sourceSets { 21 | main { 22 | manifest.srcFile '../AndroidManifest.xml' 23 | java.srcDirs = ['../src'] 24 | res.srcDirs = ['../res'] 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | OpenGLCamera 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /OpenGLCamera.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 | 13 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 15 | 16 | 17 | 20 | 21 | 27 | 28 | 35 | 36 |