Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ objs/
obj/
build/
library/.cxx/
.kotlin/
.kotlin/

# CodeQL
_codeql_detected_source_root
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ public void run() {
content += String.format("Accuracy: %g, center %g, %g, eyeDis: %g\n", face.confidence(), pnt.x, pnt.y, eyeDis);
canvas.drawRect((int) (pnt.x - eyeDis * 1.5f), (int) (pnt.y - eyeDis * 1.5f), (int) (pnt.x + eyeDis * 1.5f), (int) (pnt.y + eyeDis * 1.5f), paint);

//眼睛中心
// Eye center
canvas.drawRect((int) (pnt.x - 2.0f), (int) (pnt.y - 2.0f), (int) (pnt.x + 2.0f), (int) (pnt.y + 2.0f), paint);

//双眼
// Both eyes
canvas.drawRect((int) (pnt.x - halfEyeDis - 2.0f), (int) (pnt.y - 2.0f), (int) (pnt.x - halfEyeDis + 2.0f), (int) (pnt.y + 2.0f), paint);
canvas.drawRect((int) (pnt.x + halfEyeDis - 2.0f), (int) (pnt.y - 2.0f), (int) (pnt.x + halfEyeDis + 2.0f), (int) (pnt.y + 2.0f), paint);
}
Expand Down
10 changes: 5 additions & 5 deletions cgeDemo/src/main/java/org/wysaid/cgeDemo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class MainActivity extends AppCompatActivity {

public static final String EFFECT_CONFIGS[] = {
"",
"@curve RGB(0,255)(255,0) @style cm mapping0.jpg 80 80 8 3", // ASCII art (字符画效果)
"@curve RGB(0,255)(255,0) @style cm mapping0.jpg 80 80 8 3", // ASCII art effect
"@style waveform 0.01 0.01 0.4 0.4",
"@beautify face 1 480 640", //Beautify
"@adjust lut edgy_amber.png",
Expand Down Expand Up @@ -144,7 +144,7 @@ public class MainActivity extends AppCompatActivity {
public CGENativeLibrary.LoadImageCallback mLoadImageCallback = new CGENativeLibrary.LoadImageCallback() {

//Notice: the 'name' passed in is just what you write in the rule, e.g: 1.jpg
//注意, 这里回传的name不包含任何路径名, 仅为具体的图片文件名如 1.jpg
// Note: The name returned here does not contain any path name, only the specific image filename such as 1.jpg
@Override
public Bitmap loadImage(String name, Object arg) {

Expand All @@ -167,8 +167,8 @@ public void loadImageOK(Bitmap bmp, Object arg) {

//The bitmap is which you returned at 'loadImage'.
//You can call recycle when this function is called, or just keep it for further usage.
//唯一不需要马上recycle的应用场景为 多个不同的滤镜都使用到相同的bitmap
//那么可以选择缓存起来。
// The only scenario where immediate recycle is not needed is when multiple different filters use the same bitmap
// Then it can be cached.
bmp.recycle();
}
};
Expand Down Expand Up @@ -251,7 +251,7 @@ protected void onCreate(Bundle savedInstanceState) {
}

//The second param will be passed as the second arg of the callback function.
//第二个参数根据自身需要设置, 将作为 loadImage 第二个参数回传
// The second parameter is set according to your needs and will be passed back as the second parameter of loadImage
CGENativeLibrary.setLoadImageCallback(mLoadImageCallback, null);
PermissionUtil.verifyStoragePermissions(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,13 @@ public void onClick(View v) {
mPlayerView.setPlayerInitializeCallback(new VideoPlayerGLSurfaceView.PlayerInitializeCallback() {
@Override
public void initPlayer(final MediaPlayer player) {
//针对网络视频进行进度检查
// Check progress for network videos
player.setOnBufferingUpdateListener(new MediaPlayer.OnBufferingUpdateListener() {
@Override
public void onBufferingUpdate(MediaPlayer mp, int percent) {
Log.i(Common.LOG_TAG, "Buffer update: " + percent);
if (percent == 100) {
Log.i(Common.LOG_TAG, "缓冲完毕!");
Log.i(Common.LOG_TAG, "Buffering complete!");
player.setOnBufferingUpdateListener(null);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Created by wysaid on 16/3/9.
* Mail: admin@wysaid.org
* blog: wysaid.org
* Description: algorithm目录的所有类都是为了OpenGL 辅助使用, 所以 float 使用较多.
* Description: All classes in the algorithm directory are for OpenGL auxiliary use, so float is used extensively.
*/
public class AlgorithmUtil {
public static float getNormalizeScaling(final float x, final float y, final float z) {
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/java/org/wysaid/common/ProgramObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class ProgramObject {
private int mProgramID;
private ShaderObject mVertexShader, mFragmentShader;

//单独初始化之后可以进行一些 attribute location 的绑定操作
// After separate initialization, some attribute location binding operations can be performed
//之后再进行init
public ProgramObject() {
mProgramID = GLES20.glCreateProgram();
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/java/org/wysaid/common/SharedContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class SharedContext {

private static int mBitsR = 8, mBitsG = 8, mBitsB = 8, mBitsA = 8;

//注意, 设置之后将影响之后的所有操作
// Note: After setting, it will affect all subsequent operations
static public void setContextColorBits(int r, int g, int b, int a) {
mBitsR = r;
mBitsG = g;
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/java/org/wysaid/myUtils/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static String getPathInPackage(Context context, boolean grantPermissions)
if(context == null || packageFilesDirectory != null)
return packageFilesDirectory;

//手机不存在sdcard, 需要使用 data/data/name.of.package/files 目录
// Phone does not have sdcard, need to use data/data/name.of.package/files directory
String path = context.getFilesDir() + "/" + mDefaultFolder;
File file = new File(path);

Expand Down
2 changes: 1 addition & 1 deletion library/src/main/java/org/wysaid/myUtils/ImageUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static String saveBitmap(Bitmap bmp, String filename) {
}

public static class FaceRects {
public int numOfFaces; // 实际检测出的人脸数
public int numOfFaces; // Number of faces actually detected
public FaceDetector.Face[] faces; // faces.length >= numOfFaces
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ protected void finalize() throws Throwable {
// sIsTrackerSetup = true;
// }

//命名Simple 是因为后续将接入更加完整的结果数据(包含66个点的网格等等)
// Named Simple because more complete result data (including 66-point mesh etc.) will be integrated in the future
public FaceResultSimple detectFaceWithSimpleResult(Bitmap bmp, boolean drawFeature) {
float[] result = nativeDetectFaceWithSimpleResult(mNativeAddress, bmp, drawFeature);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public CGEFrameRecorder() {
mNativeAddress = nativeCreateRecorder();
}

/////////////////视频录制相关////////////////////
///////////////// Video recording related ////////////////////

public boolean startRecording(int fps, String filename) {
return startRecording(fps, 1650000, filename);
Expand Down Expand Up @@ -119,7 +119,7 @@ public void isGlobalFilterEnabled() {

private native long nativeCreateRecorder();

/////////////////视频录制相关////////////////////
///////////////// Video recording related ////////////////////
private native boolean nativeStartRecording(long holder, int fps, String filename, int bitRate);
private native boolean nativeIsRecordingStarted(long holder);
private native boolean nativeEndRecording(long holder, boolean shouldSave);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,6 @@ public void setNativeFilter(long nativeFilter) {
//辅助方法
protected native void nativeProcessWithFilter(long holder, long nativeFilter);

//特殊用法, 谨慎使用, 使用不当可能造成程序运行异常.
// Special usage, use with caution, improper use may cause program runtime exceptions.
protected native void nativeSetFilterWithAddr(long holder, long filter);
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public enum BlendFilterType {
BLEND_TILE,
}

//带纹理的 blendFilter 较为特殊, 增加单独处理方法, 第二个参数 texID 表示将要使用到的纹理id
// blendFilter with texture is special, add separate processing method, the second parameter texID represents the texture id to be used
public static long createBlendFilter(TextureBlendMode blendMode, int texID, int texWidth, int texHeight, BlendFilterType blendFilterType, float intensity) {
return cgeCreateBlendFilter(blendMode.ordinal(), texID, texWidth, texHeight, blendFilterType.ordinal(), intensity);
}
Expand All @@ -153,7 +153,7 @@ public static long createBlendFilter(TextureBlendMode blendMode, int texID, int
// intensity 表示滤镜强度 [0, 1]
public static native Bitmap cgeFilterImage_MultipleEffects(Bitmap bmp, String config, float intensity);

// 同上, 结果直接写回传入bitmap, 无返回值
// Same as above, result is written back directly to the input bitmap, no return value
public static native void cgeFilterImage_MultipleEffectsWriteBack(Bitmap bmp, String config, float intensity);

////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public abstract class TextureRenderer {

public static final String LOG_TAG = Common.LOG_TAG;

//初始化program 等
// Initialize program etc.
public abstract boolean init(boolean isExternalOES);

//为了保证GLContext 的对应, 不能等待finalize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class TextureRendererDrawOrigin extends TextureRenderer {
" gl_FragColor = texture2D(inputImageTexture, texCoord);\n" +
"}";

//初始化默认的顶点序列等。
// Initialize default vertex sequence etc.
protected TextureRendererDrawOrigin() {
defaultInitialize();
}
Expand Down
10 changes: 5 additions & 5 deletions library/src/main/java/org/wysaid/view/CameraGLSurfaceView.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void setFitFullView(boolean fit) {
calcViewport();
}

//是否使用后置摄像头
// Whether to use back camera
protected boolean mIsCameraBackForward = true;

public boolean isCameraBackForward() {
Expand All @@ -133,9 +133,9 @@ public void presetCameraForward(boolean isBackForward) {
mIsCameraBackForward = isBackForward;
}

//注意, 录制的尺寸将影响preview的尺寸
//这里的width和height表示竖屏尺寸
//在onSurfaceCreated之前设置有效
// Note: The size of recording will affect the size of preview
// Here width and height represent portrait size
// Set before onSurfaceCreated to take effect
public void presetRecordingSize(int width, int height) {
if (width > mMaxPreviewWidth || height > mMaxPreviewHeight) {
float scaling = Math.min(mMaxPreviewWidth / (float) width, mMaxPreviewHeight / (float) height);
Expand Down Expand Up @@ -209,7 +209,7 @@ public interface OnCreateCallback {

protected OnCreateCallback mOnCreateCallback;

//定制一些初始化操作
// Customize some initialization operations
public void setOnCreateCallback(final OnCreateCallback callback) {
mOnCreateCallback = callback;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void run() {
});
}

//定制一些初始化操作
// Customize some initialization operations
public void setOnCreateCallback(final OnCreateCallback callback) {
if (mFrameRecorder == null || callback == null) {
mOnCreateCallback = callback;
Expand Down Expand Up @@ -325,7 +325,7 @@ public void onPictureTaken(final byte[] data, Camera camera) {
int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);

switch (orientation) {
//被保存图片exif记录只有旋转90度, 和不旋转两种情况
// Saved image exif records only two cases: 90 degree rotation and no rotation
case ExifInterface.ORIENTATION_ROTATE_90:
shouldRotate = true;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public void run() {
return;
}

//判断音频录制是否被初始化
// Check if audio recording is initialized
while (this.audioRecord.getState() == 0) {
try {
Thread.sleep(100L);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void setFitFullView(boolean fit) {

public interface PlayerInitializeCallback {

//对player 进行初始化设置, 设置未默认启动的listener, 比如 bufferupdateListener.
// Initialize player settings, set listeners that are not started by default, such as bufferupdateListener.
void initPlayer(MediaPlayer player);
}

Expand Down Expand Up @@ -152,8 +152,8 @@ public void run() {
}

//根据传入bmp回调不同
//若设置之后使用mask, 则调用 setMaskOK
//否则调用 unsetMaskOK
// If mask is used after setting, call setMaskOK
// Otherwise call unsetMaskOK
public interface SetMaskBitmapCallback {
void setMaskOK(TextureRendererMask renderer);

Expand Down Expand Up @@ -247,10 +247,10 @@ public interface OnCreateCallback {

private OnCreateCallback mOnCreateCallback;

//定制一些初始化操作
// Customize some initialization operations
public void setOnCreateCallback(final OnCreateCallback callback) {

assert callback != null : "无意义操作!";
assert callback != null : "Meaningless operation!";

if (mDrawer == null) {
mOnCreateCallback = callback;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void setFitFullView(boolean fit) {

public interface PlayerInitializeCallback {

//对player 进行初始化设置, 设置未默认启动的listener, 比如 bufferupdateListener.
// Initialize player settings, set listeners that are not started by default, such as bufferupdateListener.
void initPlayer(MediaPlayer player);
}

Expand Down Expand Up @@ -220,10 +220,10 @@ public interface OnCreateCallback {

private OnCreateCallback mOnCreateCallback;

//定制一些初始化操作
// Customize some initialization operations
public void setOnCreateCallback(final OnCreateCallback callback) {

assert callback != null : "无意义操作!";
assert callback != null : "Meaningless operation!";

if (mFrameRenderer == null) {
mOnCreateCallback = callback;
Expand Down
14 changes: 7 additions & 7 deletions library/src/main/jni/cge/common/cgeCommonDefine.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
} while (0)

/*
为节省texture资源,对OpenGL 所有texture的使用约束如下:
0号和1号纹理在各种初始化中可能会被多次用到,如果需要绑定固定的纹理,
请在使用纹理时,从 TEXTURE_START 开始。
不排除这种需要会增加,所以,
请使用下面的宏进行加法运算, 以代替手写的 GL_TEXTURE*
To save texture resources, the usage constraints for all OpenGL textures are as follows:
Textures 0 and 1 may be used multiple times during various initializations. If you need to bind a fixed texture,
please start from TEXTURE_START when using textures.
This requirement may increase, so
please use the macros below for addition operations instead of manually writing GL_TEXTURE*

*/

Expand Down Expand Up @@ -328,7 +328,7 @@ typedef enum CGEGlobalBlendMode
CGEGLOBAL_BLEND_ALPHA_SEPERATE,
CGEGLOBAL_BLEND_ADD,
CGEGLOBAL_BLEND_ADD_SEPARATE,
CGEGLOBAL_BLEND_ADD_SEPARATE_EXT, // 带EXT的忽略alpha是否预乘
CGEGLOBAL_BLEND_ADD_SEPARATE_EXT, // EXT versions ignore whether alpha is premultiplied
CGEGLOBAL_BLEND_MULTIPLY,
CGEGLOBAL_BLEND_MULTIPLY_SEPERATE,
CGEGLOBAL_BLEND_SCREEN,
Expand All @@ -337,7 +337,7 @@ typedef enum CGEGlobalBlendMode

const char* cgeGetVersion();
void cgePrintGLString(const char*, GLenum);
bool _cgeCheckGLError(const char* name, const char* file, int line); // 请直接使用 cgeCheckGLError
bool _cgeCheckGLError(const char* name, const char* file, int line); // Please use cgeCheckGLError directly

////////////////////////////////////

Expand Down
12 changes: 6 additions & 6 deletions library/src/main/jni/cge/common/cgeGLFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ void cgeDisableGlobalGLContext();

#endif

// CGEBufferLoadFun 的返回值将作为 CGEBufferUnloadFun 的第一个参数
// CGEBufferLoadFun 的参数 arg 将作为 CGEBufferUnloadFun 的第二个参数
// The return value of CGEBufferLoadFun will be used as the first parameter of CGEBufferUnloadFun
// The parameter arg of CGEBufferLoadFun will be used as the second parameter of CGEBufferUnloadFun
typedef void* (*CGEBufferLoadFun)(const char* sourceName, void** bufferData, GLint* w, GLint* h, CGEBufferFormat* fmt, void* arg);
typedef bool (*CGEBufferUnloadFun)(void* arg1, void* arg2);

// 加载纹理回调, 注, 为了保持接口简洁性, 回调返回的纹理单元将由调用者负责释放
// 返回的纹理不应该为 glDeleteTextures 无法处理的特殊纹理类型.
// Load texture callback. Note: To keep the interface simple, the caller is responsible for releasing the texture unit returned by the callback
// The returned texture should not be a special texture type that glDeleteTextures cannot handle.
typedef GLuint (*CGETextureLoadFun)(const char* sourceName, GLint* w, GLint* h, void* arg);

// You can set a common function for loading textures
Expand Down Expand Up @@ -171,7 +171,7 @@ class TextureObject

void cleanup(bool deleteTexture = true);

// 注意, format 不支持改变, 如果有相关需求需要自行添加
// Note: format change is not supported, if there is a related need, please add it yourself
bool resize(int w, int h, const void* buffer = nullptr, GLenum format = GL_RGBA);
inline bool updateTextureData(int w, int h, const void* buffer = nullptr, GLenum format = GL_RGBA)
{
Expand Down Expand Up @@ -232,7 +232,7 @@ struct CGELuminance
return (r * RWeight + g * GWeight + b * BWeight) >> CalcPrecision;
}

// color 从低位到高位的顺序为r-g-b, 传参时需要注意大小端问题
// color order from low to high bit is r-g-b, pay attention to endianness when passing parameters
static inline int RGB565(unsigned short color)
{
const int r = (color & 31) << 3;
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/jni/cge/common/cgeGlobal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void cgeInitFilterStatus()

#if defined(_CGE_USE_ES_API_3_0_) && defined(GL_PIXEL_PACK_BUFFER)

//使用此段代码此时 GL_PIXEL_PACK_BUFFER 是否被支持
// Whether GL_PIXEL_PACK_BUFFER is supported when using this code
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
if (glGetError() == GL_FALSE)
{
Expand Down
Loading